This is Unofficial EPICS BASE Doxygen Site
osdTime.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void osdTimeRegister (void)
 
void osdNTPInit (void)
 
int osdNTPGet (struct timespec *)
 
void osdNTPReport (void)
 
int osdTickRateGet (void)
 
int osdTickGet (void)
 

Function Documentation

int osdNTPGet ( struct timespec )

Definition at line 45 of file osdTime.cpp.

46 {
47  static unsigned bequiet;
48  ssize_t ret;
49 
50  if (ntpSocket < 0)
51  return -1;
52 
53  /* rtems_bsdnet_get_ntp() will send an NTP request, then
54  * call recvfrom() exactly once to process the expected reply.
55  * Any leftovers in the socket buffer (ie. duplicates of
56  * previous replies) will cause problems.
57  * So flush out the socket buffer first.
58  */
59  do {
60  char junk[16];
61 
62  ret = recvfrom(ntpSocket, junk, sizeof(junk), MSG_DONTWAIT, NULL, NULL);
63  if (ret == -1 && errno == EAGAIN) {
64  break;
65  }
66  else if (ret == -1) {
67  if (!bequiet) {
68  printf("osdNTPGet cleaner error: %s\n", strerror(errno));
69  bequiet = 1;
70  }
71  break;
72  }
73  else {
74  bequiet = 0;
75  }
76  } while (ret > 0);
77 
78  return rtems_bsdnet_get_ntp(ntpSocket, NULL, ts);
79 }
#define printf
Definition: epicsStdio.h:41
#define NULL
Definition: catime.c:38
int rtems_bsdnet_get_ntp(int, int(*)(), struct timespec *)
void osdNTPInit ( void  )

Definition at line 81 of file osdTime.cpp.

82 {
83  struct sockaddr_in myAddr;
84 
85  ntpSocket = socket (AF_INET, SOCK_DGRAM, 0);
86  if (ntpSocket < 0) {
87  printf("osdNTPInit() Can't create socket: %s\n", strerror (errno));
88  return;
89  }
90  memset (&myAddr, 0, sizeof myAddr);
91  myAddr.sin_family = AF_INET;
92  myAddr.sin_port = htons (0);
93  myAddr.sin_addr.s_addr = htonl (INADDR_ANY);
94  if (bind (ntpSocket, (struct sockaddr *)&myAddr, sizeof myAddr) < 0) {
95  printf("osdNTPInit() Can't bind socket: %s\n", strerror (errno));
96  close (ntpSocket);
97  ntpSocket = -1;
98  }
99 }
#define printf
Definition: epicsStdio.h:41
void osdNTPReport ( void  )

Definition at line 101 of file osdTime.cpp.

102 {
103 }
int osdTickGet ( void  )

Definition at line 105 of file osdTime.cpp.

106 {
107  rtems_interval t;
108  rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &t);
109  return t;
110 }
int osdTickRateGet ( void  )

Definition at line 112 of file osdTime.cpp.

113 {
114  return rtemsTicksPerSecond;
115 }
rtems_interval rtemsTicksPerSecond
Definition: osdTime.cpp:142
void osdTimeRegister ( void  )

Definition at line 36 of file osdTime.cpp.

37 {
38  /* Init NTP first so it can be used to sync ClockTime */
39  NTPTime_Init(100);
41 
43 }
void ClockTime_Init(int synchronize)
void osdMonotonicInit(void)
Definition: osdMonotonic.c:19
void NTPTime_Init(int priority)
Definition: osiNTPTime.c:121
#define CLOCKTIME_SYNC
Definition: osiClockTime.h:12