Annotation of embedaddon/ntp/ports/winnt/ntpd/refclock_trimbledc.h, revision 1.1.1.1
1.1 misho 1: /*
2: * refclock_trimbledc - clock driver for the Trimble Data Collector compatible
3: * GPS receivers (4000, 4700, 4800, 7400, ...)
4: *
5: * Greg Brackley (greg@trimble.co.nz)
6: */
7:
8: #ifndef _REFCLOCK_TRIMBLEDC_H
9: #define _REFCLOCK_TRIMBLEDC_H
10:
11: #ifdef HAVE_CONFIG_H
12: #include "config.h"
13: #endif
14:
15: #if defined HAVE_SYS_MODEM_H
16: #include <sys/modem.h>
17: #define TIOCMSET MCSETA
18: #define TIOCMGET MCGETA
19: #define TIOCM_RTS MRTS
20: #endif
21:
22: #ifdef HAVE_TERMIOS_H
23: #include <termios.h>
24: #endif
25:
26: #ifdef HAVE_SYS_IOCTL_H
27: #include <sys/ioctl.h>
28: #endif
29:
30: #include "ntpd.h"
31: #include "ntp_io.h"
32: #include "ntp_control.h"
33: #include "ntp_refclock.h"
34: #include "ntp_unixtime.h"
35: #include "ntp_stdlib.h"
36:
37: /*
38: * GPS Definitions
39: */
40: #define DESCRIPTION "Trimble Data Collector GPS" /* Long name */
41: #define PRECISION (-20) /* precision assumed (about 1 us) */
42: #define REFID "GPS\0" /* reference ID */
43: #define NSAMPLES 1
44: #define NSKEEP 1
45: #define TRIMBLEDC_MINPOLL 4
46: #define TRIMBLEDC_MAXPOLL 4
47:
48: /*
49: * I/O Definitions
50: */
51: #if !defined SYS_WINNT
52: #define DEVICE "/dev/trimbledc%d" /* device name and unit */
53: #else
54: #define DEVICE "\\\\.\\COM%d" /* device name and unit */
55: #endif
56: #define SPEED232 B9600 /* uart speed (9600 baud) */
57:
58: #define POLL_AVG 10 /* number of samples to average code delay */
59: #define DC_IO_BUFSIZE 512 /* IO buffer */
60: #define DC_MAXLEN 260 /* maximum length TSIP packet */
61:
62: /*
63: * Leap-Insert and Leap-Delete are encoded as follows:
64: * PALISADE_UTC_TIME set and PALISADE_LEAP_PENDING set: INSERT leap
65: * PALISADE_UTC_TIME clear and PALISADE_LEAP_PENDING set: DELETE leap
66: */
67:
68: #define PALISADE_LEAP_WARNING 0x04 /* GPS Leap Warning (see ICD-200) */
69: #define PALISADE_LEAP_PENDING 0x02 /* Leap Pending (24 hours) */
70: #define PALISADE_UTC_TIME 0x01 /* UTC time available */
71:
72: #define mb(_X_) (up->rpt_buf[(_X_ + 1)]) /* shortcut for buffer access */
73:
74: /* Conversion Definitions */
75: #define GPS_PI (3.1415926535898)
76: #define R2D (180.0/GPS_PI)
77:
78: typedef enum TrimbleDcParseState {
79:
80: TrimbleParseStateAck,
81: TrimbleParseStateNak,
82: TrimbleParseStateData,
83:
84: } TrimbleDcParseState;
85:
86: struct trimbledc_unit {
87: int unit; /* NTP refclock unit number */
88: int polled; /* flag to detect noreplies */
89: char leap_status; /* leap second flag */
90: TrimbleDcParseState rpt_status;
91: short rpt_cnt;
92: char rpt_buf[DC_MAXLEN];
93: char io_buf[DC_IO_BUFSIZE];
94: short io_ptr[2]; /* 0 = head, 1 = tail */
95: };
96:
97: #endif /* _REFCLOCK_TRIMBLEDC_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>