Skip to content

Commit

Permalink
Reliable cycle-start indication for almost all drivers.
Browse files Browse the repository at this point in the history
Some regression tests needed to be rebuilt as a result.  
One new regression test, for iTalk binary.
  • Loading branch information
eric-s-raymond committed Sep 9, 2009
1 parent 9e679fb commit 5744aee
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 59 deletions.
23 changes: 17 additions & 6 deletions driver_evermore.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size
{
unsigned char buf2[MAX_PACKET_LENGTH], *cp, *tp;
size_t i, datalen;
unsigned int used, visible, satcnt;
unsigned int type, used, visible, satcnt;
double version;
gps_mask_t mask = 0;

Expand All @@ -161,15 +161,27 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size
tp++;
}

type = getub(buf2, 1);

/*@ -usedef -compdef @*/
gpsd_report(LOG_RAW, "EverMore packet type 0x%02x, length %zd: %s\n",
buf2[0], datalen, gpsd_hexdump_wrapper(buf2, datalen, LOG_RAW));
type, datalen, gpsd_hexdump_wrapper(buf2, datalen, LOG_RAW));
/*@ +usedef +compdef @*/

(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
"EID%d",(int)buf2[0]);

switch (getub(buf2, 1))
"EID%u", type);

/*
* Only one message sends actual fix data, so we can treat it as
* both start-of-cycle and end-of-cycle. For correctness, and in
* case the reports ever merge data from other sentences, we
* should find out what the actual cycle-ender is.
*/
session->cycle_state |= CYCLE_END_RELIABLE;
if (type == 0x02)
session->cycle_state |= CYCLE_START | CYCLE_END;

