diff options
Diffstat (limited to 'contrib/ntp/ntpd/refclock_datum.c')
-rw-r--r-- | contrib/ntp/ntpd/refclock_datum.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/contrib/ntp/ntpd/refclock_datum.c b/contrib/ntp/ntpd/refclock_datum.c index 82b7369..b26fe73 100644 --- a/contrib/ntp/ntpd/refclock_datum.c +++ b/contrib/ntp/ntpd/refclock_datum.c @@ -119,6 +119,7 @@ #define REFID "DATM" /* reference id */ #define DATUM_DISPERSION 0 /* fixed dispersion = 0 ms */ #define DATUM_MAX_ERROR 0.100 /* limits on sigma squared */ +#define DATUM_DEV "/dev/datum" /* device name */ #define DATUM_MAX_ERROR2 (DATUM_MAX_ERROR*DATUM_MAX_ERROR) @@ -233,6 +234,7 @@ datum_pts_start( { struct datum_pts_unit **temp_datum_pts_unit; struct datum_pts_unit *datum_pts; + int fd; #ifdef HAVE_TERMIOS struct termios arg; #endif @@ -243,6 +245,16 @@ datum_pts_start( #endif /* + ** Open the Datum PTS device + */ + fd = open(DATUM_DEV, O_RDWR); + + if (fd < 0) { + msyslog(LOG_ERR, "Datum_PTS: open(\"%s\", O_RDWR) failed: %m", DATUM_DEV); + return 0; + } + + /* ** Create the memory for the new unit */ @@ -260,11 +272,7 @@ datum_pts_start( datum_pts->yearstart = 0; /* initialize the yearstart to 0 */ datum_pts->sigma2 = 0.0; /* initialize the sigma2 to 0 */ - /* - ** Open the Datum PTS device - */ - - datum_pts->PTS_fd = open("/dev/datum",O_RDWR); + datum_pts->PTS_fd = fd; fcntl(datum_pts->PTS_fd, F_SETFL, 0); /* clear the descriptor flags */ |