apps/sntpdate/sntpdate.c File Reference

#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <syslog.h>
#include <netdb.h>
#include <signal.h>
#include <ctype.h>
#include <stdarg.h>
#include <errno.h>
#include <asm/elphel/c313a.h>
#include <asm/elphel/fpgaconfa.h>
#include <sys/ioctl.h>

Include dependency graph for sntpdate.c:

Go to the source code of this file.

Data Structures

struct  ntp_stamp
struct  ntpmsg

Defines

#define NTPDATE_FILE   "/etc/sntpdate.conf"
#define NTPPORT   123
#define NTPTIMEOUT   4
#define MAXRETRY   5
#define D(x)
#define D2(x)
#define D3(x)
#define TO_FRAC(x)   ((unsigned long)((((ntp_double)x) * 1.0e-6) * NTP_SCALE))
#define TO_USEC(x)   ((unsigned long)((((ntp_double)x) * NTP_SCALE_I) * 1.0e6))
#define USESYSLOG
#define MAXNUMSERVERS   10
#define X313_WA_RTC_USEC   0x44
#define X313_WA_RTC_SEC   0x45

Typedefs

typedef double ntp_double

Functions

void set_rtc_fpga (struct timeval *)
static void log (char *str,...)
static void catch_signal (int sig)
int main (int argc, char **argv)

Variables

const unsigned long UNIX_NTP_DIFF = 2208988800U
const ntp_double NTP_SCALE = 4294967296.0
const ntp_double NTP_SCALE_I = 2.3283064365e-10
const long MILLION_L = 1000000
const ntp_double MILLION_D = 1.0e6
const ntp_double MILLION_D_I = 1.0e-6
static int as_daemon = 0
static volatile int check_config = 0


Define Documentation

#define D ( x   ) 

Definition at line 102 of file sntpdate.c.

#define D2 ( x   ) 

Definition at line 106 of file sntpdate.c.

#define D3 ( x   ) 

Definition at line 107 of file sntpdate.c.

#define MAXNUMSERVERS   10

Referenced by main().

#define MAXRETRY   5

Definition at line 100 of file sntpdate.c.

Referenced by main().

#define NTPDATE_FILE   "/etc/sntpdate.conf"

Definition at line 97 of file sntpdate.c.

Referenced by main().

#define NTPPORT   123

Definition at line 98 of file sntpdate.c.

Referenced by main().

#define NTPTIMEOUT   4

Definition at line 99 of file sntpdate.c.

Referenced by main().

#define TO_FRAC ( x   )     ((unsigned long)((((ntp_double)x) * 1.0e-6) * NTP_SCALE))

Definition at line 195 of file sntpdate.c.

Referenced by main().

#define TO_USEC ( x   )     ((unsigned long)((((ntp_double)x) * NTP_SCALE_I) * 1.0e6))

Definition at line 196 of file sntpdate.c.

#define USESYSLOG

Definition at line 200 of file sntpdate.c.

#define X313_WA_RTC_SEC   0x45

Definition at line 798 of file sntpdate.c.

Referenced by set_rtc_fpga().

#define X313_WA_RTC_USEC   0x44

Definition at line 797 of file sntpdate.c.

Referenced by set_rtc_fpga().


Typedef Documentation

typedef double ntp_double

Definition at line 116 of file sntpdate.c.


Function Documentation

static void catch_signal ( int  sig  )  [static]

Definition at line 232 of file sntpdate.c.

References check_config.

Referenced by main().

static void log ( char *  str,
  ... 
) [static]

Definition at line 211 of file sntpdate.c.

References as_daemon, buf, and stderr.

Referenced by hist__ioctl(), initCamera(), initSettings(), main(), and recorder().

int main ( int  argc,
char **  argv 
)

Definition at line 239 of file sntpdate.c.

References as_daemon, catch_signal(), check_config, D, D2, D3, fd, ntp_stamp::frac, free(), log(), MAXNUMSERVERS, MAXRETRY, memcpy(), memset(), MILLION_D, MILLION_D_I, MILLION_L, NTP_SCALE_I, NTPDATE_FILE, NTPPORT, NTPTIMEOUT, read, ntpmsg::receive_stamp, ntp_stamp::sec, set_rtc_fpga(), TO_FRAC, ntpmsg::transmit_stamp, and UNIX_NTP_DIFF.

void set_rtc_fpga ( struct timeval *   ) 

Definition at line 800 of file sntpdate.c.

References FPGACONF_READREG, FPGACONF_WRITEREG, id, X313_WA_RTC_SEC, and X313_WA_RTC_USEC.

Referenced by main().


Variable Documentation

int as_daemon = 0 [static]

Definition at line 203 of file sntpdate.c.

Referenced by log(), and main().

volatile int check_config = 0 [static]

Definition at line 229 of file sntpdate.c.

Referenced by catch_signal(), and main().

const ntp_double MILLION_D = 1.0e6

Definition at line 175 of file sntpdate.c.

Referenced by main().

const ntp_double MILLION_D_I = 1.0e-6

Definition at line 176 of file sntpdate.c.

Referenced by main().

const long MILLION_L = 1000000

Definition at line 174 of file sntpdate.c.

Referenced by main().

const ntp_double NTP_SCALE = 4294967296.0

Definition at line 171 of file sntpdate.c.

const ntp_double NTP_SCALE_I = 2.3283064365e-10

Definition at line 172 of file sntpdate.c.

Referenced by main().

const unsigned long UNIX_NTP_DIFF = 2208988800U

Definition at line 165 of file sntpdate.c.

Referenced by main().


Generated on Thu Aug 7 16:19:52 2008 for elphel by  doxygen 1.5.1