switch (type)
{
case 0x02: /* Navigation Data Output */
session->gpsdata.fix.time = session->gpsdata.sentence_time
Expand All @@ -195,7 +207,6 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size
session->gpsdata.status,
visible,
used);
session->cycle_state |= CYCLE_START;
mask |= TIME_SET | LATLON_SET | TRACK_SET | SPEED_SET | MODE_SET;
if (session->subtype[0] == '\0') {
(void)snprintf(session->subtype, sizeof(session->subtype),
Expand Down
5 changes: 4 additions & 1 deletion driver_garmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id

gpsd_report(LOG_IO, "PrintSERPacket(, %#02x, %#02x, )\n", pkt_id, pkt_len);

session->cycle_state = CYCLE_END_RELIABLE;
if (pkt_id == GARMIN_PKTID_PVT_DATA)
session->cycle_state |= (CYCLE_START | CYCLE_END);

switch( pkt_id ) {
case ACK:
gpsd_report(LOG_PROG, "ACK\n");
Expand Down Expand Up @@ -468,7 +472,6 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id
, pvt->leap_sec
, pvt->grmn_days);

session->cycle_state |= CYCLE_START;
mask |= TIME_SET | LATLON_SET | ALTITUDE_SET | STATUS_SET | MODE_SET | SPEED_SET | TRACK_SET | CLIMB_SET | HERR_SET | VERR_SET | PERR_SET;
break;
case GARMIN_PKTID_RMD_DATA:
Expand Down
6 changes: 6 additions & 0 deletions driver_italk.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ static gps_mask_t italk_parse(struct gps_device_t *session, unsigned char *buf,
gpsd_report(LOG_RAW, "raw italk packet type 0x%02x length %zu: %s\n",
type, len, gpsd_hexdump_wrapper(buf, len, LOG_RAW));

session->cycle_state = CYCLE_END_RELIABLE;
if (type == ITALK_NAV_FIX)
session->cycle_state |= CYCLE_START;
else if (type == ITALK_PRN_STATUS)
session->cycle_state |= CYCLE_END;

switch (type)
{
case ITALK_NAV_FIX:
Expand Down
11 changes: 10 additions & 1 deletion driver_navcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ static gps_mask_t handle_0xb1(struct gps_device_t *session)
#undef VEL_RES
#undef DOP_UNDEFINED

session->cycle_state |= CYCLE_START;
return LATLON_SET | ALTITUDE_SET | CLIMB_SET | SPEED_SET | TRACK_SET
| TIME_SET | STATUS_SET | MODE_SET | USED_SET | HERR_SET | VERR_SET
| TIMERR_SET | DOP_SET;
Expand Down Expand Up @@ -1109,6 +1108,16 @@ gps_mask_t navcom_parse(struct gps_device_t *session, unsigned char *buf, size_t
(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
"0x%02x",cmd_id);

/*
* Only one message, at start of cycle, sends actual fix data, so
* we can treat it as end-of-cycle too. For correctness, and in case
* the reports ever merge data from other sentences, we should
* find out what the actual cycle-ender is.
*/
session->cycle_state |= CYCLE_END_RELIABLE;
if (cmd_id == 0xb1)
session->cycle_state |= CYCLE_START | CYCLE_END;

switch (cmd_id)
{
case 0x06:
Expand Down
10 changes: 10 additions & 0 deletions driver_oncore.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,16 @@ gps_mask_t oncore_dispatch(struct gps_device_t *session, unsigned char *buf, siz
(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
"MOT-%c%c", type>>8, type&0xff);

/*
* Only one message sends actual fix data, so we can treat it as
* both start-of-cycle and end-of-cycle. For correctness, and in
* case the reports ever merge data from other sentences, we
* should find out what the actual cycle-ender is.
*/
session->cycle_state |= CYCLE_END_RELIABLE;
if (type == ONCTYPE('E','a'))
session->cycle_state |= CYCLE_START | CYCLE_END;

switch (type)
{
case ONCTYPE('B','b'):
Expand Down
4 changes: 4 additions & 0 deletions driver_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ gps_mask_t _proto__dispatch(struct gps_device_t *session, unsigned char *buf, si
* packet analyzer.
*/
session->cycle_state = CYCLE_END_RELIABLE;
if (msgid == MY_START_OF_CYCLE)
session->cycle_state |= CYCLE_START;
else if (msgid == MY_END_OF_CYCLE)
session->cycle_state |= CYCLE_END;

type = GET_MESSAGE_TYPE();

Expand Down
6 changes: 5 additions & 1 deletion driver_sirf.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ static gps_mask_t sirf_msg_navsol(struct gps_device_t *session, unsigned char *b
#endif /* NTPSHM_ENABLE */
/* fix quality data */
session->gpsdata.hdop = (double)getub(buf, 20)/5.0;
session->cycle_state |= CYCLE_START | CYCLE_END | CYCLE_END_RELIABLE;
mask |= TIME_SET | LATLON_SET | TRACK_SET | SPEED_SET | STATUS_SET | MODE_SET | HDOP_SET | USED_SET;
}
return mask;
Expand Down Expand Up @@ -754,6 +753,11 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
"MID%d",(int)buf[0]);

/* could change if the set of messages we enable does */
session->cycle_state = CYCLE_END_RELIABLE;
if (buf[0] == (unsigned char)0x02 || (unsigned char)0x62)
session->cycle_state |= (CYCLE_START | CYCLE_END);

switch (buf[0])
{
case 0x02: /* Measure Navigation Data Out */
Expand Down
24 changes: 22 additions & 2 deletions driver_superstar2.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ static gps_mask_t superstar2_msg_ack(struct gps_device_t *,
unsigned char *, size_t );
static gps_mask_t superstar2_msg_navsol_lla(struct gps_device_t *,
unsigned char *, size_t );
#ifdef __UNUSED__
static gps_mask_t superstar2_msg_navsol_ecef(struct gps_device_t *,
unsigned char *, size_t );
#endif /* __UNUSED__ */
static gps_mask_t superstar2_msg_timing(struct gps_device_t *,
unsigned char *, size_t );
static gps_mask_t superstar2_msg_svinfo(struct gps_device_t *,
Expand Down Expand Up @@ -144,12 +146,18 @@ superstar2_msg_navsol_lla(struct gps_device_t *session,
session->gpsdata.fix.mode = MODE_NO_FIX;
}

session->cycle_state |= CYCLE_START;
mask |= MODE_SET | STATUS_SET ;

return mask;
}

#ifdef __UNUSED__
/*
* This is duplicative with navsol_lla. By suppressing evaluation of it,
* we gain the desirable feature that the fix update is atomic and
* exactly once per cycle.
*/

static gps_mask_t
superstar2_msg_navsol_ecef(struct gps_device_t *session,
unsigned char *buf, size_t data_len)
Expand Down Expand Up @@ -218,11 +226,11 @@ superstar2_msg_navsol_ecef(struct gps_device_t *session,
session->gpsdata.fix.mode = MODE_NO_FIX;
}

session->cycle_state |= CYCLE_START;
mask |= MODE_SET | STATUS_SET;

return mask;
}
#endif /* __UNUSED__ */

/**
* GPS Satellite Info
Expand Down Expand Up @@ -437,6 +445,16 @@ superstar2_dispatch(struct gps_device_t *session, unsigned char *buf,
(void)snprintf(session->gpsdata.tag,
sizeof(session->gpsdata.tag), "SS2-%d", type);

/*
* Only one message sends actual fix data, so we can treat it as
* both start-of-cycle and end-of-cycle. For correctness, and in
* case the reports ever merge data from other sentences, we
* should find out what the actual cycle-ender is.
*/
session->cycle_state |= CYCLE_END_RELIABLE;
if (type == SUPERSTAR2_NAVSOL_LLA)
session->cycle_state |= CYCLE_START | CYCLE_END;

switch (type)
{
case SUPERSTAR2_ACK: /* Message Acknowledgement */
Expand All @@ -445,8 +463,10 @@ superstar2_dispatch(struct gps_device_t *session, unsigned char *buf,
return superstar2_msg_svinfo(session, buf, len);
case SUPERSTAR2_NAVSOL_LLA: /* Navigation Data */
return superstar2_msg_navsol_lla(session, buf, len);
#ifdef __UNUSED__
case SUPERSTAR2_NAVSOL_ECEF: /* Navigation Data */
return superstar2_msg_navsol_ecef(session, buf, len);
#endif /* __UNUSED__ */
case SUPERSTAR2_VERSION: /* Hardware/Software Version */
return superstar2_msg_version(session, buf, len);
case SUPERSTAR2_TIMING: /* Timing Parameters */
Expand Down
4 changes: 1 addition & 3 deletions driver_ubx.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,7 @@ gps_mask_t ubx_parse(struct gps_device_t *session, unsigned char *buf, size_t le
/* could change if the set of messages we enable does */
session->cycle_state = CYCLE_END_RELIABLE;
if (msgid == 0x0106)
session->cycle_state |= CYCLE_START;
else if (msgid == 0x0130)
session->cycle_state |= CYCLE_END;
session->cycle_state |= CYCLE_START | CYCLE_END;

return mask | ONLINE_SET;
}
Expand Down
10 changes: 7 additions & 3 deletions driver_zodiac.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,19 @@ static gps_mask_t zodiac_analyze(struct gps_device_t *session)

(void)snprintf(session->gpsdata.tag,sizeof(session->gpsdata.tag),"%u",id);

/* normal cycle for these devices is 1001 1002 */
/*
* Normal cycle for these devices is 1001 1002.
* We cound 1001 as end of cycle because 1002 doesn't
* carry fix information.
*/
session->cycle_state = CYCLE_END_RELIABLE;
if (id == 1000)
session->cycle_state |= (CYCLE_START | CYCLE_END);

switch (id) {
case 1000:
session->cycle_state = CYCLE_END;
return handle1000(session);
case 1002:
/* actual cycle end, but conveys no fix information */
return handle1002(session);
case 1003:
return handle1003(session);
Expand Down
Binary file added test/stable/italk-binary.log
Binary file not shown.
Loading

0 comments on commit 5744aee

Please sign in to comment.