summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2014-08-27 08:17:53 -0400
committerEric S. Raymond <esr@thyrsus.com>2014-08-27 08:17:53 -0400
commit95e1dc568463108afaa55d7afaa3dda50e93b45a (patch)
treef6bfb99d1b174e0a4d9c2485dcb21e83483ae8dc
parent05806755dbd7d671201df03194ddfebca1553a62 (diff)
downloadgpsd-95e1dc568463108afaa55d7afaa3dda50e93b45a.tar.gz
Structure member name change: packet -> lexer. No logic changes.
All regression tests pass.
-rw-r--r--driver_evermore.c10
-rw-r--r--driver_garmin.c8
-rw-r--r--driver_garmin_txt.c28
-rw-r--r--driver_geostar.c18
-rw-r--r--driver_italk.c10
-rw-r--r--driver_navcom.c30
-rw-r--r--driver_nmea2000.c30
-rw-r--r--driver_oncore.c10
-rw-r--r--driver_proto.c14
-rw-r--r--driver_rtcm2.c4
-rw-r--r--driver_sirf.c12
-rw-r--r--driver_superstar2.c10
-rw-r--r--driver_tsip.c20
-rw-r--r--driver_ubx.c12
-rw-r--r--driver_zodiac.c14
-rw-r--r--drivers.c86
-rw-r--r--gpsd.c38
-rw-r--r--gpsd.h-tail24
-rw-r--r--gpsdecode.c10
-rw-r--r--gpsmon.c30
-rw-r--r--gpspacket.c4
-rw-r--r--isgps.c6
-rw-r--r--libgpsd_core.c64
-rw-r--r--monitor_garmin.c4
-rw-r--r--monitor_italk.c4
-rw-r--r--monitor_nmea.c2
-rw-r--r--monitor_oncore.c2
-rw-r--r--monitor_proto.c2
-rw-r--r--monitor_sirf.c4
-rw-r--r--monitor_superstar2.c4
-rw-r--r--monitor_tnt.c2
-rw-r--r--monitor_ubx.c2
-rw-r--r--packet.c20
-rw-r--r--pseudonmea.c2
-rw-r--r--serial.c8
-rw-r--r--test_packet.c4
-rw-r--r--timebase.c4
37 files changed, 278 insertions, 278 deletions
diff --git a/driver_evermore.c b/driver_evermore.c
index ea315643..20e75045 100644
--- a/driver_evermore.c
+++ b/driver_evermore.c
@@ -386,14 +386,14 @@ static gps_mask_t evermore_parse_input(struct gps_device_t *session)
{
gps_mask_t st;
- if (session->packet.type == EVERMORE_PACKET) {
- st = evermore_parse(session, session->packet.outbuffer,
- session->packet.outbuflen);
+ if (session->lexer.type == EVERMORE_PACKET) {
+ st = evermore_parse(session, session->lexer.outbuffer,
+ session->lexer.outbuflen);
return st;
}
#ifdef NMEA_ENABLE
- else if (session->packet.type == NMEA_PACKET) {
- st = nmea_parse((char *)session->packet.outbuffer, session);
+ else if (session->lexer.type == NMEA_PACKET) {
+ st = nmea_parse((char *)session->lexer.outbuffer, session);
return st;
}
#endif /* NMEA_ENABLE */
diff --git a/driver_garmin.c b/driver_garmin.c
index acdbc90b..c5673cdc 100644
--- a/driver_garmin.c
+++ b/driver_garmin.c
@@ -1020,8 +1020,8 @@ static void garmin_event_hook(struct gps_device_t *session, event_t event)
/*@ +charint @*/
gps_mask_t garmin_ser_parse(struct gps_device_t *session)
{
- unsigned char *buf = session->packet.outbuffer;
- size_t len = session->packet.outbuflen;
+ unsigned char *buf = session->lexer.outbuffer;
+ size_t len = session->lexer.outbuflen;
unsigned char data_buf[MAX_BUFFER_SIZE];
unsigned char c;
int i = 0;
@@ -1278,7 +1278,7 @@ static int GetPacket(struct gps_device_t *session)
memset(session->driver.garmin.Buffer, 0, sizeof(Packet_t));
memset(&delay, 0, sizeof(delay));
session->driver.garmin.BufferLen = 0;
- session->packet.outbuflen = 0;
+ session->lexer.outbuflen = 0;
gpsd_report(session->context->debug, LOG_DATA, "Garmin: GetPacket()\n");
@@ -1356,7 +1356,7 @@ static int GetPacket(struct gps_device_t *session)
gpsd_report(session->context->debug, LOG_RAW,
"Garmin: GotPacket() sz=%d \n",
session->driver.garmin.BufferLen);
- session->packet.outbuflen = session->driver.garmin.BufferLen;
+ session->lexer.outbuflen = session->driver.garmin.BufferLen;
return 0;
}
diff --git a/driver_garmin_txt.c b/driver_garmin_txt.c
index 5b59f60b..e708354a 100644
--- a/driver_garmin_txt.c
+++ b/driver_garmin_txt.c
@@ -270,22 +270,22 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session)
gpsd_report(session->context->debug, LOG_PROG,
"Garmin Simple Text packet, len %zd: %s\n",
- session->packet.outbuflen, (char*)session->packet.outbuffer);
+ session->lexer.outbuflen, (char*)session->lexer.outbuffer);
- if (session->packet.outbuflen < 54) {
+ if (session->lexer.outbuflen < 54) {
/* trailing CR and LF can be ignored; ('@' + 54x 'DATA' + '\r\n') has length 57 */
gpsd_report(session->context->debug, LOG_WARN,
"Message is too short, rejected.\n");
return ONLINE_SET;
}
- session->packet.type = GARMINTXT_PACKET;
+ session->lexer.type = GARMINTXT_PACKET;
/* only one message, set cycle start */
session->cycle_end_reliable = true;
do {
unsigned int result;
- char *buf = (char *)session->packet.outbuffer + 1;
+ char *buf = (char *)session->lexer.outbuffer + 1;
gpsd_report(session->context->debug, LOG_PROG, "Timestamp: %.12s\n", buf);
/* year */
@@ -343,13 +343,13 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session)
/* decode degrees of Latitude */
if (0 !=
gar_decode(session->context,
- (char *)session->packet.outbuffer + 13, 3, "NS", 1.0,
+ (char *)session->lexer.outbuffer + 13, 3, "NS", 1.0,
&lat))
break;
/* decode minutes of Latitude */
if (0 !=
gar_int_decode(session->context,
- (char *)session->packet.outbuffer + 16, 5, 0,
+ (char *)session->lexer.outbuffer + 16, 5, 0,
99999, &degfrag))
break;
lat += degfrag * 100.0 / 60.0 / 100000.0;
@@ -359,20 +359,20 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session)
/* decode degrees of Longitude */
if (0 !=
gar_decode(session->context,
- (char *)session->packet.outbuffer + 21, 4, "EW", 1.0,
+ (char *)session->lexer.outbuffer + 21, 4, "EW", 1.0,
&lon))
break;
/* decode minutes of Longitude */
if (0 !=
gar_int_decode(session->context,
- (char *)session->packet.outbuffer + 25, 5, 0,
+ (char *)session->lexer.outbuffer + 25, 5, 0,
99999, &degfrag))
break;
lon += degfrag * 100.0 / 60.0 / 100000.0;
session->newdata.longitude = lon;
/* fix mode, GPS status, [gGdDS_] */
- status = (char)session->packet.outbuffer[30];
+ status = (char)session->lexer.outbuffer[30];
switch (status) {
case 'G':
@@ -404,7 +404,7 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session)
double eph;
if (0 !=
gar_decode(session->context,
- (char *)session->packet.outbuffer + 31, 3, "", 1.0,
+ (char *)session->lexer.outbuffer + 31, 3, "", 1.0,
&eph))
break;
/* eph is a circular error, sqrt(epx**2 + epy**2) */
@@ -418,7 +418,7 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session)
double alt;
if (0 !=
gar_decode(session->context,
- (char *)session->packet.outbuffer + 34, 6, "+-", 1.0,
+ (char *)session->lexer.outbuffer + 34, 6, "+-", 1.0,
&alt))
break;
session->newdata.altitude = alt;
@@ -430,12 +430,12 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session)
double ewvel, nsvel, speed, track;
if (0 !=
gar_decode(session->context,
- (char *)session->packet.outbuffer + 40, 5, "EW", 10.0,
+ (char *)session->lexer.outbuffer + 40, 5, "EW", 10.0,
&ewvel))
break;
if (0 !=
gar_decode(session->context,
- (char *)session->packet.outbuffer + 45, 5, "NS", 10.0,
+ (char *)session->lexer.outbuffer + 45, 5, "NS", 10.0,
&nsvel))
break;
speed = sqrt(ewvel * ewvel + nsvel * nsvel); /* is this correct formula? Result is in mps */
@@ -453,7 +453,7 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session)
double climb;
if (0 !=
gar_decode(session->context,
- (char *)session->packet.outbuffer + 50, 5, "UD", 100.0,
+ (char *)session->lexer.outbuffer + 50, 5, "UD", 100.0,
&climb))
break;
session->newdata.climb = climb; /* climb in mps */
diff --git a/driver_geostar.c b/driver_geostar.c
index 6423dad6..4632c31d 100644
--- a/driver_geostar.c
+++ b/driver_geostar.c
@@ -108,7 +108,7 @@ static bool geostar_detect(struct gps_device_t *session)
if (select(myfd + 1, &fdset, NULL, NULL, &to) != 1)
break;
if (generic_get(session) >= 0) {
- if (session->packet.type == GEOSTAR_PACKET) {
+ if (session->lexer.type == GEOSTAR_PACKET) {
gpsd_report(session->context->debug, LOG_RAW,
"geostar_detect found\n");
ret = true;
@@ -133,32 +133,32 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session)
char buf[BUFSIZ];
char buf2[BUFSIZ];
- if (session->packet.type != GEOSTAR_PACKET) {
+ if (session->lexer.type != GEOSTAR_PACKET) {
gpsd_report(session->context->debug, LOG_INF,
"geostar_analyze packet type %d\n",
- session->packet.type);
+ session->lexer.type);
return 0;
}
/*@ +charint @*/
- if (session->packet.outbuflen < 12 || session->packet.outbuffer[0] != 'P')
+ if (session->lexer.outbuflen < 12 || session->lexer.outbuffer[0] != 'P')
return 0;
/* put data part of message in buf */
memset(buf, 0, sizeof(buf));
/* cppcheck-suppress redundantCopy */
- memcpy(buf, session->packet.outbuffer, session->packet.outbuflen);
+ memcpy(buf, session->lexer.outbuffer, session->lexer.outbuflen);
buf2[len = 0] = '\0';
- for (i = 0; i < (int)session->packet.outbuflen; i++) {
+ for (i = 0; i < (int)session->lexer.outbuflen; i++) {
(void)snprintf(buf2 + strlen(buf2),
sizeof(buf2) - strlen(buf2),
- "%02x", buf[len++] = session->packet.outbuffer[i]);
+ "%02x", buf[len++] = session->lexer.outbuffer[i]);
}
/*@ -charint @*/
- id = (unsigned int)getleu16(session->packet.outbuffer, OFFSET(0));
+ id = (unsigned int)getleu16(session->lexer.outbuffer, OFFSET(0));
gpsd_report(session->context->debug, LOG_DATA,
"GeoStar packet id 0x%02x length %d: %s\n", id, len, buf2);
@@ -485,7 +485,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session)
static gps_mask_t geostar_parse_input(struct gps_device_t *session)
{
- if (session->packet.type == GEOSTAR_PACKET) {
+ if (session->lexer.type == GEOSTAR_PACKET) {
return geostar_analyze(session);;
} else
return 0;
diff --git a/driver_italk.c b/driver_italk.c
index 94f78118..76f24a3e 100644
--- a/driver_italk.c
+++ b/driver_italk.c
@@ -384,12 +384,12 @@ static gps_mask_t italk_parse(struct gps_device_t *session,
static gps_mask_t italk_parse_input(struct gps_device_t *session)
{
- if (session->packet.type == ITALK_PACKET) {
- return italk_parse(session, session->packet.outbuffer,
- session->packet.outbuflen);;
+ if (session->lexer.type == ITALK_PACKET) {
+ return italk_parse(session, session->lexer.outbuffer,
+ session->lexer.outbuflen);;
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);
#endif /* NMEA_ENABLE */
} else
return 0;
diff --git a/driver_navcom.c b/driver_navcom.c
index 213b6d25..783f459d 100644
--- a/driver_navcom.c
+++ b/driver_navcom.c
@@ -245,7 +245,7 @@ static gps_mask_t handle_0x83(struct gps_device_t *session)
#define SF_BETA2 (65536)
/* 2^16 */
#define SF_BETA3 (65536)
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
uint16_t week = getleu16(buf, 3);
uint32_t tow = getleu32(buf, 5);
int8_t alpha0 = getsb(buf, 9);
@@ -318,7 +318,7 @@ static gps_mask_t handle_0x83(struct gps_device_t *session)
/* Acknowledgement (without error) */
static gps_mask_t handle_0x06(struct gps_device_t *session)
{
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
uint8_t cmd_id = getub(buf, 3);
uint8_t port = getub(buf, 4);
session->driver.navcom.physical_port = port; /* This tells us which serial port was used last */
@@ -336,7 +336,7 @@ static gps_mask_t handle_0x06(struct gps_device_t *session)
static gps_mask_t handle_0x15(struct gps_device_t *session)
{
size_t n;
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
size_t msg_len = (size_t) getleu16(buf, 1);
/*@ -type @*/
uint8_t port, cmd_id = getub(buf, 3);
@@ -362,7 +362,7 @@ static gps_mask_t handle_0xb1(struct gps_device_t *session)
{
gps_mask_t mask;
unsigned int n;
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
uint16_t week;
uint32_t tow;
uint32_t sats_used;
@@ -594,7 +594,7 @@ static gps_mask_t handle_0x81(struct gps_device_t *session)
/* 2^-43 */
#define SF_IDOT (.000000000000113686837721616029)
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
uint8_t prn = getub(buf, 3);
uint16_t week = getleu16(buf, 4);
uint32_t tow = getleu32(buf, 6);
@@ -714,7 +714,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session)
size_t n, i;
uint8_t prn, ele, ca_snr, p2_snr, log_channel, hw_channel, s;
uint16_t azm, dgps_age;
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
size_t msg_len = (size_t) getleu16(buf, 1);
uint16_t week = getleu16(buf, 3);
uint32_t tow = getleu32(buf, 5);
@@ -818,7 +818,7 @@ static gps_mask_t handle_0xb0(struct gps_device_t *session)
/* L1 wavelength (299792458m/s / 1575420000Hz) */
#define LAMBDA_L1 (.190293672798364880476317426464)
size_t n;
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
size_t msg_len = (size_t) getleu16(buf, 1);
uint16_t week = getleu16(buf, 3);
uint32_t tow = getleu32(buf, 5);
@@ -893,7 +893,7 @@ static gps_mask_t handle_0xb5(struct gps_device_t *session)
{
if (sizeof(double) == 8) {
gps_mask_t mask = TIME_SET;
- char *buf = (char *)session->packet.outbuffer + 3;
+ char *buf = (char *)session->lexer.outbuffer + 3;
uint16_t week = getleu16(buf, 3);
uint32_t tow = getleu32(buf, 5);
double rms = getled64(buf, 9);
@@ -954,7 +954,7 @@ static gps_mask_t handle_0xae(struct gps_device_t *session)
{
/*@-modobserver@*/
char *engconfstr, *asicstr;
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
size_t msg_len = (size_t) getleu16(buf, 1);
uint8_t engconf = getub(buf, 3);
uint8_t asic = getub(buf, 4);
@@ -1082,7 +1082,7 @@ static gps_mask_t handle_0xae(struct gps_device_t *session)
/* Clock Drift and Offset */
static gps_mask_t handle_0xef(struct gps_device_t *session)
{
- unsigned char *buf = session->packet.outbuffer + 3;
+ unsigned char *buf = session->lexer.outbuffer + 3;
//uint16_t week = getleu16(buf, 3);
//uint32_t tow = getleu32(buf, 5);
int8_t osc_temp = getsb(buf, 9);
@@ -1171,12 +1171,12 @@ gps_mask_t navcom_parse(struct gps_device_t * session, unsigned char *buf,
static gps_mask_t navcom_parse_input(struct gps_device_t *session)
{
- if (session->packet.type == NAVCOM_PACKET) {
- return navcom_parse(session, session->packet.outbuffer,
- session->packet.outbuflen);
+ if (session->lexer.type == NAVCOM_PACKET) {
+ return navcom_parse(session, session->lexer.outbuffer,
+ session->lexer.outbuflen);
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);;
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);;
#endif /* NMEA_ENABLE */
} else
return 0;
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index dc6eb474..6203c5fb 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -1381,9 +1381,9 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session)
gpsd_report(session->context->debug, LOG_DATA,
"pgn %6d:%s \n", work->pgn, work->name);
session->driver.nmea2000.workpgn = (void *) work;
- /*@i1@*/session->packet.outbuflen = frame->can_dlc & 0x0f;
- for (l2=0;l2<session->packet.outbuflen;l2++) {
- /*@i3@*/session->packet.outbuffer[l2]= frame->data[l2];
+ /*@i1@*/session->lexer.outbuflen = frame->can_dlc & 0x0f;
+ for (l2=0;l2<session->lexer.outbuflen;l2++) {
+ /*@i3@*/session->lexer.outbuffer[l2]= frame->data[l2];
}
}
/*@i2@*/else if ((frame->data[0] & 0x1f) == 0) {
@@ -1399,10 +1399,10 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session)
frame->data[1],
source_pgn);
#endif /* of #if NMEA2000_FAST_DEBUG */
- session->packet.inbuflen = 0;
+ session->lexer.inbuflen = 0;
session->driver.nmea2000.idx += 1;
for (l2=2;l2<8;l2++) {
- /*@i3@*/session->packet.inbuffer[session->packet.inbuflen++] = frame->data[l2];
+ /*@i3@*/session->lexer.inbuffer[session->lexer.inbuflen++] = frame->data[l2];
}
gpsd_report(session->context->debug, LOG_DATA,
"pgn %6d:%s \n", work->pgn, work->name);
@@ -1411,11 +1411,11 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session)
unsigned int l2;
for (l2=1;l2<8;l2++) {
- if (session->driver.nmea2000.fast_packet_len > session->packet.inbuflen) {
- /*@i3@*/session->packet.inbuffer[session->packet.inbuflen++] = frame->data[l2];
+ if (session->driver.nmea2000.fast_packet_len > session->lexer.inbuflen) {
+ /*@i3@*/session->lexer.inbuffer[session->lexer.inbuflen++] = frame->data[l2];
}
}
- if (session->packet.inbuflen == session->driver.nmea2000.fast_packet_len) {
+ if (session->lexer.inbuflen == session->driver.nmea2000.fast_packet_len) {
#if NMEA2000_FAST_DEBUG
gpsd_report(session->context->debug, LOG_ERROR,
"Fast done %2x %2x %2x %2x %6d\n",
@@ -1426,9 +1426,9 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session)
source_pgn);
#endif /* of #if NMEA2000_FAST_DEBUG */
session->driver.nmea2000.workpgn = (void *) work;
- session->packet.outbuflen = session->driver.nmea2000.fast_packet_len;
- for(l2=0;l2 < (unsigned int)session->packet.outbuflen; l2++) {
- session->packet.outbuffer[l2] = session->packet.inbuffer[l2];
+ session->lexer.outbuflen = session->driver.nmea2000.fast_packet_len;
+ for(l2=0;l2 < (unsigned int)session->lexer.outbuflen; l2++) {
+ session->lexer.outbuffer[l2] = session->lexer.inbuffer[l2];
}
session->driver.nmea2000.fast_packet_len = 0;
} else {
@@ -1475,10 +1475,10 @@ static ssize_t nmea2000_get(struct gps_device_t *session)
struct can_frame frame;
ssize_t status;
- session->packet.outbuflen = 0;
+ session->lexer.outbuflen = 0;
status = read(session->gpsdata.gps_fd, &frame, sizeof(frame));
if (status == (ssize_t)sizeof(frame)) {
- session->packet.type = NMEA2000_PACKET;
+ session->lexer.type = NMEA2000_PACKET;
find_pgn(&frame, session);
return frame.can_dlc & 0x0f;
@@ -1497,10 +1497,10 @@ static gps_mask_t nmea2000_parse_input(struct gps_device_t *session)
work = (PGN *) session->driver.nmea2000.workpgn;
if (work != NULL) {
- mask = (work->func)(&session->packet.outbuffer[0], (int)session->packet.outbuflen, work, session);
+ mask = (work->func)(&session->lexer.outbuffer[0], (int)session->lexer.outbuflen, work, session);
session->driver.nmea2000.workpgn = NULL;
}
- session->packet.outbuflen = 0;
+ session->lexer.outbuflen = 0;
return mask;
}
diff --git a/driver_oncore.c b/driver_oncore.c
index e9dbecfd..a6d33b43 100644
--- a/driver_oncore.c
+++ b/driver_oncore.c
@@ -474,12 +474,12 @@ static double oncore_time_offset(struct gps_device_t *session UNUSED)
static gps_mask_t oncore_parse_input(struct gps_device_t *session)
{
- if (session->packet.type == ONCORE_PACKET) {
- return oncore_dispatch(session, session->packet.outbuffer,
- session->packet.outbuflen);
+ if (session->lexer.type == ONCORE_PACKET) {
+ return oncore_dispatch(session, session->lexer.outbuffer,
+ session->lexer.outbuflen);
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);
#endif /* NMEA_ENABLE */
} else
return 0;
diff --git a/driver_proto.c b/driver_proto.c
index 10fb05ac..c215d376 100644
--- a/driver_proto.c
+++ b/driver_proto.c
@@ -375,7 +375,7 @@ static void _proto__event_hook(struct gps_device_t *session, event_t event)
if (event == event_identified) {
/*
* Fires when the first full packet is recognized from a
- * previously unidentified device. The session packet counter
+ * previously unidentified device. The session.lexer counter
* is zeroed. If your device has a default cycle time other
* than 1 second, set session->device->gpsdata.cycle here. If
* possible, get the software version and store it in
@@ -388,9 +388,9 @@ static void _proto__event_hook(struct gps_device_t *session, event_t event)
* Called immediately after event_identified fires, then just
* after every packet received thereafter, but you probably
* only want to take actions on the first few packets after
- * the session packet counter has been zeroed,
+ * the session.lexer counter has been zeroed,
*
- * Remember that session->packet.counter is available when you
+ * Remember that session->lexer.counter is available when you
* write this hook; you can use this fact to interleave configuration
* sends with the first few packet reads, which is useful for
* devices with small receive buffers.
@@ -422,11 +422,11 @@ static void _proto__event_hook(struct gps_device_t *session, event_t event)
*/
static gps_mask_t _proto__parse_input(struct gps_device_t *session)
{
- if (session->packet.type == _PROTO__PACKET) {
- return _proto__dispatch(session, session->packet.outbuffer, session->packet.outbuflen);
+ if (session->lexer.type == _PROTO__PACKET) {
+ return _proto__dispatch(session, session->lexer.outbuffer, session->lexer.outbuflen);
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);
#endif /* NMEA_ENABLE */
} else
return 0;
diff --git a/driver_rtcm2.c b/driver_rtcm2.c
index 3a53e8be..c190911c 100644
--- a/driver_rtcm2.c
+++ b/driver_rtcm2.c
@@ -989,7 +989,7 @@ static bool preamble_match(isgps30bits_t * w)
return (((struct rtcm2_msghw1 *)w)->preamble == PREAMBLE_PATTERN);
}
-static bool length_check(struct gps_packet_t *lexer)
+static bool length_check(struct gps_lexer_t *lexer)
{
return lexer->isgps.bufindex >= 2
&& lexer->isgps.bufindex >=
@@ -997,7 +997,7 @@ static bool length_check(struct gps_packet_t *lexer)
}
/*@+type */
-enum isgpsstat_t rtcm2_decode(struct gps_packet_t *lexer, unsigned int c)
+enum isgpsstat_t rtcm2_decode(struct gps_lexer_t *lexer, unsigned int c)
{
return isgps_decode(lexer,
preamble_match, length_check, RTCM2_WORDS_MAX, c);
diff --git a/driver_sirf.c b/driver_sirf.c
index 6d1078ea..2f1d299c 100644
--- a/driver_sirf.c
+++ b/driver_sirf.c
@@ -1366,12 +1366,12 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf,
static gps_mask_t sirfbin_parse_input(struct gps_device_t *session)
{
- if (session->packet.type == SIRF_PACKET) {
- return sirf_parse(session, session->packet.outbuffer,
- session->packet.outbuflen);
+ if (session->lexer.type == SIRF_PACKET) {
+ return sirf_parse(session, session->lexer.outbuffer,
+ session->lexer.outbuflen);
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);
#endif /* NMEA_ENABLE */
} else
return 0;
@@ -1390,7 +1390,7 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event)
return;
if (event == event_identified || event == event_reactivate) {
- if (session->packet.type == NMEA_PACKET) {
+ if (session->lexer.type == NMEA_PACKET) {
gpsd_report(session->context->debug, LOG_PROG,
"SiRF: Switching chip mode to binary.\n");
(void)nmea_send(session,
diff --git a/driver_superstar2.c b/driver_superstar2.c
index 9db21e02..51a06044 100644
--- a/driver_superstar2.c
+++ b/driver_superstar2.c
@@ -473,12 +473,12 @@ static void superstar2_event_hook(struct gps_device_t *session, event_t event)
*/
static gps_mask_t superstar2_parse_input(struct gps_device_t *session)
{
- if (session->packet.type == SUPERSTAR2_PACKET) {
- return superstar2_dispatch(session, session->packet.outbuffer,
- session->packet.length);;
+ if (session->lexer.type == SUPERSTAR2_PACKET) {
+ return superstar2_dispatch(session, session->lexer.outbuffer,
+ session->lexer.length);;
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);
#endif /* NMEA_ENABLE */
} else
return 0;
diff --git a/driver_tsip.c b/driver_tsip.c
index d8736736..c2a5f7df 100644
--- a/driver_tsip.c
+++ b/driver_tsip.c
@@ -105,7 +105,7 @@ static bool tsip_detect(struct gps_device_t *session)
if (select(myfd + 1, &fdset, NULL, NULL, &to) != 1)
break;
if (generic_get(session) >= 0) {
- if (session->packet.type == TSIP_PACKET) {
+ if (session->lexer.type == TSIP_PACKET) {
gpsd_report(session->context->debug, LOG_RAW,
"tsip_detect found\n");
ret = true;
@@ -137,32 +137,32 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session)
unsigned char buf[BUFSIZ];
char buf2[BUFSIZ];
- if (session->packet.type != TSIP_PACKET) {
+ if (session->lexer.type != TSIP_PACKET) {
gpsd_report(session->context->debug, LOG_INF, "tsip_analyze packet type %d\n",
- session->packet.type);
+ session->lexer.type);
return 0;
}
/*@ +charint @*/
- if (session->packet.outbuflen < 4 || session->packet.outbuffer[0] != 0x10)
+ if (session->lexer.outbuflen < 4 || session->lexer.outbuffer[0] != 0x10)
return 0;
/* remove DLE stuffing and put data part of message in buf */
memset(buf, 0, sizeof(buf));
buf2[len = 0] = '\0';
- for (i = 2; i < (int)session->packet.outbuflen; i++) {
- if (session->packet.outbuffer[i] == 0x10)
- if (session->packet.outbuffer[++i] == 0x03)
+ for (i = 2; i < (int)session->lexer.outbuflen; i++) {
+ if (session->lexer.outbuffer[i] == 0x10)
+ if (session->lexer.outbuffer[++i] == 0x03)
break;
(void)snprintf(buf2 + strlen(buf2),
sizeof(buf2) - strlen(buf2),
- "%02x", buf[len++] = session->packet.outbuffer[i]);
+ "%02x", buf[len++] = session->lexer.outbuffer[i]);
}
/*@ -charint @*/
- id = (unsigned)session->packet.outbuffer[1];
+ id = (unsigned)session->lexer.outbuffer[1];
gpsd_report(session->context->debug, LOG_DATA,
"TSIP packet id 0x%02x length %d: %s\n",
id, len, buf2);
@@ -1042,7 +1042,7 @@ static void tsip_event_hook(struct gps_device_t *session, event_t event)
putbyte(buf, 3, 0x08); /* Aux: dBHz */
(void)tsip_write(session, 0x35, buf, 4);
}
- if (event == event_configure && session->packet.counter == 0) {
+ if (event == event_configure && session->lexer.counter == 0) {
/*
* TSIP is ODD parity 1 stopbit, save original values and
* change it Thunderbolts and Copernicus use
diff --git a/driver_ubx.c b/driver_ubx.c
index ac8c5116..2e2f8201 100644
--- a/driver_ubx.c
+++ b/driver_ubx.c
@@ -546,12 +546,12 @@ gps_mask_t ubx_parse(struct gps_device_t * session, unsigned char *buf,
static gps_mask_t parse_input(struct gps_device_t *session)
{
- if (session->packet.type == UBX_PACKET) {
- return ubx_parse(session, session->packet.outbuffer,
- session->packet.outbuflen);
+ if (session->lexer.type == UBX_PACKET) {
+ return ubx_parse(session, session->lexer.outbuffer,
+ session->lexer.outbuflen);
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);
#endif /* NMEA_ENABLE */
} else
return 0;
@@ -932,7 +932,7 @@ static bool ubx_speed(struct gps_device_t *session,
speed,
parity,
stopbits,
- (session->packet.type == UBX_PACKET) ? MODE_BINARY : MODE_NMEA);
+ (session->lexer.type == UBX_PACKET) ? MODE_BINARY : MODE_NMEA);
return true;
}
diff --git a/driver_zodiac.c b/driver_zodiac.c
index be7d8b54..7f1a1f1b 100644
--- a/driver_zodiac.c
+++ b/driver_zodiac.c
@@ -133,8 +133,8 @@ static ssize_t zodiac_send_rtcm(struct gps_device_t *session,
return 1;
}
-#define getzword(n) get16z(session->packet.outbuffer, n)
-#define getzlong(n) get32z(session->packet.outbuffer, n)
+#define getzword(n) get16z(session->lexer.outbuffer, n)
+#define getzlong(n) get32z(session->lexer.outbuffer, n)
static gps_mask_t handle1000(struct gps_device_t *session)
/* time-position-velocity report */
@@ -329,7 +329,7 @@ static gps_mask_t handle1011(struct gps_device_t *session)
* client querying of the ID with firmware version in 2006.
* The Zodiac is supposed to send one of these messages on startup.
*/
- getstringz(session->subtype, session->packet.outbuffer, 19, 28); /* software version field */
+ getstringz(session->subtype, session->lexer.outbuffer, 19, 28); /* software version field */
gpsd_report(session->context->debug, LOG_DATA,
"1011: subtype=%s mask={DEVICEID}\n",
session->subtype);
@@ -353,13 +353,13 @@ static void handle1108(struct gps_device_t *session)
static gps_mask_t zodiac_analyze(struct gps_device_t *session)
{
unsigned int id =
- (unsigned int)((session->packet.outbuffer[3] << 8) |
- session->packet.outbuffer[2]);
+ (unsigned int)((session->lexer.outbuffer[3] << 8) |
+ session->lexer.outbuffer[2]);
gpsd_report(session->context->debug, LOG_RAW,
"Raw Zodiac packet type %d length %zd: %s\n",
- id, session->packet.outbuflen, gpsd_prettydump(session));
+ id, session->lexer.outbuflen, gpsd_prettydump(session));
- if (session->packet.outbuflen < 10)
+ if (session->lexer.outbuflen < 10)
return 0;
/*
diff --git a/drivers.c b/drivers.c
index a02dbce2..2438e855 100644
--- a/drivers.c
+++ b/drivers.c
@@ -17,21 +17,21 @@
ssize_t generic_get(struct gps_device_t *session)
{
- return packet_get(session->gpsdata.gps_fd, &session->packet);
+ return packet_get(session->gpsdata.gps_fd, &session->lexer);
}
gps_mask_t generic_parse_input(struct gps_device_t *session)
{
- if (session->packet.type == BAD_PACKET)
+ if (session->lexer.type == BAD_PACKET)
return 0;
- else if (session->packet.type == COMMENT_PACKET) {
+ else if (session->lexer.type == COMMENT_PACKET) {
gpsd_set_century(session);
return 0;
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
+ } else if (session->lexer.type == NMEA_PACKET) {
const struct gps_type_t **dp;
gps_mask_t st = 0;
- char *sentence = (char *)session->packet.outbuffer;
+ char *sentence = (char *)session->lexer.outbuffer;
if (sentence[strlen(sentence)-1] != '\n')
gpsd_report(session->context->debug, LOG_IO,
@@ -65,7 +65,7 @@ gps_mask_t generic_parse_input(struct gps_device_t *session)
} else {
gpsd_report(session->context->debug, LOG_SHOUT,
"packet type %d fell through (should never happen): %s.\n",
- session->packet.type, gpsd_prettydump(session));
+ session->lexer.type, gpsd_prettydump(session));
return 0;
}
}
@@ -143,7 +143,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event)
* a comma to the trigger, because that won't be in the response
* unless there is actual following data.
*/
- switch (session->packet.counter) {
+ switch (session->lexer.counter) {
#ifdef NMEA_ENABLE
case 0:
/* probe for Garmin serial GPS -- expect $PGRMC followed by data */
@@ -301,7 +301,7 @@ static void garmin_nmea_event_hook(struct gps_device_t *session,
if (event == event_driver_switch) {
/* forces a reconfigure as the following packets come in */
- session->packet.counter = 0;
+ session->lexer.counter = 0;
}
if (event == event_configure) {
/*
@@ -309,7 +309,7 @@ static void garmin_nmea_event_hook(struct gps_device_t *session,
* receivers like the Garmin GPS-10 don't handle having having a lot of
* probes shoved at them very well.
*/
- switch (session->packet.counter) {
+ switch (session->lexer.counter) {
case 0:
/* reset some config, AutoFix, WGS84, PPS
* Set the PPS pulse length to 40ms which leaves the Garmin 18-5hz
@@ -821,7 +821,7 @@ static void oceanserver_event_hook(struct gps_device_t *session,
{
if (session->context->readonly)
return;
- if (event == event_configure && session->packet.counter == 0) {
+ if (event == event_configure && session->lexer.counter == 0) {
/* report in NMEA format */
(void)oceanserver_send(session->context->debug,
session->gpsdata.gps_fd, "2\n");
@@ -938,16 +938,16 @@ static const struct gps_type_t driver_fury = {
static gps_mask_t rtcm104v2_analyze(struct gps_device_t *session)
{
- rtcm2_unpack(&session->gpsdata.rtcm2, (char *)session->packet.isgps.buf);
+ rtcm2_unpack(&session->gpsdata.rtcm2, (char *)session->lexer.isgps.buf);
/* extra guard prevents expensive hexdump calls */
if (session->context->debug >= LOG_RAW)
gpsd_report(session->context->debug, LOG_RAW,
"RTCM 2.x packet type 0x%02x length %d words from %zd bytes: %s\n",
session->gpsdata.rtcm2.type,
session->gpsdata.rtcm2.length + 2,
- session->packet.isgps.buflen,
+ session->lexer.isgps.buflen,
gpsd_hexdump(session->msgbuf, sizeof(session->msgbuf),
- (char *)session->packet.isgps.buf,
+ (char *)session->lexer.isgps.buf,
(session->gpsdata.rtcm2.length +
2) * sizeof(isgps30bits_t)));
session->cycle_end_reliable = true;
@@ -991,12 +991,12 @@ static const struct gps_type_t driver_rtcm104v2 = {
static gps_mask_t rtcm104v3_analyze(struct gps_device_t *session)
{
- uint16_t type = getbeu16(session->packet.inbuffer, 3) >> 4;
+ uint16_t type = getbeu16(session->lexer.inbuffer, 3) >> 4;
gpsd_report(session->context->debug, LOG_RAW, "RTCM 3.x packet %d\n", type);
rtcm3_unpack(session->context,
&session->gpsdata.rtcm3,
- (char *)session->packet.outbuffer);
+ (char *)session->lexer.outbuffer);
session->cycle_end_reliable = true;
return RTCM3_SET;
}
@@ -1359,17 +1359,17 @@ static bool aivdm_decode(const char *buf, size_t buflen,
static gps_mask_t aivdm_analyze(struct gps_device_t *session)
{
- if (session->packet.type == AIVDM_PACKET) {
+ if (session->lexer.type == AIVDM_PACKET) {
if (aivdm_decode
- ((char *)session->packet.outbuffer, session->packet.outbuflen,
+ ((char *)session->lexer.outbuffer, session->lexer.outbuflen,
session, &session->gpsdata.ais,
session->context->debug)) {
return ONLINE_SET | AIS_SET;
} else
return ONLINE_SET;
#ifdef NMEA_ENABLE
- } else if (session->packet.type == NMEA_PACKET) {
- return nmea_parse((char *)session->packet.outbuffer, session);
+ } else if (session->lexer.type == NMEA_PACKET) {
+ return nmea_parse((char *)session->lexer.outbuffer, session);
#endif /* NMEA_ENABLE */
} else
return 0;
@@ -1422,60 +1422,60 @@ static void path_rewrite(struct gps_device_t *session, char *prefix)
* from the device.
*/
char *prefloc;
- for (prefloc = (char *)session->packet.outbuffer;
- prefloc < (char *)session->packet.outbuffer+session->packet.outbuflen;
+ for (prefloc = (char *)session->lexer.outbuffer;
+ prefloc < (char *)session->lexer.outbuffer+session->lexer.outbuflen;
prefloc++)
if (strncmp(prefloc, prefix, strlen(prefix)) == 0) {
- char copy[sizeof(session->packet.outbuffer)+1];
+ char copy[sizeof(session->lexer.outbuffer)+1];
(void)strlcpy(copy,
- (char *)session->packet.outbuffer,
+ (char *)session->lexer.outbuffer,
sizeof(copy));
prefloc += strlen(prefix);
(void)strlcpy(prefloc,
session->gpsdata.dev.path,
sizeof(session->gpsdata.dev.path));
- (void)strlcat((char *)session->packet.outbuffer, "#",
- sizeof(session->packet.outbuffer));
- (void)strlcat((char *)session->packet.outbuffer,
- copy + (prefloc-(char *)session->packet.outbuffer),
- sizeof(session->packet.outbuffer));
+ (void)strlcat((char *)session->lexer.outbuffer, "#",
+ sizeof(session->lexer.outbuffer));
+ (void)strlcat((char *)session->lexer.outbuffer,
+ copy + (prefloc-(char *)session->lexer.outbuffer),
+ sizeof(session->lexer.outbuffer));
}
- session->packet.outbuflen = strlen((char *)session->packet.outbuffer);
+ session->lexer.outbuflen = strlen((char *)session->lexer.outbuffer);
}
static gps_mask_t json_pass_packet(struct gps_device_t *session)
{
gpsd_report(session->context->debug, LOG_IO,
- "<= GPS: %s\n", (char *)session->packet.outbuffer);
+ "<= GPS: %s\n", (char *)session->lexer.outbuffer);
if (strncmp(session->gpsdata.dev.path, "gpsd://localhost:", 17) != 0)
{
/*@-nullpass@*/ /* required only because splint is buggy */
/* devices and paths need to be edited */
- if (strstr((char *)session->packet.outbuffer, "DEVICE") != NULL)
+ if (strstr((char *)session->lexer.outbuffer, "DEVICE") != NULL)
path_rewrite(session, "\"path\":\"");
path_rewrite(session, "\"device\":\"");
/* mark certain responses without a path or device attribute */
if (session->gpsdata.dev.path[0] != '\0') {
- if (strstr((char *)session->packet.outbuffer, "VERSION") != NULL
- || strstr((char *)session->packet.outbuffer, "WATCH") != NULL
- || strstr((char *)session->packet.outbuffer, "DEVICES") != NULL) {
- session->packet.outbuffer[session->packet.outbuflen-1] = '\0';
- (void)strlcat((char *)session->packet.outbuffer, ",\"remote\":\"",
- sizeof(session->packet.outbuffer));
- (void)strlcat((char *)session->packet.outbuffer,
+ if (strstr((char *)session->lexer.outbuffer, "VERSION") != NULL
+ || strstr((char *)session->lexer.outbuffer, "WATCH") != NULL
+ || strstr((char *)session->lexer.outbuffer, "DEVICES") != NULL) {
+ session->lexer.outbuffer[session->lexer.outbuflen-1] = '\0';
+ (void)strlcat((char *)session->lexer.outbuffer, ",\"remote\":\"",
+ sizeof(session->lexer.outbuffer));
+ (void)strlcat((char *)session->lexer.outbuffer,
session->gpsdata.dev.path,
- sizeof(session->packet.outbuffer));
- (void)strlcat((char *)session->packet.outbuffer, "\"}",
- sizeof(session->packet.outbuffer));
+ sizeof(session->lexer.outbuffer));
+ (void)strlcat((char *)session->lexer.outbuffer, "\"}",
+ sizeof(session->lexer.outbuffer));
}
- session->packet.outbuflen = strlen((char *)session->packet.outbuffer);
+ session->lexer.outbuflen = strlen((char *)session->lexer.outbuffer);
}
}
gpsd_report(session->context->debug, LOG_PROG,
"JSON, passing through %s\n",
- (char *)session->packet.outbuffer);
+ (char *)session->lexer.outbuffer);
/*@-nullpass@*/
return PASSTHROUGH_IS;
}
diff --git a/gpsd.c b/gpsd.c
index bf14ecca..7dea33e7 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1395,11 +1395,11 @@ static void raw_report(struct subscriber_t *sub, struct gps_device_t *device)
* copied to all clients that are in raw or nmea
* mode.
*/
- if (TEXTUAL_PACKET_TYPE(device->packet.type)
+ if (TEXTUAL_PACKET_TYPE(device->lexer.type)
&& (sub->policy.raw > 0 || sub->policy.nmea)) {
(void)throttled_write(sub,
- (char *)device->packet.outbuffer,
- device->packet.outbuflen);
+ (char *)device->lexer.outbuffer,
+ device->lexer.outbuflen);
return;
}
@@ -1409,8 +1409,8 @@ static void raw_report(struct subscriber_t *sub, struct gps_device_t *device)
*/
if (sub->policy.raw > 1) {
(void)throttled_write(sub,
- (char *)device->packet.outbuffer,
- device->packet.outbuflen);
+ (char *)device->lexer.outbuffer,
+ device->lexer.outbuflen);
return;
}
#ifdef BINARY_ENABLE
@@ -1420,8 +1420,8 @@ static void raw_report(struct subscriber_t *sub, struct gps_device_t *device)
if (sub->policy.raw == 1) {
const char *hd =
gpsd_hexdump(device->msgbuf, sizeof(device->msgbuf),
- (char *)device->packet.outbuffer,
- device->packet.outbuflen);
+ (char *)device->lexer.outbuffer,
+ device->lexer.outbuflen);
(void)strlcat((char *)hd, "\r\n", sizeof(device->msgbuf));
(void)throttled_write(sub, (char *)hd, strlen(hd));
}
@@ -1433,8 +1433,8 @@ static void pseudonmea_report(struct subscriber_t *sub,
struct gps_device_t *device)
/* report pseudo-NMEA in appropriate circumstances */
{
- if (GPS_PACKET_TYPE(device->packet.type)
- && !TEXTUAL_PACKET_TYPE(device->packet.type)) {
+ if (GPS_PACKET_TYPE(device->lexer.type)
+ && !TEXTUAL_PACKET_TYPE(device->lexer.type)) {
char buf[MAX_PACKET_LENGTH * 3 + 2];
if ((changed & REPORT_IS) != 0) {
@@ -1508,10 +1508,10 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed)
* If the device provided an RTCM packet, repeat it to all devices.
*/
if ((changed & RTCM2_SET) != 0 || (changed & RTCM3_SET) != 0) {
- if (device->packet.outbuflen > RTCM_MAX) {
+ if (device->lexer.outbuflen > RTCM_MAX) {
gpsd_report(context.debug, LOG_ERROR,
"overlong RTCM packet (%zd bytes)\n",
- device->packet.outbuflen);
+ device->lexer.outbuflen);
} else {
struct gps_device_t *dp;
for (dp = devices; dp < devices+MAXDEVICES; dp++) {
@@ -1519,14 +1519,14 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed)
/* *INDENT-OFF* */
if (dp->device_type->rtcm_writer != NULL) {
if (dp->device_type->rtcm_writer(dp,
- (const char *)device->packet.outbuffer,
- device->packet.outbuflen) == 0)
+ (const char *)device->lexer.outbuffer,
+ device->lexer.outbuflen) == 0)
gpsd_report(context.debug, LOG_ERROR,
"Write to RTCM sink failed\n");
else {
gpsd_report(context.debug, LOG_IO,
"<= DGPS: %zd bytes of RTCM relayed.\n",
- device->packet.outbuflen);
+ device->lexer.outbuflen);
}
}
/* *INDENT-ON* */
@@ -1611,12 +1611,12 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed)
#ifdef PASSTHROUGH_ENABLE
/* this is for passing through JSON packets */
if ((changed & PASSTHROUGH_IS) != 0) {
- (void)strlcat((char *)device->packet.outbuffer,
+ (void)strlcat((char *)device->lexer.outbuffer,
"\r\n",
- sizeof(device->packet.outbuffer));
+ sizeof(device->lexer.outbuffer));
(void)throttled_write(sub,
- (char *)device->packet.outbuffer,
- device->packet.outbuflen+2);
+ (char *)device->lexer.outbuffer,
+ device->lexer.outbuflen+2);
continue;
}
#endif /* PASSTHROUGH_ENABLE */
@@ -2393,7 +2393,7 @@ int main(int argc, char *argv[])
}
if (!device_needed && device->gpsdata.gps_fd > -1 &&
- device->packet.type != BAD_PACKET) {
+ device->lexer.type != BAD_PACKET) {
if (device->releasetime == 0) {
device->releasetime = timestamp();
gpsd_report(context.debug, LOG_PROG,
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 80bedcb6..d758d7a7 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -136,7 +136,7 @@ enum isgpsstat_t {
#define SECS_PER_WEEK (7*SECS_PER_DAY) /* seconds per week */
#define GPS_ROLLOVER (1024*SECS_PER_WEEK) /* rollover period */
-struct gps_packet_t {
+struct gps_lexer_t {
/* packet-getter internals */
int type;
#define BAD_PACKET -1
@@ -207,12 +207,12 @@ struct gps_packet_t {
#endif /* PASSTHROUGH_ENABLE */
};
-extern void packet_init(/*@out@*/struct gps_packet_t *);
-extern void packet_reset(/*@out@*/struct gps_packet_t *);
-extern void packet_pushback(struct gps_packet_t *);
-extern void packet_parse(struct gps_packet_t *);
-extern ssize_t packet_get(int, struct gps_packet_t *);
-extern int packet_sniff(struct gps_packet_t *);
+extern void packet_init(/*@out@*/struct gps_lexer_t *);
+extern void packet_reset(/*@out@*/struct gps_lexer_t *);
+extern void packet_pushback(struct gps_lexer_t *);
+extern void packet_parse(struct gps_lexer_t *);
+extern ssize_t packet_get(int, struct gps_lexer_t *);
+extern int packet_sniff(struct gps_lexer_t *);
#define packet_buffered_input(lexer) ((lexer)->inbuffer + (lexer)->inbuflen - (lexer)->inbufptr)
/* Next, declarations for the core library... */
@@ -460,7 +460,7 @@ struct gps_device_t {
unsigned int baudindex;
#endif /* FIXED_PORT_SPEED */
int saved_baud;
- struct gps_packet_t packet;
+ struct gps_lexer_t lexer;
int badcount;
int subframe_count;
char subtype[64]; /* firmware version or subtype ID */
@@ -737,16 +737,16 @@ struct gps_device_t {
#define IS_HIGHEST_BIT(v,m) (v & ~((m<<1)-1))==0
/* driver helper functions */
-extern void isgps_init(/*@out@*/struct gps_packet_t *);
-enum isgpsstat_t isgps_decode(struct gps_packet_t *,
+extern void isgps_init(/*@out@*/struct gps_lexer_t *);
+enum isgpsstat_t isgps_decode(struct gps_lexer_t *,
bool (*preamble_match)(isgps30bits_t *),
- bool (*length_check)(struct gps_packet_t *),
+ bool (*length_check)(struct gps_lexer_t *),
size_t,
unsigned int);
extern unsigned int isgps_parity(isgps30bits_t);
extern void isgps_output_magnavox(const isgps30bits_t *, unsigned int, FILE *);
-extern enum isgpsstat_t rtcm2_decode(struct gps_packet_t *, unsigned int);
+extern enum isgpsstat_t rtcm2_decode(struct gps_lexer_t *, unsigned int);
extern void json_rtcm2_dump(const struct rtcm2_t *,
/*@null@*/const char *, /*@out@*/char[], size_t);
extern void rtcm2_unpack(/*@out@*/struct rtcm2_t *, char *);
diff --git a/gpsdecode.c b/gpsdecode.c
index 67ac16da..62ebaa77 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -551,10 +551,10 @@ static void decode(FILE *fpin, FILE*fpout)
if (changed == ERROR_SET || changed == NODATA_IS)
break;
- if (session.packet.type == COMMENT_PACKET)
+ if (session.lexer.type == COMMENT_PACKET)
gpsd_set_century(&session);
- if (verbose >= 1 && TEXTUAL_PACKET_TYPE(session.packet.type))
- (void)fputs((char *)session.packet.outbuffer, fpout);
+ if (verbose >= 1 && TEXTUAL_PACKET_TYPE(session.lexer.type))
+ (void)fputs((char *)session.lexer.outbuffer, fpout);
/* mask should match what's in report_data() */
if ((changed & (REPORT_IS|GST_SET|SATELLITE_SET|SUBFRAME_SET|ATTITUDE_SET|RTCM2_SET|RTCM3_SET|AIS_SET|PASSTHROUGH_IS)) == 0)
continue;
@@ -562,7 +562,7 @@ static void decode(FILE *fpin, FILE*fpout)
continue;
else if (json) {
if ((changed & PASSTHROUGH_IS) != 0) {
- (void)fputs((char *)session.packet.outbuffer, fpout);
+ (void)fputs((char *)session.lexer.outbuffer, fpout);
(void)fputs("\n", fpout);
}
#ifdef SOCKET_EXPORT_ENABLE
@@ -578,7 +578,7 @@ static void decode(FILE *fpin, FILE*fpout)
}
#endif /* SOCKET_EXPORT_ENABLE */
#ifdef AIVDM_ENABLE
- } else if (session.packet.type == AIVDM_PACKET) {
+ } else if (session.lexer.type == AIVDM_PACKET) {
if ((changed & AIS_SET)!=0) {
if (session.gpsdata.ais.type == 24 && session.gpsdata.ais.type24.part != both && !split24)
continue;
diff --git a/gpsmon.c b/gpsmon.c
index cfcaa8e2..fe928d82 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -485,10 +485,10 @@ static void select_packet_monitor(struct gps_device_t *device)
* change the selection of the current device driver; that's done
* within gpsd_multipoll() before this hook is called.
*/
- if (device->packet.type != last_type) {
+ if (device->lexer.type != last_type) {
const struct gps_type_t *active_type = device->device_type;
#ifdef NMEA_ENABLE
- if (device->packet.type == NMEA_PACKET
+ if (device->lexer.type == NMEA_PACKET
&& ((device->device_type->flags & DRIVER_STICKY) != 0))
active_type = &driver_nmea0183;
#endif /* NMEA_ENABLE */
@@ -498,11 +498,11 @@ static void select_packet_monitor(struct gps_device_t *device)
refresh_statwin();
refresh_cmdwin();
}
- last_type = device->packet.type;
+ last_type = device->lexer.type;
}
if (active != NULL
- && device->packet.outbuflen > 0
+ && device->lexer.outbuflen > 0
&& (*active)->update != NULL)
(*active)->update();
if (devicewin != NULL)
@@ -701,11 +701,11 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
struct timedrift_t td;
#ifdef PPS_ENABLE
- if (!serial && strncmp((char*)device->packet.outbuffer, "{\"class\":\"PPS\",", 13) == 0)
+ if (!serial && strncmp((char*)device->lexer.outbuffer, "{\"class\":\"PPS\",", 13) == 0)
{
const char *end = NULL;
struct gps_data_t noclobber;
- int status = json_pps_read((const char *)device->packet.outbuffer,
+ int status = json_pps_read((const char *)device->lexer.outbuffer,
&noclobber,
&end);
if (status != 0) {
@@ -738,10 +738,10 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
#ifdef __future__
if (!serial)
{
- if (device->packet.type == JSON_PACKET)
+ if (device->lexer.type == JSON_PACKET)
{
const char *end = NULL;
- libgps_json_unpack((char *)device->packet.outbuffer, &session.gpsdata, &end);
+ libgps_json_unpack((char *)device->lexer.outbuffer, &session.gpsdata, &end);
}
}
#endif /* __future__ */
@@ -750,9 +750,9 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
select_packet_monitor(device);
(void)snprintf(buf, sizeof(buf), "(%d) ",
- (int)device->packet.outbuflen);
+ (int)device->lexer.outbuflen);
cond_hexdump(buf + strlen(buf), sizeof(buf) - strlen(buf),
- (char *)device->packet.outbuffer,device->packet.outbuflen);
+ (char *)device->lexer.outbuffer,device->lexer.outbuflen);
(void)strlcat(buf, "\n", sizeof(buf) - strlen(buf));
}
@@ -768,11 +768,11 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
(void)doupdate();
}
- if (logfile != NULL && device->packet.outbuflen > 0) {
+ if (logfile != NULL && device->lexer.outbuflen > 0) {
/*@ -shiftimplementation -sefparams +charint @*/
assert(fwrite
- (device->packet.outbuffer, sizeof(char),
- device->packet.outbuflen, logfile) >= 1);
+ (device->lexer.outbuffer, sizeof(char),
+ device->lexer.outbuflen, logfile) >= 1);
/*@ +shiftimplementation +sefparams -charint @*/
}
@@ -843,7 +843,7 @@ static bool do_command(const char *line)
#endif /* RECONFIGURE_ENABLE */
if (!context.readonly)
/* magic - forces a reconfigure */
- session.packet.counter = 0;
+ session.lexer.counter = 0;
}
break;
@@ -869,7 +869,7 @@ static bool do_command(const char *line)
if (strcspn(line, "01") == strlen(line)) {
/* *INDENT-OFF* */
v = (unsigned int)TEXTUAL_PACKET_TYPE(
- session.packet.type);
+ session.lexer.type);
/* *INDENT-ON* */
} else
v = (unsigned)atoi(line + 1);
diff --git a/gpspacket.c b/gpspacket.c
index cb851404..5d1fbe1f 100644
--- a/gpspacket.c
+++ b/gpspacket.c
@@ -44,7 +44,7 @@ static PyTypeObject Lexer_Type;
typedef struct {
PyObject_HEAD
- struct gps_packet_t lexer;
+ struct gps_lexer_t lexer;
} LexerObject;
static LexerObject *
@@ -54,7 +54,7 @@ newLexerObject(PyObject *arg UNUSED)
self = PyObject_New(LexerObject, &Lexer_Type);
if (self == NULL)
return NULL;
- memset(&self->lexer, 0, sizeof(struct gps_packet_t));
+ memset(&self->lexer, 0, sizeof(struct gps_lexer_t));
packet_reset(&self->lexer);
return self;
}
diff --git a/isgps.c b/isgps.c
index 59d48699..6f346de3 100644
--- a/isgps.c
+++ b/isgps.c
@@ -167,7 +167,7 @@ unsigned int isgps_parity(isgps30bits_t th)
*/
#define isgps_parityok(w) (isgps_parity(w) == ((w) & 0x3f))
-void isgps_init( /*@out@*/ struct gps_packet_t *session)
+void isgps_init( /*@out@*/ struct gps_lexer_t *session)
{
session->isgps.curr_word = 0;
session->isgps.curr_offset = 24; /* first word */
@@ -179,9 +179,9 @@ void isgps_init( /*@out@*/ struct gps_packet_t *session)
/*@ -usereleased -compdef @*/
// This works around cppcheck not looking into enough config branches
// cppcheck-suppress unusedFunction
-enum isgpsstat_t isgps_decode(struct gps_packet_t *session,
+enum isgpsstat_t isgps_decode(struct gps_lexer_t *session,
bool(*preamble_match) (isgps30bits_t *),
- bool(*length_check) (struct gps_packet_t *),
+ bool(*length_check) (struct gps_lexer_t *),
size_t maxlen, unsigned int c)
{
/* ASCII characters 64-127, @ through DEL */
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 5af50977..dace5a3f 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -79,8 +79,8 @@ const char *gpsd_prettydump(struct gps_device_t *session)
/* dump the current packet in a form optimised for eyeballs */
{
return gpsd_packetdump(session->msgbuf, sizeof(session->msgbuf),
- (char *)session->packet.outbuffer,
- session->packet.outbuflen);
+ (char *)session->lexer.outbuffer,
+ session->lexer.outbuflen);
}
@@ -306,7 +306,7 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context,
gpsd_zero_satellites(&session->gpsdata);
/* initialize things for the packet parser */
- packet_reset(&session->packet);
+ packet_reset(&session->lexer);
}
void gpsd_deactivate(struct gps_device_t *session)
@@ -351,8 +351,8 @@ void gpsd_clear(struct gps_device_t *session)
#ifdef SIRF_ENABLE
session->driver.sirf.satcounter = 0;
#endif /* SIRF_ENABLE */
- packet_init(&session->packet);
- session->packet.debug = session->context->debug;
+ packet_init(&session->lexer);
+ session->lexer.debug = session->context->debug;
// session->gpsdata.online = 0;
gps_clear_fix(&session->gpsdata.fix);
session->gpsdata.status = STATUS_NO_FIX;
@@ -1096,7 +1096,7 @@ static bool hunt_failure(struct gps_device_t *session)
* than RS232 ones. There's a test for this at
* test/daemon/tcp-torture.log.
*
- * The second was session->badcount++>1 && session->packet.state==0.
+ * The second was session->badcount++>1 && session->lexer.state==0.
* Fail hunt only if we get a second consecutive bad packet
* and the lexer is in ground state. We don't want to fail on
* a first bad packet because the source might have a burst of
@@ -1105,7 +1105,7 @@ static bool hunt_failure(struct gps_device_t *session)
* might have picked up a valid partial packet - better to go
* back around the loop and pick up more data.
*
- * The "&& session->packet.state==0" guard causes an intermittent
+ * The "&& session->lexer.state==0" guard causes an intermittent
* hang while autobauding on SiRF IIIs (but not on SiRF-IIs, oddly
* enough). Removing this conjunct resurrected the failure
* of test/daemon/tcp-torture.log.
@@ -1166,18 +1166,18 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
* with the data they transmit.
*/
#define MINIMUM_QUIET_TIME 0.25
- if (session->packet.outbuflen == 0)
+ if (session->lexer.outbuflen == 0)
{
/* beginning of a new packet */
timestamp_t now = timestamp();
- if (session->device_type != NULL && session->packet.start_time > 0) {
+ if (session->device_type != NULL && session->lexer.start_time > 0) {
#ifdef RECONFIGURE_ENABLE
const double min_cycle = session->device_type->min_cycle;
#else
const double min_cycle = 1;
#endif /* RECONFIGURE_ENABLE */
double quiet_time = (MINIMUM_QUIET_TIME * min_cycle);
- double gap = now - session->packet.start_time;
+ double gap = now - session->lexer.start_time;
if (gap > min_cycle)
gpsd_report(session->context->debug, LOG_WARN,
@@ -1186,16 +1186,16 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
gpsd_report(session->context->debug, LOG_PROG,
"transmission pause of %f\n", gap);
session->sor = now;
- session->packet.start_char = session->packet.char_counter;
+ session->lexer.start_char = session->lexer.char_counter;
}
}
- session->packet.start_time = now;
+ session->lexer.start_time = now;
}
#endif /* TIMING_ENABLE */
- if (session->packet.type >= COMMENT_PACKET) {
+ if (session->lexer.type >= COMMENT_PACKET) {
/*@-shiftnegative@*/
- session->observed |= PACKET_TYPEMASK(session->packet.type);
+ session->observed |= PACKET_TYPEMASK(session->lexer.type);
/*@+shiftnegative@*/
}
@@ -1238,9 +1238,9 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
} else /* (newlen > 0) */ {
gpsd_report(session->context->debug, LOG_RAW,
"packet sniff on %s finds type %d\n",
- session->gpsdata.dev.path, session->packet.type);
- if (session->packet.type == COMMENT_PACKET) {
- if (strcmp((const char *)session->packet.outbuffer, "# EOF\n") == 0) {
+ session->gpsdata.dev.path, session->lexer.type);
+ if (session->lexer.type == COMMENT_PACKET) {
+ if (strcmp((const char *)session->lexer.outbuffer, "# EOF\n") == 0) {
gpsd_report(session->context->debug, LOG_PROG,
"synthetic EOF\n");
return EOF_SET;
@@ -1249,11 +1249,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
gpsd_report(session->context->debug, LOG_PROG,
"comment, sync lock deferred\n");
/* FALL THROUGH */
- } else if (session->packet.type > COMMENT_PACKET) {
+ } else if (session->lexer.type > COMMENT_PACKET) {
if (session->device_type == NULL)
driver_change = true;
else {
- int newtype = session->packet.type;
+ int newtype = session->lexer.type;
/*
* Are we seeing a new packet type? Then we probably
* want to change drivers.
@@ -1286,17 +1286,17 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
const struct gps_type_t **dp;
for (dp = gpsd_drivers; *dp; dp++)
- if (session->packet.type == (*dp)->packet_type) {
+ if (session->lexer.type == (*dp)->packet_type) {
gpsd_report(session->context->debug, LOG_PROG,
"switching to match packet type %d: %s\n",
- session->packet.type, gpsd_prettydump(session));
+ session->lexer.type, gpsd_prettydump(session));
(void)gpsd_switch_driver(session, (*dp)->type_name);
break;
}
}
/*@+nullderef@*/
session->badcount = 0;
- session->gpsdata.dev.driver_mode = (session->packet.type > NMEA_PACKET) ? MODE_BINARY : MODE_NMEA;
+ session->gpsdata.dev.driver_mode = (session->lexer.type > NMEA_PACKET) ? MODE_BINARY : MODE_NMEA;
/* FALL THROUGH */
} else if (hunt_failure(session) && !gpsd_next_hunt_setting(session)) {
gpsd_report(session->context->debug, LOG_INF,
@@ -1307,7 +1307,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
}
}
- if (session->packet.outbuflen == 0) { /* got new data, but no packet */
+ if (session->lexer.outbuflen == 0) { /* got new data, but no packet */
gpsd_report(session->context->debug, LOG_RAW + 3,
"New data on %s, not yet a packet\n",
session->gpsdata.dev.path);
@@ -1352,7 +1352,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
if (session->device_type != NULL
&& session->device_type->event_hook != NULL)
session->device_type->event_hook(session, event_identified);
- session->packet.counter = 0;
+ session->lexer.counter = 0;
/* let clients know about this. */
received |= DRIVER_IS;
@@ -1360,7 +1360,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
/* mark the fact that this driver has been seen */
session->drivers_identified |= (1 << session->driver_index);
} else
- session->packet.counter++;
+ session->lexer.counter++;
/* fire the configure hook */
if (session->device_type != NULL
@@ -1375,12 +1375,12 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
if (session->context->debug >= LOG_RAW)
gpsd_report(session->context->debug, LOG_RAW,
"raw packet of type %d, %zd:%s\n",
- session->packet.type,
- session->packet.outbuflen,
+ session->lexer.type,
+ session->lexer.outbuflen,
gpsd_prettydump(session));
/* Get data from current packet into the fix structure */
- if (session->packet.type != COMMENT_PACKET)
+ if (session->lexer.type != COMMENT_PACKET)
if (session->device_type != NULL
&& session->device_type->parse_packet != NULL)
received |= session->device_type->parse_packet(session);
@@ -1408,7 +1408,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
#ifdef TIMING_ENABLE
/* are we going to generate a report? if so, count characters */
if ((received & REPORT_IS) != 0) {
- session->chars = session->packet.char_counter - session->packet.start_char;
+ session->chars = session->lexer.char_counter - session->lexer.start_char;
}
#endif /* TIMING_ENABLE */
@@ -1590,21 +1590,21 @@ int gpsd_multipoll(const bool data_ready,
/* conditional prevents mask dumper from eating CPU */
if (device->context->debug >= LOG_DATA) {
- if (device->packet.type == BAD_PACKET)
+ if (device->lexer.type == BAD_PACKET)
gpsd_report(device->context->debug, LOG_DATA,
"packet with bad checksum from %s\n",
device->gpsdata.dev.path);
else
gpsd_report(device->context->debug, LOG_DATA,
"packet type %d from %s with %s\n",
- device->packet.type,
+ device->lexer.type,
device->gpsdata.dev.path,
gps_maskdump(device->gpsdata.set));
}
/* handle data contained in this packet */
- if (device->packet.type != BAD_PACKET)
+ if (device->lexer.type != BAD_PACKET)
/*@i1@*/handler(device, changed);
#ifdef __future__
diff --git a/monitor_garmin.c b/monitor_garmin.c
index edc52b51..bfcc8102 100644
--- a/monitor_garmin.c
+++ b/monitor_garmin.c
@@ -223,8 +223,8 @@ static void garmin_bin_ser_update(void)
unsigned char chksum;
bool pkt_good = false, got_dle = false;
- buf = session.packet.outbuffer;
- len = session.packet.outbuflen;
+ buf = session.lexer.outbuffer;
+ len = session.lexer.outbuflen;
if (!(buf[0] == (unsigned char)0x10 && /* DLE */
buf[len-2] == (unsigned char)0x10 && /* DLE */
diff --git a/monitor_italk.c b/monitor_italk.c
index 3157d5ee..1f62b54b 100644
--- a/monitor_italk.c
+++ b/monitor_italk.c
@@ -216,8 +216,8 @@ static void italk_update(void)
size_t len;
unsigned char type;
- buf = session.packet.outbuffer;
- len = session.packet.outbuflen;
+ buf = session.lexer.outbuffer;
+ len = session.lexer.outbuflen;
type = (unsigned char)getub(buf, 4);
switch (type) {
case ITALK_NAV_FIX:
diff --git a/monitor_nmea.c b/monitor_nmea.c
index 1d59944f..47887c00 100644
--- a/monitor_nmea.c
+++ b/monitor_nmea.c
@@ -191,7 +191,7 @@ static void nmea_update(void)
/* can be NULL if packet was overlong */
fields = session.nmea.field;
- if (session.packet.outbuffer[0] == (unsigned char)'$'
+ if (session.lexer.outbuffer[0] == (unsigned char)'$'
&& fields != NULL && fields[0] != NULL) {
int ymax, xmax;
timestamp_t now;
diff --git a/monitor_oncore.c b/monitor_oncore.c
index 3d97e41c..ac192db7 100644
--- a/monitor_oncore.c
+++ b/monitor_oncore.c
@@ -183,7 +183,7 @@ static void oncore_update(void)
unsigned int type;
assert(Eawin != NULL);
- buf = session.packet.outbuffer;
+ buf = session.lexer.outbuffer;
type = ONCTYPE(buf[2], buf[3]);
switch (type) {
case ONCTYPE('E', 'a'):
diff --git a/monitor_proto.c b/monitor_proto.c
index 149fba4f..b3e98bc1 100644
--- a/monitor_proto.c
+++ b/monitor_proto.c
@@ -62,7 +62,7 @@ static void PROTO_update(void)
{
/*
* Called on each packet received. The packet will be accessible in
- * session.packet.outbuffer and the length in session.packet.outbuflen.
+ * session.lexer.outbuffer and the length in session.lexer.outbuflen.
* If the device is NMEA, session.driver.nmea.fields[] will contain the
* array of unconverted field strings, including the tag in slot zero
* but not including the checksum or trailing \r\n.
diff --git a/monitor_sirf.c b/monitor_sirf.c
index 67ef297e..3026e67c 100644
--- a/monitor_sirf.c
+++ b/monitor_sirf.c
@@ -287,8 +287,8 @@ static void sirf_update(void)
/* splint pacification */
assert(mid2win!=NULL && mid27win != NULL);
- buf = session.packet.outbuffer + 4;
- len = session.packet.outbuflen - 8;
+ buf = session.lexer.outbuffer + 4;
+ len = session.lexer.outbuflen - 8;
switch (buf[0]) {
case 0x02: /* Measured Navigation Data */
(void)wmove(mid2win, 1, 6); /* ECEF position */
diff --git a/monitor_superstar2.c b/monitor_superstar2.c
index d5c55c52..f4aa08d7 100644
--- a/monitor_superstar2.c
+++ b/monitor_superstar2.c
@@ -72,8 +72,8 @@ static void superstar2_update(void)
size_t len;
unsigned char type;
- buf = session.packet.outbuffer;
- len = session.packet.outbuflen;
+ buf = session.lexer.outbuffer;
+ len = session.lexer.outbuflen;
type = buf[SUPERSTAR2_TYPE_OFFSET];
switch (type) {
case SUPERSTAR2_SVINFO:
diff --git a/monitor_tnt.c b/monitor_tnt.c
index a7800514..b9825fa6 100644
--- a/monitor_tnt.c
+++ b/monitor_tnt.c
@@ -45,7 +45,7 @@ static void tnt_update(void)
* We have to do our own field parsing because the way this
* gets called, nmea_parse() is never called on the sentence.
*/
- (void)nmea_parse((char *)session.packet.outbuffer, &session);
+ (void)nmea_parse((char *)session.lexer.outbuffer, &session);
(void)mvwaddstr(thtmwin, 1, 19, session.nmea.field[1]);
(void)mvwaddstr(thtmwin, 2, 19, session.nmea.field[3]);
diff --git a/monitor_ubx.c b/monitor_ubx.c
index ff89e74a..15eef106 100644
--- a/monitor_ubx.c
+++ b/monitor_ubx.c
@@ -236,7 +236,7 @@ static void ubx_update(void)
struct timedrift_t drift;
#endif /* PPS_ENABLE */
- buf = session.packet.outbuffer;
+ buf = session.lexer.outbuffer;
msgid = (unsigned short)((buf[2] << 8) | buf[3]);
data_len = (size_t) getles16(buf, 4);
switch (msgid) {
diff --git a/packet.c b/packet.c
index 887781d0..073a1891 100644
--- a/packet.c
+++ b/packet.c
@@ -182,7 +182,7 @@ static size_t oncore_payload_cksum_length(unsigned char id1, unsigned char id2)
}
#endif /* ONCORE_ENABLE */
-static void character_pushback(struct gps_packet_t *lexer)
+static void character_pushback(struct gps_lexer_t *lexer)
/* push back the last character grabbed */
{
/*@-modobserver@*//* looks like a splint bug */
@@ -194,7 +194,7 @@ static void character_pushback(struct gps_packet_t *lexer)
lexer->char_counter);
}
-static void nextstate(struct gps_packet_t *lexer, unsigned char c)
+static void nextstate(struct gps_lexer_t *lexer, unsigned char c)
{
static int n = 0;
#ifdef RTCM104V2_ENABLE
@@ -1382,7 +1382,7 @@ static void nextstate(struct gps_packet_t *lexer, unsigned char c)
/*@ -charint +casebreak @*/
}
-static void packet_accept(struct gps_packet_t *lexer, int packet_type)
+static void packet_accept(struct gps_lexer_t *lexer, int packet_type)
/* packet grab succeeded, move to output buffer */
{
size_t packetlen = lexer->inbufptr - lexer->inbuffer;
@@ -1408,7 +1408,7 @@ static void packet_accept(struct gps_packet_t *lexer, int packet_type)
}
}
-static void packet_discard(struct gps_packet_t *lexer)
+static void packet_discard(struct gps_lexer_t *lexer)
/* shift the input buffer to discard all data up to current input pointer */
{
size_t discard = lexer->inbufptr - lexer->inbuffer;
@@ -1425,7 +1425,7 @@ static void packet_discard(struct gps_packet_t *lexer)
}
}
-static void character_discard(struct gps_packet_t *lexer)
+static void character_discard(struct gps_lexer_t *lexer)
/* shift the input buffer to discard one character and reread data */
{
memmove(lexer->inbuffer, lexer->inbuffer + 1, (size_t)-- lexer->inbuflen);
@@ -1445,7 +1445,7 @@ static void character_discard(struct gps_packet_t *lexer)
/* entry points begin here */
-void packet_init( /*@out@*/ struct gps_packet_t *lexer)
+void packet_init( /*@out@*/ struct gps_lexer_t *lexer)
{
lexer->char_counter = 0;
lexer->retry_counter = 0;
@@ -1458,7 +1458,7 @@ void packet_init( /*@out@*/ struct gps_packet_t *lexer)
packet_reset(lexer);
}
-void packet_parse(struct gps_packet_t *lexer)
+void packet_parse(struct gps_lexer_t *lexer)
/* grab a packet from the input buffer */
{
lexer->outbuflen = 0;
@@ -2082,7 +2082,7 @@ void packet_parse(struct gps_packet_t *lexer)
#undef getword
-ssize_t packet_get(int fd, struct gps_packet_t *lexer)
+ssize_t packet_get(int fd, struct gps_lexer_t *lexer)
/* grab a packet; return -1=>I/O error, 0=>EOF, BAD_PACKET or a length */
{
ssize_t recvd;
@@ -2165,7 +2165,7 @@ ssize_t packet_get(int fd, struct gps_packet_t *lexer)
return recvd;
}
-void packet_reset( /*@out@*/ struct gps_packet_t *lexer)
+void packet_reset( /*@out@*/ struct gps_lexer_t *lexer)
/* return the packet machine to the ground state */
{
lexer->type = BAD_PACKET;
@@ -2179,7 +2179,7 @@ void packet_reset( /*@out@*/ struct gps_packet_t *lexer)
#ifdef __UNUSED__
-void packet_pushback(struct gps_packet_t *lexer)
+void packet_pushback(struct gps_lexer_t *lexer)
/* push back the last packet grabbed */
{
if (lexer->outbuflen + lexer->inbuflen < MAX_PACKET_LENGTH) {
diff --git a/pseudonmea.c b/pseudonmea.c
index 25fe6882..998f595c 100644
--- a/pseudonmea.c
+++ b/pseudonmea.c
@@ -144,7 +144,7 @@ static void gpsd_binary_satellite_dump(struct gps_device_t *session,
}
#ifdef ZODIAC_ENABLE
- if (session->packet.type == ZODIAC_PACKET
+ if (session->lexer.type == ZODIAC_PACKET
&& session->driver.zodiac.Zs[0] != 0) {
bufp += strlen(bufp);
bufp2 = bufp;
diff --git a/serial.c b/serial.c
index 9afdf1a2..707a76d8 100644
--- a/serial.c
+++ b/serial.c
@@ -359,7 +359,7 @@ void gpsd_set_speed(struct gps_device_t *session,
session->device_type->event_hook(session, event_wakeup);
}
}
- packet_reset(&session->packet);
+ packet_reset(&session->lexer);
}
int gpsd_serial_open(struct gps_device_t *session)
@@ -478,7 +478,7 @@ int gpsd_serial_open(struct gps_device_t *session)
(void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH);
}
- session->packet.type = BAD_PACKET;
+ session->lexer.type = BAD_PACKET;
if (isatty(session->gpsdata.gps_fd) != 0) {
/* Save original terminal parameters */
if (tcgetattr(session->gpsdata.gps_fd, &session->ttyset_old) != 0)
@@ -576,7 +576,7 @@ bool gpsd_next_hunt_setting(struct gps_device_t * session)
if (isatty(session->gpsdata.gps_fd) == 0)
return false;
- if (session->packet.retry_counter++ >= SNIFF_RETRIES) {
+ if (session->lexer.retry_counter++ >= SNIFF_RETRIES) {
#ifdef FIXED_PORT_SPEED
return false;
#else
@@ -609,7 +609,7 @@ bool gpsd_next_hunt_setting(struct gps_device_t * session)
session->gpsdata.dev.stopbits
#endif /* FIXED_STOP_BITS */
);
- session->packet.retry_counter = 0;
+ session->lexer.retry_counter = 0;
}
return true; /* keep hunting */
diff --git a/test_packet.c b/test_packet.c
index 13c3e7bc..3bcf6279 100644
--- a/test_packet.c
+++ b/test_packet.c
@@ -272,7 +272,7 @@ static struct map runontests[] = {
static int packet_test(struct map *mp)
{
- struct gps_packet_t packet;
+ struct gps_lexer_t packet;
int failure = 0;
packet_init(&packet);
@@ -299,7 +299,7 @@ static int packet_test(struct map *mp)
static void runon_test(struct map *mp)
{
- struct gps_packet_t packet;
+ struct gps_lexer_t packet;
int nullfd = open("/dev/null", O_RDONLY);
ssize_t st;
diff --git a/timebase.c b/timebase.c
index b231d522..5c494f14 100644
--- a/timebase.c
+++ b/timebase.c
@@ -250,9 +250,9 @@ void gpsd_set_century(struct gps_device_t *session)
*/
{
char *end;
- if (strstr((char *)session->packet.outbuffer, "Date:") != NULL) {
+ if (strstr((char *)session->lexer.outbuffer, "Date:") != NULL) {
int year;
- unsigned char *cp = session->packet.outbuffer + 5;
+ unsigned char *cp = session->lexer.outbuffer + 5;
while (isspace(*cp))
--cp;
year = (int)strtol((char *)cp, &end, 10);