summaryrefslogtreecommitdiffstats
path: root/test/rtctest.cpp
blob: f66f7f1edee6177ed8a9a37e8f0b09b50e571e69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef linux

#error "rtctest can be compiled only on linux"

#else

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <tbt.h>
#include <jutils.h>
#include <rtclock.h>

#include <string.h>
#include <errno.h>


RTClock tbtclock;

int main(int artc, char **argv) {

  int c;

  notice("Testing real time clock");

  tbtclock.init();

  if( tbtclock.set_freq( 1024L ) < 0) {
    error("can't access real time clock. have you loaded the rtc kernel module?");
    exit(0);
  }

  act("starting clock thread");

  tbtclock.start();
  

  for(c=0; c<10; c++) {
    tbtclock.sleep(500);
    act("%u check: %lu microsecs", c, tbtclock.msec);
  }

  act("sleeping three seconds while the clock runs..");
  sleep(2);

  for(c=0; c<10; c++) {
    tbtclock.sleep(1000);
    act("%u check: %lu microsecs", c, tbtclock.msec);
  }

  exit(1);
}

#endif