From 4361ec2d89bdf451602d659ddfd0fb9a79c178a2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 29 Sep 2013 01:42:45 -0400 Subject: Change gpsd_report to no longer use a global. All regression tests pass. This is a large, ugly change. But without it we can't troubleshoot the ICP/IP-source initialization bug properly - colliding definitions of gpsd_report() were interfering with error reporting early in gpsd runs. More cleanup work remains to be done, but at least this is working. --- isgps.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'isgps.c') diff --git a/isgps.c b/isgps.c index 67fb28f8..1e094f26 100644 --- a/isgps.c +++ b/isgps.c @@ -140,7 +140,9 @@ unsigned int isgps_parity(isgps30bits_t th) 0xff]); /*@ -charint @*/ +#ifdef __UNUSED__ gpsd_report(ISGPS_ERRLEVEL_BASE + 2, "ISGPS parity %u\n", p); +#endif /* __UNUSED__ */ return (p); } @@ -182,7 +184,7 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, { /* ASCII characters 64-127, @ through DEL */ if ((c & MAG_TAG_MASK) != MAG_TAG_DATA) { - gpsd_report(ISGPS_ERRLEVEL_BASE + 1, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 1, "ISGPS word tag not correct, skipping byte\n"); return ISGPS_SKIP; } @@ -202,18 +204,18 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, session->isgps.curr_word |= c >> -(session->isgps.curr_offset); } - gpsd_report(ISGPS_ERRLEVEL_BASE + 2, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 2, "ISGPS syncing at byte %lu: 0x%08x\n", session->char_counter, session->isgps.curr_word); if (preamble_match(&session->isgps.curr_word)) { if (isgps_parityok(session->isgps.curr_word)) { - gpsd_report(ISGPS_ERRLEVEL_BASE + 1, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 1, "ISGPS preamble ok, parity ok -- locked\n"); session->isgps.locked = true; break; } - gpsd_report(ISGPS_ERRLEVEL_BASE + 1, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 1, "ISGPS preamble ok, parity fail\n"); } session->isgps.curr_offset++; @@ -242,13 +244,13 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, * another preamble pattern in the data stream. -wsr */ if (preamble_match(&session->isgps.curr_word)) { - gpsd_report(ISGPS_ERRLEVEL_BASE + 2, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 2, "ISGPS preamble spotted (index: %u)\n", session->isgps.bufindex); session->isgps.bufindex = 0; } #endif - gpsd_report(ISGPS_ERRLEVEL_BASE + 2, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 2, "ISGPS processing word %u (offset %d)\n", session->isgps.bufindex, session->isgps.curr_offset); @@ -259,7 +261,7 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, */ if (session->isgps.bufindex >= (unsigned)maxlen) { session->isgps.bufindex = 0; - gpsd_report(ISGPS_ERRLEVEL_BASE + 1, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 1, "ISGPS buffer overflowing -- resetting\n"); return ISGPS_NO_SYNC; } @@ -270,7 +272,7 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, /* *INDENT-OFF* */ if ((session->isgps.bufindex == 0) && !preamble_match((isgps30bits_t *) session->isgps.buf)) { - gpsd_report(ISGPS_ERRLEVEL_BASE + 1, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 1, "ISGPS word 0 not a preamble- punting\n"); return ISGPS_NO_SYNC; } @@ -294,20 +296,22 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, c >> -(session->isgps.curr_offset); } } else { - gpsd_report(ISGPS_ERRLEVEL_BASE + 0, + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 0, "ISGPS parity failure, lost lock\n"); session->isgps.locked = false; } } session->isgps.curr_offset -= 6; - gpsd_report(ISGPS_ERRLEVEL_BASE + 2, "ISGPS residual %d\n", + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 2, + "ISGPS residual %d\n", session->isgps.curr_offset); return res; } /*@ +shiftnegative @*/ /* never achieved lock */ - gpsd_report(ISGPS_ERRLEVEL_BASE + 1, "ISGPS lock never achieved\n"); + gpsd_report(session->debug, ISGPS_ERRLEVEL_BASE + 1, + "ISGPS lock never achieved\n"); return ISGPS_NO_SYNC; } -- cgit v1.2.1