diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-09-29 01:42:45 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-09-29 01:46:53 -0400 |
commit | 4361ec2d89bdf451602d659ddfd0fb9a79c178a2 (patch) | |
tree | af067d1d7614a9e67f449eec933ba3347cde10b0 /driver_navcom.c | |
parent | a77b95b57475c2856707e91b197f8aaa8e5eb407 (diff) | |
download | gpsd-4361ec2d89bdf451602d659ddfd0fb9a79c178a2.tar.gz |
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.
Diffstat (limited to 'driver_navcom.c')
-rw-r--r-- | driver_navcom.c | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/driver_navcom.c b/driver_navcom.c index 498abc4c..406ca0e8 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -104,7 +104,7 @@ static void navcom_cmd_0x20(struct gps_device_t *session, uint8_t block_id, putbyte(msg, 16, checksum(msg + 3, 13)); putbyte(msg, 17, 0x03); (void)navcom_send_cmd(session, msg, 18); - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: sent command 0x20 (Data Request) " "- data block id = %02x at rate %02x\n", block_id, rate); } @@ -127,7 +127,7 @@ static void UNUSED navcom_cmd_0x3f(struct gps_device_t *session) putbyte(msg, 10, checksum(msg + 3, 7)); putbyte(msg, 11, 0x03); (void)navcom_send_cmd(session, msg, 12); - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: sent command 0x3f (LED Configuration Block)\n"); } @@ -148,8 +148,8 @@ static void navcom_cmd_0x1c(struct gps_device_t *session, uint8_t mode, putbyte(msg, 10, checksum(msg + 3, 7)); putbyte(msg, 11, 0x03); (void)navcom_send_cmd(session, msg, 12); - gpsd_report(LOG_PROG, "Navcom: sent command 0x1c (Test Support Block)\n"); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: sent command 0x1c (Test Support Block)\n"); + gpsd_report(session->context->debug, LOG_IO, "Navcom: command 0x1c mode = %02x, length = %u\n", mode, length); } @@ -174,9 +174,9 @@ static void navcom_cmd_0x11(struct gps_device_t *session, putbyte(msg, 10, checksum(msg + 3, 7)); putbyte(msg, 11, 0x03); (void)navcom_send_cmd(session, msg, 12); - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: sent command 0x11 (Serial Port Configuration)\n"); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: serial port selection: 0x%02x\n", port_selection); } #endif /* RECONFIGURE_ENABLE */ @@ -275,26 +275,26 @@ static gps_mask_t handle_0x83(struct gps_device_t *session) } /*@ -relaxtypes -charint @*/ - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0x83 (Ionosphere and UTC Data)\n"); - gpsd_report(LOG_IO, "Navcom: Scaled parameters follow:\n"); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: Scaled parameters follow:\n"); + gpsd_report(session->context->debug, LOG_IO, "Navcom: GPS Week: %u, GPS Time of Week: %u (GPS Time: %f)\n", week, tow, week * 604800 + tow / 1000.0); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: a0: %12.4E, a1: %12.4E, a2: %12.4E, a3: %12.4E, " "b0: %12.4E, b1: %12.4E, b2: %12.4E, b3: %12.4E\n", (double)alpha0 * SF_ALPHA0, (double)alpha1 * SF_ALPHA1, (double)alpha2 * SF_ALPHA2, (double)alpha3 * SF_ALPHA3, (double)beta0 * SF_BETA0, (double)beta1 * SF_BETA1, (double)beta2 * SF_BETA2, (double)beta3 * SF_BETA3); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: A0: %19.12E, A1: %19.12E\n", (double)a0 * SF_A0, (double)a1 * SF_A1); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: UTC Ref. Time: %lu, UTC Ref. Week: %u, dTls: %d\n", (unsigned long)tot * SF_TOT, wnt, dtls); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: Week of leap seconds: %u, Day number of leap seconds: %u, dTlsf: %d\n", wnlsf, dn, dtlsf); @@ -320,10 +320,10 @@ static gps_mask_t handle_0x06(struct gps_device_t *session) 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 */ - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0x06 (Acknowledgement (without error))\n"); /*@ -type @*/ - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: acknowledged command id 0x%02x on port %c\n", cmd_id, (port == 0 ? 'A' : (port == 1 ? 'B' : '?'))); /*@ +type @*/ @@ -338,17 +338,17 @@ static gps_mask_t handle_0x15(struct gps_device_t *session) size_t msg_len = (size_t) getleu16(buf, 1); /*@ -type @*/ uint8_t port, cmd_id = getub(buf, 3); - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0x15 (Negative Acknowledge)\n"); for (n = 4; n < (msg_len - 2); n += 2) { uint8_t err_id = getub(buf, n); uint8_t err_desc = getub(buf, n + 1); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: error id = 0x%02x, error description = 0x%02x\n", err_id, err_desc); } port = getub(buf, n); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: negative acknowledge was for command id 0x%02x on port %c\n", cmd_id, (port == 0 ? 'A' : (port == 1 ? 'B' : '?'))); /*@ -type @*/ @@ -492,17 +492,19 @@ static gps_mask_t handle_0xb1(struct gps_device_t *session) if (tdop != DOP_UNDEFINED) session->gpsdata.dop.tdop = tdop / 10.0; - gpsd_report(LOG_PROG, "Navcom: received packet type 0xb1 (PVT Report)\n"); - gpsd_report(LOG_IO, "Navcom: navigation mode %s (0x%02x) - %s - %s\n", + gpsd_report(session->context->debug, LOG_PROG, + "Navcom: received packet type 0xb1 (PVT Report)\n"); + gpsd_report(session->context->debug, LOG_IO, + "Navcom: navigation mode %s (0x%02x) - %s - %s\n", ((-nav_mode & 0x80)!='\0' ? "invalid" : "valid"), nav_mode, ((nav_mode & 0x40)!='\0' ? "3D" : "2D"), ((nav_mode & 0x03)!='\0' ? "DGPS" : "GPS")); /*@ +type @*/ - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: latitude = %f, longitude = %f, altitude = %f, geoid = %f\n", session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, session->gpsdata.separation); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: velocities: north = %f, east = %f, up = %f (track = %f, speed = %f)\n", vel_north * VEL_RES, vel_east * VEL_RES, vel_up * VEL_RES, session->newdata.track, session->newdata.speed); @@ -517,7 +519,8 @@ static gps_mask_t handle_0xb1(struct gps_device_t *session) | STATUS_SET | MODE_SET | USED_IS | HERR_SET | VERR_SET | TIMERR_SET | DOP_SET | TIME_SET | PPSTIME_IS; - gpsd_report(LOG_DATA, "PVT 0xb1: time=%.2f, lat=%.2f lon=%.2f alt=%.f " + gpsd_report(session->context->debug, LOG_DATA, + "PVT 0xb1: time=%.2f, lat=%.2f lon=%.2f alt=%.f " "speed=%.2f track=%.2f climb=%.2f mode=%d status=%d " "epx=%.2f epy=%.2f epv=%.2f " "gdop=%.2f pdop=%.2f hdop=%.2f vdop=%.2f tdop=%.2f " @@ -642,41 +645,41 @@ static gps_mask_t handle_0x81(struct gps_device_t *session) session->context->gps_week = (unsigned short)wn; session->context->gps_tow = (double)(toc * SF_TOC); /* leap second? */ - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0x81 (Packed Ephemeris Data)\n"); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: PRN: %u, Week: %u, TOW: %.3f SV clock bias/drift/drift rate: %#19.12E/%#19.12E/%#19.12E\n", prn, session->context->gps_week, session->context->gps_tow, ((double)af0) * SF_AF0, ((double)af1) * SF_AF1, ((double)af2) * SF_AF2); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: IODE (!AODE): %u Crs: %19.12e, Delta n: %19.12e, M0: %19.12e\n", iode, (double)crs * SF_CRS, (double)delta_n * SF_DELTA_N * GPS_PI, (double)m0 * SF_M0 * GPS_PI); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: Cuc: %19.12e, Eccentricity: %19.12e, Cus: %19.12e, A^1/2: %19.12e\n", (double)cuc * SF_CUC, (double)e * SF_E, (double)cus * SF_CUS, (double)sqrt_a * SF_SQRT_A); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: TOE: %u, Cic: %19.12e, Omega %19.12e, Cis: %19.12e\n", toe * SF_TOE, (double)cic * SF_CIC, (double)Omega0 * SF_OMEGA0 * GPS_PI, (double)cis * SF_CIS); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: i0: %19.12e, Crc: %19.12e, omega: %19.12e, Omega dot: %19.12e\n", (double)i0 * SF_I0 * GPS_PI, (double)crc * SF_CRC, (double)omega * SF_OMEGA * GPS_PI, (double)Omegadot * SF_OMEGADOT * GPS_PI); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: IDOT: %19.12e, Codes on L2: 0x%x, GPS Week: %u, L2 P data flag: %x\n", (double)idot * SF_IDOT * GPS_PI, cl2, week - (week % 1024) + wn, l2pd); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: SV accuracy: 0x%x, SV health: 0x%x, TGD: %f, IODC (!AODC): %u\n", ura, svh, (double)tgd * SF_TGD, iodc); - gpsd_report(LOG_IO, "Navcom: Transmission time: %u\n", tow); + gpsd_report(session->context->debug, LOG_IO, "Navcom: Transmission time: %u\n", tow); #undef SF_TGD #undef SF_TOC @@ -745,7 +748,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) } /*@ -predboolothers @*/ - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: engine status = 0x%x, almanac = %s, time = 0x%x, pos = 0x%x\n", eng_status & 0x07, (eng_status & 0x08 ? "valid" : "invalid"), eng_status & 0x30 >> 4, eng_status & 0xc0 >> 6); @@ -755,7 +758,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) i = 0; for (n = 17; n < msg_len; n += 14) { if (i >= MAXCHANNELS) { - gpsd_report(LOG_ERROR, + gpsd_report(session->context->debug, LOG_ERROR, "Navcom: packet type 0x86: too many satellites!\n"); gpsd_zero_satellites(&session->gpsdata); return 0; @@ -784,12 +787,12 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) s = session->gpsdata.ss[i++] = (p2_snr ? p2_snr : ca_snr) / 4.0; /*@ end @*/ } - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: prn = %3u, ele = %02u, azm = %03u, snr = %d (%s), " "dgps age = %.1fs, log ch = %d, hw ch = 0x%02x\n", prn, ele, azm, s, (p2_snr ? "P2" : "C/A"), (double)dgps_age * 0.1, log_channel & 0x3f, hw_channel); - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: sol. valid = %c, clock = %s, pos. = %s, " "height = %s, err. code = 0x%x\n", (sol_status & 0x01 ? 'Y' : 'N'), @@ -800,7 +803,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) /*@ +predboolothers -charint @*/ } - gpsd_report(LOG_DATA, + gpsd_report(session->context->debug, LOG_DATA, "CS 0x86: visible=%d, used=%d, mask={SATELLITE|STATUS}\n", session->gpsdata.satellites_visible, session->gpsdata.satellites_used); @@ -823,10 +826,10 @@ static gps_mask_t handle_0xb0(struct gps_device_t *session) session->context->gps_week = (unsigned short)week; session->context->gps_tow = (double)tow / 1000.0; - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0xb0 (Raw Meas. Data Block)\n"); /*@ -predboolothers @*/ - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: week = %u, tow = %.3f, time slew accumulator = %u (1/1023mS), status = 0x%02x " "(%sclock %s - %u blocks follow)\n", session->context->gps_week, @@ -864,17 +867,17 @@ static gps_mask_t handle_0xb0(struct gps_device_t *session) double p2 = (sv_status & 0x20 ? c1 + (double)p2_ca_pseudorange / 16.0 * LAMBDA_L1 : NAN); - gpsd_report(LOG_IO + 1, + gpsd_report(session->context->debug, LOG_IO + 1, "Navcom: >> sv status = 0x%02x (PRN %u - C/A & L1 %s - P1 %s - P2 & L2 %s)\n", sv_status, (sv_status & 0x1f), (sv_status & 0x80 ? "valid" : "invalid"), (sv_status & 0x40 ? "valid" : "invalid"), (sv_status & 0x20 ? "valid" : "invalid")); - gpsd_report(LOG_IO + 1, + gpsd_report(session->context->debug, LOG_IO + 1, "Navcom: >>> ch status = 0x%02x (Logical channel: %u - CA C/No: %u dBHz) " "sL1: %u, sL2: %u\n", ch_status, ch_status & 0x0f, ((ch_status & 0xf0) >> 4) + 35, l1_slips, l2_slips); - gpsd_report(LOG_IO + 1, + gpsd_report(session->context->debug, LOG_IO + 1, "Navcom: >>> C1: %14.3f, L1: %14.3f, L2: %14.3f, P1: %14.3f, P2: %14.3f\n", c1, l1, l2, p1, p2); /*@ +predboolothers -charint @*/ @@ -915,14 +918,15 @@ static gps_mask_t handle_0xb5(struct gps_device_t *session) session->newdata.time = gpsd_gpstime_resolve(session, (unsigned short)week, (double)tow / 1000.0f); - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0xb5 (Pseudorange Noise Statistics)\n"); - gpsd_report(LOG_IO, "Navcom: epe = %f\n", session->gpsdata.epe); + gpsd_report(session->context->debug, LOG_IO, + "Navcom: epe = %f\n", session->gpsdata.epe); return mask; } else { /* Ignore this message block */ if (!session->driver.navcom.warned) { - gpsd_report(LOG_WARN, + gpsd_report(session->context->debug, LOG_WARN, "Navcom: received packet type 0xb5 (Pseudorange Noise Statistics) ignored " " - sizeof(double) == 64 bits required\n"); session->driver.navcom.warned = true; @@ -1045,16 +1049,16 @@ static gps_mask_t handle_0xae(struct gps_device_t *session) asicstr = "?"; } - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0xae (Identification Block)\n"); if (msg_len == 0x0037) { - gpsd_report(LOG_INF, "Navcom: ID Data: " + gpsd_report(session->context->debug, LOG_INF, "Navcom: ID Data: " "%s %s Ver. %u.%u.%u, DC S/N: %u.%u, RF S/N: %u.%u, " "Build ID: %s, Boot software: %s\n", engconfstr, asicstr, swvermaj, swvermin, slsbn, dcser, dcclass, rfcser, rfcclass, softtm, bootstr); } else { - gpsd_report(LOG_INF, "Navcom: ID Data: " + gpsd_report(session->context->debug, LOG_INF, "Navcom: ID Data: " "%s %s Ver. %u.%u.%u, DC S/N: %u.%u, RF S/N: %u.%u, " "Build ID: %s, Boot software: %s, " "IOP Ver.: %u.%u.%u, PIC: %u, IOP Build ID: %s\n", @@ -1098,13 +1102,13 @@ static gps_mask_t handle_0xef(struct gps_device_t *session) osc_filter_drift_est = NAN; } - gpsd_report(LOG_IO, + gpsd_report(session->context->debug, LOG_IO, "Navcom: oscillator temp. = %d, nav. status = 0x%02x, " "nav. clock offset = %f, nav. clock drift = %f, " "osc. filter drift est. = %f, acc.time slew value = %d\n", osc_temp, nav_status, nav_clock_offset, nav_clock_drift, osc_filter_drift_est, time_slew); - gpsd_report(LOG_DATA, + gpsd_report(session->context->debug, LOG_DATA, "CDO 0xef: time=%.2f mask={TIME}\n", session->newdata.time); return 0; } @@ -1125,7 +1129,7 @@ gps_mask_t navcom_parse(struct gps_device_t * session, unsigned char *buf, msg_len = (uint) getleu16(buf, 4); /*@ -usedef -compdef @*/ - gpsd_report(LOG_RAW, "Navcom: packet type 0x%02x\n", cmd_id); + gpsd_report(session->context->debug, LOG_RAW, "Navcom: packet type 0x%02x\n", cmd_id); /*@ +usedef +compdef @*/ (void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag), @@ -1157,7 +1161,7 @@ gps_mask_t navcom_parse(struct gps_device_t * session, unsigned char *buf, case 0xef: return handle_0xef(session); default: - gpsd_report(LOG_PROG, + gpsd_report(session->context->debug, LOG_PROG, "Navcom: received packet type 0x%02x, length %d - unknown or unimplemented\n", cmd_id, msg_len); return 0; |