diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2014-08-27 16:26:52 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-08-27 16:26:52 -0400 |
commit | 6203e5b8fcac9d78ea54b7b3c53cb8d084e8a219 (patch) | |
tree | d8611d8e44267151c29ab8920702cc94e86063c5 | |
parent | b53db1322c70f8b86dfe72e982d6097304a749ae (diff) | |
download | gpsd-6203e5b8fcac9d78ea54b7b3c53cb8d084e8a219.tar.gz |
Introduce struct errout_t to encapsulate error-reporting hooks.
A major step towards eliminating reverse linkage.
All regression tests pass.
-rw-r--r-- | driver_evermore.c | 30 | ||||
-rw-r--r-- | driver_garmin.c | 158 | ||||
-rw-r--r-- | driver_garmin_txt.c | 26 | ||||
-rw-r--r-- | driver_geostar.c | 106 | ||||
-rw-r--r-- | driver_italk.c | 46 | ||||
-rw-r--r-- | driver_navcom.c | 104 | ||||
-rw-r--r-- | driver_nmea0183.c | 92 | ||||
-rw-r--r-- | driver_nmea2000.c | 116 | ||||
-rw-r--r-- | driver_oncore.c | 32 | ||||
-rw-r--r-- | driver_proto.c | 22 | ||||
-rw-r--r-- | driver_rtcm3.c | 2 | ||||
-rw-r--r-- | driver_sirf.c | 178 | ||||
-rw-r--r-- | driver_superstar2.c | 30 | ||||
-rw-r--r-- | driver_tsip.c | 90 | ||||
-rw-r--r-- | driver_ubx.c | 112 | ||||
-rw-r--r-- | driver_zodiac.c | 14 | ||||
-rw-r--r-- | drivers.c | 78 | ||||
-rw-r--r-- | gpsctl.c | 124 | ||||
-rw-r--r-- | gpsd.c | 238 | ||||
-rw-r--r-- | gpsd.h-tail | 16 | ||||
-rw-r--r-- | gpsmon.c | 4 | ||||
-rw-r--r-- | gpspacket.c | 39 | ||||
-rw-r--r-- | isgps.c | 22 | ||||
-rw-r--r-- | libgpsd_core.c | 152 | ||||
-rw-r--r-- | net_dgpsip.c | 10 | ||||
-rw-r--r-- | net_ntrip.c | 34 | ||||
-rw-r--r-- | ntpshm.c | 22 | ||||
-rw-r--r-- | packet.c | 99 | ||||
-rw-r--r-- | ppsthread.c | 64 | ||||
-rw-r--r-- | serial.c | 30 | ||||
-rw-r--r-- | shmexport.c | 6 | ||||
-rw-r--r-- | subframe.c | 36 | ||||
-rw-r--r-- | test_packet.c | 32 | ||||
-rw-r--r-- | timebase.c | 12 |
34 files changed, 1114 insertions, 1062 deletions
diff --git a/driver_evermore.c b/driver_evermore.c index 20e75045..8b000f1b 100644 --- a/driver_evermore.c +++ b/driver_evermore.c @@ -173,7 +173,7 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, /*@ +usedef @*/ /*@ -usedef -compdef @*/ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "EverMore packet type 0x%02x (%zd bytes)\n", type, tp-buf2); /*@ +usedef +compdef @*/ @@ -209,7 +209,7 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, "%3.2f", version); mask |= DEVICEID_SET; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NDO 0x02: time=%.2f, lat=%.2f lon=%.2f alt=%.2f speed=%.2f track=%.2f climb=%.2f mode=%d subtype='%s\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, @@ -254,7 +254,7 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, } /* that's all the information in this packet */ mask = TIME_SET | PPSTIME_IS | DOP_SET | MODE_SET | STATUS_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "DDO 0x04: gdop=%.2f pdop=%.2f hdop=%.2f vdop=%.2f tdop=%.2f mode=%d, status=%d mask={TIME| DOP|MODE|STATUS}\n", session->gpsdata.dop.gdop, session->gpsdata.dop.pdop, session->gpsdata.dop.hdop, session->gpsdata.dop.vdop, @@ -270,7 +270,7 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, gpsd_zero_satellites(&session->gpsdata); memset(session->gpsdata.used, 0, sizeof(session->gpsdata.used)); if (session->gpsdata.satellites_visible > 12) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Warning: EverMore packet has information about %d satellites!\n", session->gpsdata.satellites_visible); } @@ -309,7 +309,7 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, session->gpsdata.satellites_visible = (int)satcnt; /* that's all the information in this packet */ mask = SATELLITE_SET | USED_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "CSO 0x06: time=%.2f used=%d visible=%d mask={TIME|SATELLITE|USED}\n", session->newdata.time, session->gpsdata.satellites_used, session->gpsdata.satellites_visible); @@ -352,28 +352,28 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, } #undef SBITS #undef UBITS - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "MDO 0x04: time=%.2f mask={TIME|RAW}\n", session->newdata.time); return TIME_SET | PPSTIME_IS | RAW_IS; case 0x20: /* LogConfig Info, could be used as a probe for EverMore GPS */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "LogConfig EverMore packet, length %zd\n", datalen); return ONLINE_SET; case 0x22: /* LogData */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "LogData EverMore packet, length %zd\n", datalen); return ONLINE_SET; case 0x38: /* ACK */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "EverMore command %02X ACK\n", getub(buf2, 3)); return ONLINE_SET; default: - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "unknown EverMore packet EID 0x%02x, length %zd\n", buf2[0], datalen); return 0; @@ -460,7 +460,7 @@ static bool evermore_protocol(struct gps_device_t *session, int protocol) (char)0x00, /* 3: reserved */ }; /*@ -charint */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "evermore_protocol(%d)\n", protocol); /*@i1@*/ tmp8 = (protocol != 0) ? 1 : 0; /* NMEA : binary */ @@ -491,7 +491,7 @@ static bool evermore_nmea_config(struct gps_device_t *session, int mode) 0, 0, 0, 0, 0, 0, /* 10-15: reserved */ }; /*@ -charint */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "evermore_nmea_config(%d)\n", mode); /*@i1@*/ tmp8 = (mode == 1) ? 5 : 1; /* NMEA GPGSV, gpsd */ @@ -505,7 +505,7 @@ static bool evermore_nmea_config(struct gps_device_t *session, int mode) static void evermore_mode(struct gps_device_t *session, int mode) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "evermore_mode(%d), %d\n", mode, session->back_to_nmea ? 1 : 0); if (mode == MODE_NMEA) { @@ -549,7 +549,7 @@ static bool evermore_speed(struct gps_device_t *session, speed_t speed, char parity, int stopbits) { /*@ -type @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "evermore_speed(%u%c%d)\n", (unsigned int)speed, parity, stopbits); /* parity and stopbit switching aren't available on this chip */ @@ -592,7 +592,7 @@ static bool evermore_rate_switcher(struct gps_device_t *session, double rate) { /*@ +charint @*/ if (rate < 1 || rate > 10) { - gpsd_report(session->context->debug, LOG_ERROR, "valid rate range is 1-10.\n"); + gpsd_report(session->context->errout.debug, LOG_ERROR, "valid rate range is 1-10.\n"); return false; } else { unsigned char evrm_rate_config[] = { diff --git a/driver_garmin.c b/driver_garmin.c index c5673cdc..792dbaa3 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -304,17 +304,17 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, cpo_pvt_data *pvt = NULL; cpo_rcv_data *rmd = NULL; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: PrintSERPacket(, %#02x, %#02x, )\n", pkt_id, pkt_len); session->cycle_end_reliable = true; switch (pkt_id) { case ACK: - gpsd_report(session->context->debug, LOG_PROG, "Garmin: ACK\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: ACK\n"); break; case NAK: - gpsd_report(session->context->debug, LOG_PROG, "Garmin: NAK\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: NAK\n"); break; case GARMIN_PKTID_L001_COMMAND_DATA: prod_id = get_uint16((uint8_t *) buf); @@ -339,11 +339,11 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, break; } /*@ +branchstate @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Appl, Command Data: %s\n", msg); break; case GARMIN_PKTID_PRODUCT_RQST: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Appl, Product Data req\n"); break; case GARMIN_PKTID_PRODUCT_DATA: @@ -351,23 +351,23 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, ver = get_uint16((uint8_t *) & buf[2]); maj_ver = (int)(ver / 100); min_ver = (int)(ver - (maj_ver * 100)); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Appl, Product Data, sz: %d\n", pkt_len); (void)snprintf(session->subtype, sizeof(session->subtype), "%d: %d.%02d", (int)prod_id, maj_ver, min_ver); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: Product ID: %d, SoftVer: %d.%02d\n", prod_id, maj_ver, min_ver); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: Product Desc: %s\n", &buf[4]); mask |= DEVICEID_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: PRODUCT_DATA: subtype=%s\n", session->subtype); break; case GARMIN_PKTID_PVT_DATA: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Appl, PVT Data Sz: %d\n", pkt_len); pvt = (cpo_pvt_data *) buf; @@ -382,29 +382,29 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, time_l += (time_t) round(pvt->gps_tow); session->context->gps_tow = pvt->gps_tow; session->newdata.time = (timestamp_t)time_l; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: time_l: %ld\n", (long int)time_l); session->newdata.latitude = radtodeg(pvt->lat); /* sanity check the lat */ if (90.0 < session->newdata.latitude) { session->newdata.latitude = 90.0; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: ERROR: Latitude overrange\n"); } else if (-90.0 > session->newdata.latitude) { session->newdata.latitude = -90.0; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: ERROR: Latitude negative overrange\n"); } session->newdata.longitude = radtodeg(pvt->lon); /* sanity check the lon */ if (180.0 < session->newdata.longitude) { session->newdata.longitude = 180.0; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: ERROR: Longitude overrange\n"); } else if (-180.0 > session->newdata.longitude) { session->newdata.longitude = -180.0; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: ERROR: Longitude negative overrange\n"); } // altitude over WGS84 converted to MSL @@ -466,20 +466,20 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, break; } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Appl, mode %d, status %d\n", session->newdata.mode, session->gpsdata.status); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: UTC Time: %lf\n", session->newdata.time); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: Geoid Separation (MSL-WGS84): from garmin %lf, calculated %lf\n", -pvt->msl_hght, wgs84_separation(session->newdata.latitude, session->newdata.longitude)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: Alt: %.3f, Epe: %.3f, Eph: %.3f, Epv: %.3f, Fix: %d, Gps_tow: %f, Lat: %.3f, Lon: %.3f, LonVel: %.3f, LatVel: %.3f, AltVel: %.3f, MslHgt: %.3f, Leap: %d, GarminDays: %d\n", pvt->alt, pvt->epe, pvt->eph, pvt->epv, GPSD_LE16TOH(pvt->fix), pvt->gps_tow, session->newdata.latitude, @@ -501,7 +501,7 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, if (session->fixcnt > 3) mask |= PPSTIME_IS; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: PVT_DATA: time=%.2f, lat=%.2f lon=%.2f " "speed=%.2f track=%.2f climb=%.2f " "epx=%.2f epy=%.2f epv=%.2f " @@ -521,13 +521,13 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, case GARMIN_PKTID_RMD_DATA: case GARMIN_PKTID_RMD41_DATA: rmd = (cpo_rcv_data *) buf; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: PVT RMD Data Sz: %d\n", pkt_len); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: PVT RMD rcvr_tow: %f, rcvr_wn: %d\n", rmd->rcvr_tow, rmd->rcvr_wn); for (i = 0; i < GARMIN_CHANNELS; i++) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: PVT RMD Sat: %3u, cycles: %9u, pr: %16.6f, " "phase: %7.3f, slp_dtct: %3s, snr: %3u, Valid: %3s\n", (int)rmd->sv[i].svid + 1, @@ -541,7 +541,7 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, break; case GARMIN_PKTID_SAT_DATA: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: SAT Data Sz: %d\n", pkt_len); sats = (cpo_sat_data *) buf; @@ -550,7 +550,7 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, memset(session->gpsdata.used, 0, sizeof(session->gpsdata.used)); gpsd_zero_satellites(&session->gpsdata); for (i = 0, j = 0; i < GARMIN_CHANNELS; i++, sats++) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: Sat %3d, snr: %5u, elev: %2d, Azmth: %3d, Stat: %x\n", sats->svid, GPSD_LE16TOH(sats->snr), sats->elev, GPSD_LE16TOH(sats->azmth), @@ -591,7 +591,7 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, mask |= SATELLITE_SET; if (session->gpsdata.satellites_used > 0) mask |= USED_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: SAT_DATA: visible=%d used=%d\n", session->gpsdata.satellites_visible, session->gpsdata.satellites_used); @@ -599,22 +599,22 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, case GARMIN_PKTID_PROTOCOL_ARRAY: // this packet is never requested, it just comes, in some case // after a GARMIN_PKTID_PRODUCT_RQST - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: Appl, Product Capability, sz: %d\n", pkt_len); for (i = 0; i < pkt_len; i += 3) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: %c%03d\n", buf[i], get_uint16((uint8_t *) & buf[i + 1])); } break; default: - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Garmin: Unknown packet id: %#02x, Sz: %#02x\n", pkt_id, pkt_len); break; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: PrintSERPacket(, %#02x, %#02x, )\n", pkt_id, pkt_len); return mask; @@ -639,10 +639,10 @@ static gps_mask_t PrintUSBPacket(struct gps_device_t *session, Packet_t * pkt) // uint8_t *buffer = (uint8_t *) pkt; - gpsd_report(session->context->debug, LOG_PROG, "Garmin: PrintUSBPacket()\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: PrintUSBPacket()\n"); // gem if (DLE == pkt->mPacketType) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: really a SER packet!\n"); return PrintSERPacket(session, (unsigned char)buffer[1], @@ -650,7 +650,7 @@ static gps_mask_t PrintUSBPacket(struct gps_device_t *session, Packet_t * pkt) } // gem if (4096 < mDataSize) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Garmin: bogus packet, size too large=%d\n", mDataSize); return 0; @@ -661,17 +661,17 @@ static gps_mask_t PrintUSBPacket(struct gps_device_t *session, Packet_t * pkt) /* Garmin USB layer specific */ switch (pkt->mPacketId) { case GARMIN_PKTID_TRANSPORT_START_SESSION_REQ: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Transport, Start Session req\n"); break; case GARMIN_PKTID_TRANSPORT_START_SESSION_RESP: mode = get_int32(&pkt->mData.uchars[0]); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Transport, Start Session resp, unit: 0x%x\n", mode); break; default: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Transport, Packet: Type %d %d %d, ID: %d, Sz: %d\n", pkt->mPacketType, pkt->mReserved1, pkt->mReserved2, pkt->mPacketId, mDataSize); @@ -691,11 +691,11 @@ static gps_mask_t PrintUSBPacket(struct gps_device_t *session, Packet_t * pkt) switch (pkt->mPacketId) { case PRIV_PKTID_SET_MODE: prod_id = get_uint16(&pkt->mData.uchars[0]); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Private, Set Mode: %d\n", prod_id); break; case PRIV_PKTID_INFO_REQ: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Private, ID: Info Req\n"); break; case PRIV_PKTID_INFO_RESP: @@ -704,21 +704,21 @@ static gps_mask_t PrintUSBPacket(struct gps_device_t *session, Packet_t * pkt) min_ver = (int)(veri & 0xffff); mode = get_int32(&pkt->mData.uchars[4]); serial = get_int32(&pkt->mData.uchars[8]); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Private, ID: Info Resp\n"); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Garmin: USB Driver found, Version %d.%d, Mode: %d, GPS Serial# %u\n", maj_ver, min_ver, mode, serial); break; default: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Private, Packet: ID: %d, Sz: %d\n", pkt->mPacketId, mDataSize); break; } break; default: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Packet: Type %d %d %d, ID: %d, Sz: %d\n", pkt->mPacketType, pkt->mReserved1, pkt->mReserved2, pkt->mPacketId, mDataSize); @@ -754,7 +754,7 @@ static void Build_Send_USB_Packet(struct gps_device_t *session, theBytesReturned = gpsd_write(session, (const char *)thePacket, (size_t) theBytesToWrite); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: SendPacket(), wrote %zd bytes\n", theBytesReturned); @@ -827,7 +827,7 @@ static void Build_Send_SER_Packet(struct gps_device_t *session, theBytesReturned = gpsd_write(session, (const char *)thePacket, (size_t) theBytesToWrite); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: SendPacket(), wrote %zd bytes\n", theBytesReturned); @@ -941,11 +941,11 @@ static bool garmin_usb_detect(struct gps_device_t *session UNUSED) else { #ifdef HAVE_LIBUSB if (!is_usb_device(session->gpsdata.dev.path, 0x091e, 0x0003, - session->context->debug)) + session->context->errout.debug)) return false; if (!gpsd_set_raw(session)) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Garmin: garmin_usb_detect: error changing port attributes: %s\n", strerror(errno)); return false; @@ -953,7 +953,7 @@ static bool garmin_usb_detect(struct gps_device_t *session UNUSED) if (sizeof(session->driver.garmin.Buffer) < sizeof(Packet_t)) { /* dunno how this happens, but it does on some compilers */ - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Garmin: garmin_usb_detect: Compile error, garmin.Buffer too small.\n"); return false; } @@ -961,7 +961,7 @@ static bool garmin_usb_detect(struct gps_device_t *session UNUSED) // FIXME!!! needs to use libusb totally and move garmin_gps aside */ // set Mode 1, mode 0 is broken somewhere past 2.6.14 // but how? - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Set garmin_gps driver mode = 0\n"); Build_Send_USB_Packet(session, GARMIN_LAYERID_PRIVATE, PRIV_PKTID_SET_MODE, 4, MODE_GARMIN_SERIAL); @@ -987,12 +987,12 @@ static void garmin_event_hook(struct gps_device_t *session, event_t event) */ if (event == event_identified || event == event_reactivate) { // Tell the device to send product data - gpsd_report(session->context->debug, LOG_PROG, "Garmin: Get Product Data\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Get Product Data\n"); Build_Send_SER_Packet(session, GARMIN_LAYERID_APPL, GARMIN_PKTID_PRODUCT_RQST, 0, 0); // turn on PVT data 49 - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Set to send reports every 1 second\n"); Build_Send_SER_Packet(session, GARMIN_LAYERID_APPL, @@ -1001,7 +1001,7 @@ static void garmin_event_hook(struct gps_device_t *session, event_t event) #if USE_RMD // turn on RMD data 110 - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: Set to send Raw sat data\n"); Build_Send_SER_Packet(session, GARMIN_LAYERID_APPL, GARMIN_PKTID_L001_COMMAND_DATA, 2, @@ -1010,7 +1010,7 @@ static void garmin_event_hook(struct gps_device_t *session, event_t event) } if (event == event_deactivate) /* FIX-ME: is any action needed, or is closing the port sufficient? */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: garmin_close()\n"); } @@ -1033,24 +1033,24 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) unsigned char chksum = 0; gps_mask_t mask = 0; - gpsd_report(session->context->debug, LOG_RAW, "Garmin: garmin_ser_parse()\n"); + gpsd_report(session->context->errout.debug, LOG_RAW, "Garmin: garmin_ser_parse()\n"); if (6 > len) { /* WTF? */ /* minimum packet; <DLE> [pkt id] [length=0] [chksum] <DLE> <STX> */ Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: serial too short: %zd\n", len); return 0; } /* debug */ for (i = 0; i < (int)len; i++) { - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Char: %#02x\n", buf[i]); } if ('\x10' != buf[0]) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, "Garmin: buf[0] not DLE\n"); + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: buf[0] not DLE\n"); return 0; } n = 1; @@ -1059,7 +1059,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) if ('\x10' == pkt_id) { if ('\x10' != buf[n++]) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, "Garmin: Bad pkt_id %#02x\n", pkt_id); + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Bad pkt_id %#02x\n", pkt_id); return 0; } } @@ -1068,7 +1068,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) chksum += pkt_len; if ('\x10' == pkt_len) { if ('\x10' != buf[n++]) { - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Bad pkt_len %#02x\n", pkt_len); Send_NAK(); return 0; @@ -1082,7 +1082,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) break; } if (len < n + i) { - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Packet too short %zd < %zd\n", len, n + i); Send_NAK(); @@ -1093,7 +1093,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) got_dle = 0; if ('\x10' != c) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Bad DLE %#02x\n", c); return 0; } @@ -1108,7 +1108,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) /* get checksum */ if (len < n + i) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: No checksum, Packet too short %zd < %zd\n", len, n + i); return 0; @@ -1118,7 +1118,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) /* get final DLE */ if (len < n + i) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: No final DLE, Packet too short %zd < %zd\n", len, n + i); return 0; @@ -1126,13 +1126,13 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) c = buf[n + i++]; if ('\x10' != c) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, "Garmin: Final DLE not DLE\n"); + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Final DLE not DLE\n"); return 0; } /* get final ETX */ if (len < n + i) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: No final ETX, Packet too short %zd < %zd\n", len, n + i); return 0; @@ -1141,7 +1141,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) c = buf[n + i]; if ('\x03' != c) { Send_NAK(); - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Final ETX not ETX\n"); return 0; } @@ -1149,12 +1149,12 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) /* debug */ /*@ -usedef -compdef @*/ for (i = 0; i < data_index; i++) { - gpsd_report(session->context->debug, LOG_RAW + 1, + gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: Char: %#02x\n", data_buf[i]); } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: garmin_ser_parse() Type: %#02x, Len: %#02x, chksum: %#02x\n", pkt_id, pkt_len, chksum); mask = PrintSERPacket(session, pkt_id, pkt_len, data_buf); @@ -1164,7 +1164,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session) (void)usleep(300); Send_ACK(); /*@ +usedef +compdef @*/ - gpsd_report(session->context->debug, LOG_DATA, "Garmin: garmin_ser_parse( )\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: garmin_ser_parse( )\n"); return mask; } @@ -1192,11 +1192,11 @@ static void garmin_switcher(struct gps_device_t *session, int mode) ssize_t status = gpsd_write(session, switcher, sizeof(switcher)); /*@ -charint @*/ if (status == (ssize_t)sizeof(switcher)) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: => GPS: turn off binary %02x %02x %02x... \n", switcher[0], switcher[1], switcher[2]); } else { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Garmin: => GPS: FAILED\n"); } settle(); // wait 333mS, essential! @@ -1280,7 +1280,7 @@ static int GetPacket(struct gps_device_t *session) session->driver.garmin.BufferLen = 0; session->lexer.outbuflen = 0; - gpsd_report(session->context->debug, LOG_DATA, "Garmin: GetPacket()\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "Garmin: GetPacket()\n"); for (cnt = 0; cnt < 10; cnt++) { size_t pkt_size; @@ -1301,18 +1301,18 @@ static int GetPacket(struct gps_device_t *session) if (0 > theBytesReturned) { // read error... // or EAGAIN, but O_NONBLOCK is never set - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Garmin: GetPacket() read error=%d, errno=%d\n", theBytesReturned, errno); continue; } - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "Garmin: got %d bytes\n", theBytesReturned); session->driver.garmin.BufferLen += theBytesReturned; if (256 <= session->driver.garmin.BufferLen) { // really bad read error... - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Garmin: GetPacket() packet too long, %ld > 255 !\n", session->driver.garmin.BufferLen); session->driver.garmin.BufferLen = 0; @@ -1323,7 +1323,7 @@ static int GetPacket(struct gps_device_t *session) // have enough data to check packet size if (session->driver.garmin.BufferLen > pkt_size) { // wrong amount of data in buffer - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Garmin: GetPacket() packet size wrong! Packet: %ld, s/b %ld\n", session->driver.garmin.BufferLen, pkt_size); session->driver.garmin.BufferLen = 0; @@ -1345,15 +1345,15 @@ static int GetPacket(struct gps_device_t *session) } // dump the individual bytes, debug only // for ( x = 0; x < session->driver.garmin.BufferLen; x++ ) { - // gpsd_report(session->context->debug, LOG_RAW+1, "Garmin: p[%d] = %x\n", x, session->driver.garmin.Buffer[x]); + // gpsd_report(session->context->errout.debug, LOG_RAW+1, "Garmin: p[%d] = %x\n", x, session->driver.garmin.Buffer[x]); // } if (10 <= cnt) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Garmin: GetPacket() packet too long or too slow!\n"); return -1; } - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "Garmin: GotPacket() sz=%d \n", session->driver.garmin.BufferLen); session->lexer.outbuflen = session->driver.garmin.BufferLen; @@ -1362,7 +1362,7 @@ static int GetPacket(struct gps_device_t *session) static gps_mask_t garmin_usb_parse(struct gps_device_t *session) { - gpsd_report(session->context->debug, LOG_PROG, "Garmin: garmin_usb_parse()\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: garmin_usb_parse()\n"); return PrintUSBPacket(session, (Packet_t *) session->driver.garmin.Buffer); } diff --git a/driver_garmin_txt.c b/driver_garmin_txt.c index e708354a..2be5ce1a 100644 --- a/driver_garmin_txt.c +++ b/driver_garmin_txt.c @@ -127,7 +127,7 @@ invalid data. * -1: data error * -2: data not valid * - * examples with context->debug == 0: + * examples with context->errout.debug == 0: * gar_decode(context, cbuf, 9, "EW", 100000.0, &result); * E01412345 -> +14.12345 @@ -153,13 +153,13 @@ static int gar_decode(const struct gps_context_t *context, /* splint is buggy here, thinks buf can be a null pointer */ /*@ -mustdefine -nullderef -nullpass @*/ if (length >= sizeof(buf)) { - gpsd_report(context->debug, LOG_ERROR, "internal buffer too small\n"); + gpsd_report(context->errout.debug, LOG_ERROR, "internal buffer too small\n"); return -1; } bzero(buf, (int)sizeof(buf)); (void)strlcpy(buf, data, length); - gpsd_report(context->debug, LOG_RAW + 2, "Decoded string: %s\n", buf); + gpsd_report(context->errout.debug, LOG_RAW + 2, "Decoded string: %s\n", buf); if (strchr(buf, '_') != NULL) { /* value is not valid, ignore it */ @@ -186,14 +186,14 @@ static int gar_decode(const struct gps_context_t *context, break; } } - gpsd_report(context->debug, LOG_WARN, + gpsd_report(context->errout.debug, LOG_WARN, "Unexpected char \"%c\" in data \"%s\"\n", buf[0], buf); return -1; } while (0); if (strspn(buf + offset, "0123456789") != length - offset) { - gpsd_report(context->debug, LOG_WARN, "Invalid value %s\n", buf); + gpsd_report(context->errout.debug, LOG_WARN, "Invalid value %s\n", buf); return -1; } /*@ +mustdefine +nullderef +nullpass @*/ @@ -223,13 +223,13 @@ static int gar_int_decode(const struct gps_context_t *context, /*@ -mustdefine @*/ if (length >= sizeof(buf)) { - gpsd_report(context->debug, LOG_ERROR, "internal buffer too small\n"); + gpsd_report(context->errout.debug, LOG_ERROR, "internal buffer too small\n"); return -1; } bzero(buf, (int)sizeof(buf)); (void)strlcpy(buf, data, length); - gpsd_report(context->debug, LOG_RAW + 2, "Decoded string: %s\n", buf); + gpsd_report(context->errout.debug, LOG_RAW + 2, "Decoded string: %s\n", buf); if (strchr(buf, '_') != NULL) { /* value is not valid, ignore it */ @@ -238,7 +238,7 @@ static int gar_int_decode(const struct gps_context_t *context, /*@ -nullpass @*//* splint bug */ if (strspn(buf, "0123456789") != length) { - gpsd_report(context->debug, LOG_WARN, "Invalid value %s\n", buf); + gpsd_report(context->errout.debug, LOG_WARN, "Invalid value %s\n", buf); return -1; } @@ -247,7 +247,7 @@ static int gar_int_decode(const struct gps_context_t *context, *result = res; return 0; /* SUCCESS */ } else { - gpsd_report(context->debug, LOG_WARN, + gpsd_report(context->errout.debug, LOG_WARN, "Value %u out of range <%u, %u>\n", res, min, max); return -1; @@ -268,13 +268,13 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session) gps_mask_t mask = 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin Simple Text packet, len %zd: %s\n", session->lexer.outbuflen, (char*)session->lexer.outbuffer); 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, + gpsd_report(session->context->errout.debug, LOG_WARN, "Message is too short, rejected.\n"); return ONLINE_SET; } @@ -286,7 +286,7 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session) do { unsigned int result; char *buf = (char *)session->lexer.outbuffer + 1; - gpsd_report(session->context->debug, LOG_PROG, "Timestamp: %.12s\n", buf); + gpsd_report(session->context->errout.debug, LOG_PROG, "Timestamp: %.12s\n", buf); /* year */ if (0 != gar_int_decode(session->context, @@ -460,7 +460,7 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session) mask |= CLIMB_SET; } while (0); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GTXT: time=%.2f, lat=%.2f lon=%.2f alt=%.2f speed=%.2f track=%.2f climb=%.2f exp=%.2f epy=%.2f mode=%d status=%d\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, diff --git a/driver_geostar.c b/driver_geostar.c index 4632c31d..37bb17ee 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -70,7 +70,7 @@ static int geostar_write(struct gps_device_t *session, session->msgbuflen = len * 4; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Sent GeoStar packet id 0x%x\n", id); if (gpsd_write(session, session->msgbuf, session->msgbuflen) != (ssize_t) session->msgbuflen) @@ -109,7 +109,7 @@ static bool geostar_detect(struct gps_device_t *session) break; if (generic_get(session) >= 0) { if (session->lexer.type == GEOSTAR_PACKET) { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "geostar_detect found\n"); ret = true; break; @@ -134,7 +134,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) char buf2[BUFSIZ]; if (session->lexer.type != GEOSTAR_PACKET) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "geostar_analyze packet type %d\n", session->lexer.type); return 0; @@ -160,20 +160,20 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) id = (unsigned int)getleu16(session->lexer.outbuffer, OFFSET(0)); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GeoStar packet id 0x%02x length %d: %s\n", id, len, buf2); session->cycle_end_reliable = true; switch (id) { case 0x10: - gpsd_report(session->context->debug, LOG_INF, "Raw measurements\n"); + gpsd_report(session->context->errout.debug, LOG_INF, "Raw measurements\n"); break; case 0x11: - gpsd_report(session->context->debug, LOG_INF, "GPS sub-frame data\n"); + gpsd_report(session->context->errout.debug, LOG_INF, "GPS sub-frame data\n"); break; case 0x12: - gpsd_report(session->context->debug, LOG_INF, "GLONASS sub-frame data\n"); + gpsd_report(session->context->errout.debug, LOG_INF, "GLONASS sub-frame data\n"); break; case 0x13: d1 = getled64(buf, OFFSET(1)); @@ -181,7 +181,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) d3 = getled64(buf, OFFSET(5)); d4 = getled64(buf, OFFSET(29)); /* GPS time */ d5 = getled64(buf, OFFSET(31)); /* GLONASS time */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "ECEF coordinates %g %g %g %f %f\n", d1, d2, d3, d4, d5); break; case 0x20: @@ -214,7 +214,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) } mask |= TIME_SET | PPSTIME_IS | LATLON_SET | ALTITUDE_SET | SPEED_SET | TRACK_SET | DOP_SET | USED_IS | REPORT_IS; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Geographic coordinates %f %g %g %g %g %g\n", d1, session->newdata.latitude, @@ -222,7 +222,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) session->newdata.altitude, session->newdata.speed, session->newdata.track); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Dilution of precision %g %g %g %g %g\n", session->gpsdata.dop.gdop, session->gpsdata.dop.pdop, @@ -235,7 +235,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) ul2 = getleu32(buf, OFFSET(2)); uw1 = getleu16(buf, OFFSET(3)); uw2 = getleu16(buf, OFFSET(3) + 2); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Current receiver telemetry %x %d %d %d\n", ul1, ul2, uw1, uw2); if(ul1 & (1<<3)) { @@ -256,7 +256,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) break; case 0x22: ul1 = getleu32(buf, OFFSET(1)); - gpsd_report(session->context->debug, LOG_INF, "SVs in view %d\n", ul1); + gpsd_report(session->context->errout.debug, LOG_INF, "SVs in view %d\n", ul1); session->gpsdata.satellites_visible = (int)ul1; if(ul1 > GEOSTAR_CHANNELS) ul1 = GEOSTAR_CHANNELS; for(i = 0, j = 0; (uint32_t)i < ul1; i++) { @@ -264,7 +264,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) s1 = getles16(buf, OFFSET(3) + i * 3 * 4); s2 = getles16(buf, OFFSET(3) + 2 + i * 3 * 4); s3 = getles16(buf, OFFSET(4) + 2 + i * 3 * 4); - gpsd_report(session->context->debug, LOG_INF, "ID %d Az %g El %g SNR %g\n", + gpsd_report(session->context->errout.debug, LOG_INF, "ID %d Az %g El %g SNR %g\n", decode_channel_id(ul2), s1*0.001*RAD_2_DEG, s2*0.001*RAD_2_DEG, s3*0.1); session->gpsdata.PRN[i] = decode_channel_id(ul2); session->gpsdata.azimuth[i] = (int)round((double)s1*0.001 * RAD_2_DEG); @@ -281,57 +281,57 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) ul1 = getleu32(buf, OFFSET(1)); ul2 = getleu32(buf, OFFSET(2)); ul3 = getleu32(buf, OFFSET(3)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Receiver power-up message %d %d %d\n", ul1, ul2, ul3); break; case 0x3f: ul1 = getleu32(buf, OFFSET(1)); ul2 = getleu32(buf, OFFSET(2)); - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Negative acknowledge %x %d\n", ul1, ul2); break; case 0x40: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set initial parameters\n"); break; case 0x41: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set serial ports parameters\n"); break; case 0x42: ul1 = getleu32(buf, OFFSET(1)); ul2 = getleu32(buf, OFFSET(2)); ul3 = getleu32(buf, OFFSET(3)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set receiver operation mode %d %d %d\n", ul1, ul2, ul3); break; case 0x43: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set navigation task solution parameters\n"); break; case 0x44: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set output data rate\n"); break; case 0x46: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Assign data protocol to communication port\n"); break; case 0x48: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set GPS almanac\n"); break; case 0x49: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set GLONASS almanac\n"); break; case 0x4a: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set GPS ephemeris\n"); break; case 0x4b: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set GLONASS ephemeris\n"); break; case 0x4c: @@ -340,74 +340,74 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) ul3 = getleu32(buf, OFFSET(3)); ul4 = getleu32(buf, OFFSET(4)); ul5 = getleu32(buf, OFFSET(5)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Set PPS parameters %d %d %d %d %d\n", ul1, ul2, ul3, ul4, ul5); break; case 0x4d: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Enable/disable SV in position fix\n"); break; case 0x4e: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Enable/disable NMEA messages\n"); break; case 0x4f: ul1 = getleu32(buf, OFFSET(1)); ul2 = getleu32(buf, OFFSET(2)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Enable/disable binary messages %x %x\n", ul1, ul2); break; case 0x80: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query initial parameters\n"); break; case 0x81: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query serial ports parameters\n"); break; case 0x82: ul1 = getleu32(buf, OFFSET(1)); ul2 = getleu32(buf, OFFSET(2)); ul3 = getleu32(buf, OFFSET(3)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query receiver operation mode %d %d %d\n", ul1, ul2, ul3); break; case 0x83: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query navigation task solution parameters\n"); break; case 0x84: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query output data rate\n"); break; case 0x86: session->driver.geostar.physical_port = (unsigned int)getleu32(buf, OFFSET(1)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query data protocol assignment to communication port\n"); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Connected to physical port %d\n", session->driver.geostar.physical_port); break; case 0x88: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query GPS almanac\n"); break; case 0x89: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query GLONASS almanac\n"); break; case 0x8a: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query GPS ephemerides\n"); break; case 0x8b: d1 = getled64(buf, OFFSET(23)); d2 = getled64(buf, OFFSET(25)); d3 = getled64(buf, OFFSET(27)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query GLONASS ephemerides %g %g %g\n", d1, d2, d3); break; @@ -417,27 +417,27 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) ul3 = getleu32(buf, OFFSET(3)); ul4 = getleu32(buf, OFFSET(4)); ul5 = getleu32(buf, OFFSET(5)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query PPS parameters %d %d %d %d %d\n", ul1, ul2, ul3, ul4, ul5); break; case 0x8d: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query enable/disable status of the SV in position fix\n"); break; case 0x8e: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query enable NMEA messages\n"); break; case 0x8f: ul1 = getleu32(buf, OFFSET(1)); ul2 = getleu32(buf, OFFSET(2)); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Query enable binary messages %x %x\n", ul1, ul2); break; case 0xc0: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Change operation mode command\n"); break; case 0xc1: @@ -449,33 +449,33 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) (void)snprintf(session->subtype, sizeof(session->subtype), "%d.%d %d.%d.%d %x %c-%d\n", ul4>>16, ul4&0xFFFF, ul1>>9, (ul1>>5)&0xF, ul1&0x1F, ul2, ul3>>24, ul3&0x00FFFFFF); /*@ +formattype @*/ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Request FW version command: %s\n", session->subtype); mask |= DEVICEID_SET; break; case 0xc2: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Restart receiver command\n"); break; case 0xc3: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Store parameters to Flash command\n"); break; case 0xd0: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Erase Flash sector command\n"); break; case 0xd1: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Write data to Flash command\n"); break; case 0xd2: - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Response to Store Serial Number command\n"); break; default: - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Unhandled GeoStar packet type 0x%02x\n", id); break; } @@ -602,7 +602,7 @@ static void geostar_mode(struct gps_device_t *session, int mode) /* Switch to binary mode */ (void)nmea_send(session, "$GPSGG,SWPROT"); } else { - gpsd_report(session->context->debug, LOG_ERROR, "unknown mode %i requested\n", mode); + gpsd_report(session->context->errout.debug, LOG_ERROR, "unknown mode %i requested\n", mode); } /*@+shiftimplementation@*/ } diff --git a/driver_italk.c b/driver_italk.c index 76f24a3e..59a95ee9 100644 --- a/driver_italk.c +++ b/driver_italk.c @@ -41,7 +41,7 @@ static gps_mask_t decode_itk_navfix(struct gps_device_t *session, double epx, epy, epz, evx, evy, evz, eph; if (len != 296) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "ITALK: bad NAV_FIX (len %zu, should be 296)\n", len); return -1; @@ -106,7 +106,7 @@ static gps_mask_t decode_itk_navfix(struct gps_device_t *session, session->gpsdata.status = STATUS_FIX; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NAV_FIX: time=%.2f, lat=%.2f lon=%.2f alt=%.f speed=%.2f track=%.2f climb=%.2f mode=%d status=%d gdop=%.2f pdop=%.2f hdop=%.2f vdop=%.2f tdop=%.2f\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, @@ -124,7 +124,7 @@ static gps_mask_t decode_itk_prnstatus(struct gps_device_t *session, gps_mask_t mask; if (len < 62) { - gpsd_report(session->context->debug, LOG_PROG, "ITALK: runt PRN_STATUS (len=%zu)\n", len); + gpsd_report(session->context->errout.debug, LOG_PROG, "ITALK: runt PRN_STATUS (len=%zu)\n", len); mask = 0; } else { unsigned int i, nsv, nchan, st; @@ -156,7 +156,7 @@ static gps_mask_t decode_itk_prnstatus(struct gps_device_t *session, session->gpsdata.satellites_used = (int)nsv; mask = USED_IS | SATELLITE_SET;; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "PRN_STATUS: time=%.2f visible=%d used=%d mask={USED|SATELLITE}\n", session->newdata.time, session->gpsdata.satellites_visible, @@ -173,7 +173,7 @@ static gps_mask_t decode_itk_utcionomodel(struct gps_device_t *session, unsigned short flags; if (len != 64) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "ITALK: bad UTC_IONO_MODEL (len %zu, should be 64)\n", len); return 0; @@ -190,7 +190,7 @@ static gps_mask_t decode_itk_utcionomodel(struct gps_device_t *session, session->newdata.time = gpsd_gpstime_resolve(session, (unsigned short) getleu16(buf, 7 + 36), (unsigned int)getleu32(buf, 7 + 38) / 1000.0); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "UTC_IONO_MODEL: time=%.2f mask={TIME}\n", session->newdata.time); return TIME_SET | PPSTIME_IS; @@ -204,7 +204,7 @@ static gps_mask_t decode_itk_subframe(struct gps_device_t *session, uint32_t words[10]; if (len != 64) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "ITALK: bad SUBFRAME (len %zu, should be 64)\n", len); return 0; } @@ -212,7 +212,7 @@ static gps_mask_t decode_itk_subframe(struct gps_device_t *session, flags = (unsigned short) getleu16(buf, 7 + 4); prn = (unsigned short) getleu16(buf, 7 + 6); sf = (unsigned short) getleu16(buf, 7 + 8); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "iTalk 50B SUBFRAME prn %u sf %u - decode %s %s\n", prn, sf, flags & SUBFRAME_WORD_FLAG_MASK ? "error" : "ok", @@ -237,17 +237,17 @@ static gps_mask_t decode_itk_pseudo(struct gps_device_t *session, n = (unsigned short) getleu16(buf, 7 + 4); if ((n < 1) || (n > MAXCHANNELS)){ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "ITALK: bad PSEUDO channel count\n"); return 0; } if (len != (size_t)((n+1)*36)) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "ITALK: bad PSEUDO len %zu\n", len); } - gpsd_report(session->context->debug, LOG_PROG, "iTalk PSEUDO [%u]\n", n); + gpsd_report(session->context->errout.debug, LOG_PROG, "iTalk PSEUDO [%u]\n", n); flags = (unsigned short)getleu16(buf, 7 + 6); if ((flags & 0x3) != 0x3) return 0; // bail if measurement time not valid. @@ -285,54 +285,54 @@ static gps_mask_t italk_parse(struct gps_device_t *session, type = (uint) getub(buf, 4); /* we may need to dump the raw packet */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "raw italk packet type 0x%02x\n", type); session->cycle_end_reliable = true; switch (type) { case ITALK_NAV_FIX: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk NAV_FIX len %zu\n", len); mask = decode_itk_navfix(session, buf, len) | (CLEAR_IS | REPORT_IS); break; case ITALK_PRN_STATUS: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk PRN_STATUS len %zu\n", len); mask = decode_itk_prnstatus(session, buf, len); break; case ITALK_UTC_IONO_MODEL: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk UTC_IONO_MODEL len %zu\n", len); mask = decode_itk_utcionomodel(session, buf, len); break; case ITALK_ACQ_DATA: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk ACQ_DATA len %zu\n", len); break; case ITALK_TRACK: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk TRACK len %zu\n", len); break; case ITALK_PSEUDO: - gpsd_report(session->context->debug, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk PSEUDO len %zu\n", len); mask = decode_itk_pseudo(session, buf, len); break; case ITALK_RAW_ALMANAC: - gpsd_report(session->context->debug, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk RAW_ALMANAC len %zu\n", len); break; case ITALK_RAW_EPHEMERIS: - gpsd_report(session->context->debug, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk RAW_EPHEMERIS len %zu\n", len); break; case ITALK_SUBFRAME: mask = decode_itk_subframe(session, buf, len); break; case ITALK_BIT_STREAM: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk BIT_STREAM len %zu\n", len); break; @@ -367,12 +367,12 @@ static gps_mask_t italk_parse(struct gps_device_t *session, case ITALK_PULL_FIX: case ITALK_MEMCTRL: case ITALK_STOP_TASK: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk not processing packet: id 0x%02x length %zu\n", type, len); break; default: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "iTalk unknown packet: id 0x%02x length %zu\n", type, len); } diff --git a/driver_navcom.c b/driver_navcom.c index 783f459d..2317fbe5 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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: sent command 0x3f (LED Configuration Block)\n"); } @@ -148,9 +148,9 @@ 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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: sent command 0x1c (Test Support Block)\n"); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: command 0x1c mode = %02x, length = %u\n", mode, length); } @@ -175,9 +175,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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: sent command 0x11 (Serial Port Configuration)\n"); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: serial port selection: 0x%02x\n", port_selection); } #endif /* RECONFIGURE_ENABLE */ @@ -276,27 +276,27 @@ static gps_mask_t handle_0x83(struct gps_device_t *session) } /*@ -relaxtypes -charint @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0x83 (Ionosphere and UTC Data)\n"); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: Scaled parameters follow:\n"); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: GPS Week: %u, GPS Time of Week: %u (GPS Time: %f)\n", week, tow, week * 604800 + tow / 1000.0); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: A0: %19.12E, A1: %19.12E\n", (double)a0 * SF_A0, (double)a1 * SF_A1); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: UTC Ref. Time: %lu, UTC Ref. Week: %u, dTls: %d\n", (unsigned long)tot * SF_TOT, wnt, dtls); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: Week of leap seconds: %u, Day number of leap seconds: %u, dTlsf: %d\n", wnlsf, dn, dtlsf); @@ -322,10 +322,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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0x06 (Acknowledgement (without error))\n"); /*@ -type @*/ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: acknowledged command id 0x%02x on port %c\n", cmd_id, (port == 0 ? 'A' : (port == 1 ? 'B' : '?'))); /*@ +type @*/ @@ -340,17 +340,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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: error id = 0x%02x, error description = 0x%02x\n", err_id, err_desc); } port = getub(buf, n); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: negative acknowledge was for command id 0x%02x on port %c\n", cmd_id, (port == 0 ? 'A' : (port == 1 ? 'B' : '?'))); /*@ -type @*/ @@ -494,19 +494,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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0xb1 (PVT Report)\n"); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: latitude = %f, longitude = %f, altitude = %f, geoid = %f\n", session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, session->gpsdata.separation); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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); @@ -521,7 +521,7 @@ 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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.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 " @@ -647,41 +647,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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0x81 (Packed Ephemeris Data)\n"); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: SV accuracy: 0x%x, SV health: 0x%x, TGD: %f, IODC (!AODC): %u\n", ura, svh, (double)tgd * SF_TGD, iodc); - gpsd_report(session->context->debug, LOG_DATA, "Navcom: Transmission time: %u\n", tow); + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: Transmission time: %u\n", tow); #undef SF_TGD #undef SF_TOC @@ -750,7 +750,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) } /*@ -predboolothers @*/ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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); @@ -760,7 +760,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(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Navcom: packet type 0x86: too many satellites!\n"); gpsd_zero_satellites(&session->gpsdata); return 0; @@ -789,12 +789,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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: sol. valid = %c, clock = %s, pos. = %s, " "height = %s, err. code = 0x%x\n", (sol_status & 0x01 ? 'Y' : 'N'), @@ -805,7 +805,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) /*@ +predboolothers -charint @*/ } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "CS 0x86: visible=%d, used=%d, mask={SATELLITE|STATUS}\n", session->gpsdata.satellites_visible, session->gpsdata.satellites_used); @@ -828,10 +828,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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0xb0 (Raw Meas. Data Block)\n"); /*@ -predboolothers @*/ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: week = %u, tow = %.3f, time slew accumulator = %u (1/1023mS), status = 0x%02x " "(%sclock %s - %u blocks follow)\n", session->context->gps_week, @@ -869,17 +869,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(session->context->debug, LOG_DATA + 1, + gpsd_report(session->context->errout.debug, LOG_DATA + 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(session->context->debug, LOG_DATA + 1, + gpsd_report(session->context->errout.debug, LOG_DATA + 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(session->context->debug, LOG_DATA + 1, + gpsd_report(session->context->errout.debug, LOG_DATA + 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 @*/ @@ -920,15 +920,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(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0xb5 (Pseudorange Noise Statistics)\n"); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "Navcom: epe = %f\n", session->gpsdata.epe); return mask; } else { /* Ignore this message block */ if (!session->driver.navcom.warned) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Navcom: received packet type 0xb5 (Pseudorange Noise Statistics) ignored " " - sizeof(double) == 64 bits required\n"); session->driver.navcom.warned = true; @@ -1051,16 +1051,16 @@ static gps_mask_t handle_0xae(struct gps_device_t *session) asicstr = "?"; } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0xae (Identification Block)\n"); if (msg_len == 0x0037) { - gpsd_report(session->context->debug, LOG_INF, "Navcom: ID Data: " + gpsd_report(session->context->errout.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(session->context->debug, LOG_INF, "Navcom: ID Data: " + gpsd_report(session->context->errout.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", @@ -1104,13 +1104,13 @@ static gps_mask_t handle_0xef(struct gps_device_t *session) osc_filter_drift_est = NAN; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "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(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "CDO 0xef: time=%.2f mask={TIME}\n", session->newdata.time); return 0; } @@ -1131,7 +1131,7 @@ gps_mask_t navcom_parse(struct gps_device_t * session, unsigned char *buf, msg_len = (uint) getleu16(buf, 4); /*@ -usedef -compdef @*/ - gpsd_report(session->context->debug, LOG_RAW, "Navcom: packet type 0x%02x\n", cmd_id); + gpsd_report(session->context->errout.debug, LOG_RAW, "Navcom: packet type 0x%02x\n", cmd_id); /*@ +usedef +compdef @*/ session->cycle_end_reliable = true; @@ -1160,7 +1160,7 @@ gps_mask_t navcom_parse(struct gps_device_t * session, unsigned char *buf, case 0xef: return handle_0xef(session); default: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Navcom: received packet type 0x%02x, length %d - unknown or unimplemented\n", cmd_id, msg_len); return 0; diff --git a/driver_nmea0183.c b/driver_nmea0183.c index 27fe1abb..c1a2eff1 100644 --- a/driver_nmea0183.c +++ b/driver_nmea0183.c @@ -82,13 +82,13 @@ static void merge_ddmmyy(char *ddmmyy, struct gps_device_t *session) year = (session->context->century + yy); if ( (1 > mon ) || (12 < mon ) ) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "merge_ddmmyy(%s), malformed month\n", ddmmyy); } else if ( (1 > mday ) || (31 < mday ) ) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "merge_ddmmyy(%s), malformed day\n", ddmmyy); } else { - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "merge_ddmmyy(%s) sets year %d\n", ddmmyy, year); session->nmea.date.tm_year = year - 1900; @@ -119,7 +119,7 @@ static void register_fractional_time(const char *tag, const char *fld, session->nmea.this_frac_time; session->nmea.this_frac_time = safe_atof(fld); session->nmea.latch_frac_time = true; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "%s: registers fractional time %.2f\n", tag, session->nmea.this_frac_time); } @@ -210,7 +210,7 @@ static gps_mask_t processRMC(int count, char *field[], } } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "RMC: ddmmyy=%s hhmmss=%s lat=%.2f lon=%.2f " "speed=%.2f track=%.2f mode=%d status=%d\n", field[9], field[1], @@ -266,7 +266,7 @@ static gps_mask_t processGLL(int count, char *field[], merge_hhmmss(field[5], session); register_fractional_time(field[0], field[5], session); if (session->nmea.date.tm_year == 0) - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "can't use GLL time until after ZDA or RMC has supplied a year.\n"); else { mask = TIME_SET; @@ -296,7 +296,7 @@ static gps_mask_t processGLL(int count, char *field[], mask |= STATUS_SET; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GLL: hhmmss=%s lat=%.2f lon=%.2f mode=%d status=%d\n", field[5], session->newdata.latitude, @@ -356,7 +356,7 @@ static gps_mask_t processGGA(int c UNUSED, char *field[], merge_hhmmss(field[1], session); register_fractional_time(field[0], field[1], session); if (session->nmea.date.tm_year == 0) - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "can't use GGA time until after ZDA or RMC has supplied a year.\n"); else { mask |= TIME_SET; @@ -398,7 +398,7 @@ static gps_mask_t processGGA(int c UNUSED, char *field[], session->newdata.longitude); } } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GGA: hhmmss=%s lat=%.2f lon=%.2f alt=%.2f mode=%d status=%d\n", field[1], session->newdata.latitude, @@ -441,7 +441,7 @@ static gps_mask_t processGST(int count, char *field[], struct gps_device_t *sess #undef PARSE_FIELD register_fractional_time(field[0], field[1], session); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GST: utc = %.2f, rms = %.2f, maj = %.2f, min = %.2f, ori = %.2f, lat = %.2f, lon = %.2f, alt = %.2f\n", session->gpsdata.gst.utctime, session->gpsdata.gst.rms_deviation, @@ -482,7 +482,7 @@ static gps_mask_t processGSA(int count, char *field[], * Alarmingly, it's possible this error may be generic to SiRFstarIII. */ if (count < 17) { - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GPGSA: malformed, setting ONLINE_SET only.\n"); mask = ONLINE_SET; } else if (session->nmea.latch_mode) { @@ -500,7 +500,7 @@ static gps_mask_t processGSA(int count, char *field[], mask = 0; else mask = MODE_SET; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "GPGSA sets mode %d\n", session->newdata.mode); session->gpsdata.dop.pdop = safe_atof(field[15]); session->gpsdata.dop.hdop = safe_atof(field[16]); @@ -515,7 +515,7 @@ static gps_mask_t processGSA(int count, char *field[], prn; } mask |= DOP_SET | USED_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GPGSA: mode=%d used=%d pdop=%.2f hdop=%.2f vdop=%.2f\n", session->newdata.mode, session->gpsdata.satellites_used, @@ -549,7 +549,7 @@ static gps_mask_t processGSV(int count, char *field[], */ int n, fldnum; if (count <= 3) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "malformed GPGSV - fieldcount %d <= 3\n", count); gpsd_zero_satellites(&session->gpsdata); @@ -557,7 +557,7 @@ static gps_mask_t processGSV(int count, char *field[], return ONLINE_SET; } if (count % 4 != 0) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "malformed GPGSV - fieldcount %d %% 4 != 0\n", count); gpsd_zero_satellites(&session->gpsdata); @@ -567,7 +567,7 @@ static gps_mask_t processGSV(int count, char *field[], session->nmea.await = atoi(field[1]); if ((session->nmea.part = atoi(field[2])) < 1) { - gpsd_report(session->context->debug, LOG_WARN, "malformed GPGSV - bad part\n"); + gpsd_report(session->context->errout.debug, LOG_WARN, "malformed GPGSV - bad part\n"); gpsd_zero_satellites(&session->gpsdata); return ONLINE_SET; } else if (session->nmea.part == 1) { @@ -583,7 +583,7 @@ static gps_mask_t processGSV(int count, char *field[], for (fldnum = 4; fldnum < count;) { if (session->gpsdata.satellites_visible >= MAXCHANNELS) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "internal error - too many satellites [%d]!\n", session->gpsdata.satellites_visible); gpsd_zero_satellites(&session->gpsdata); @@ -612,13 +612,13 @@ static gps_mask_t processGSV(int count, char *field[], } if (session->nmea.part == session->nmea.await && atoi(field[3]) != session->gpsdata.satellites_visible) - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "GPGSV field 3 value of %d != actual count %d\n", atoi(field[3]), session->gpsdata.satellites_visible); /* not valid data until we've seen a complete set of parts */ if (session->nmea.part < session->nmea.await) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Partial satellite data (%d of %d).\n", session->nmea.part, session->nmea.await); return ONLINE_SET; @@ -634,14 +634,14 @@ static gps_mask_t processGSV(int count, char *field[], for (n = 0; n < session->gpsdata.satellites_visible; n++) if (session->gpsdata.azimuth[n] != 0) goto sane; - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Satellite data no good (%d of %d).\n", session->nmea.part, session->nmea.await); gpsd_zero_satellites(&session->gpsdata); return ONLINE_SET; sane: session->gpsdata.skyview_time = NAN; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GSV: Satellite data OK (%d of %d).\n", session->nmea.part, session->nmea.await); @@ -688,7 +688,7 @@ static gps_mask_t processPGRME(int c UNUSED, char *field[], mask = HERR_SET | VERR_SET | PERR_IS; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "PGRME: epx=%.2f epy=%.2f epv=%.2f\n", session->newdata.epx, session->newdata.epy, @@ -723,14 +723,14 @@ static gps_mask_t processGBS(int c UNUSED, char *field[], session->newdata.epy = safe_atof(field[2]); session->newdata.epx = safe_atof(field[3]); session->newdata.epv = safe_atof(field[4]); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GBS: epx=%.2f epy=%.2f epv=%.2f\n", session->newdata.epx, session->newdata.epy, session->newdata.epv); return HERR_SET | VERR_SET; } else { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "second in $GPGBS error estimates doesn't match.\n"); return 0; } @@ -758,7 +758,7 @@ static gps_mask_t processZDA(int c UNUSED, char *field[], if (field[1][0] == '\0' || field[2][0] == '\0' || field[3][0] == '\0' || field[4][0] == '\0') { - gpsd_report(session->context->debug, LOG_WARN, "ZDA fields are empty\n"); + gpsd_report(session->context->errout.debug, LOG_WARN, "ZDA fields are empty\n"); } else { int year, mon, mday, century; @@ -774,13 +774,13 @@ static gps_mask_t processZDA(int c UNUSED, char *field[], mday = atoi(field[2]); century = year - year % 100; if ( (1900 > year ) || (2200 < year ) ) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "malformed ZDA year: %s\n", field[4]); } else if ( (1 > mon ) || (12 < mon ) ) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "malformed ZDA month: %s\n", field[3]); } else if ( (1 > mday ) || (31 < mday ) ) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "malformed ZDA day: %s\n", field[2]); } else { gpsd_century_update(session, century); @@ -831,7 +831,7 @@ static gps_mask_t processHDT(int c UNUSED, char *field[], session->gpsdata.attitude.depth = NAN; mask |= (ATTITUDE_SET); - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "time %.3f, heading %lf.\n", session->newdata.time, session->gpsdata.attitude.heading); @@ -879,7 +879,7 @@ static gps_mask_t processDBT(int c UNUSED, char *field[], * no better place to put it. Should work in practice as nobody is * likely to be operating a depth sounder at varying altitudes. */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "mode %d, depth %lf.\n", session->newdata.mode, session->newdata.altitude); @@ -946,7 +946,7 @@ static gps_mask_t processTNTHTM(int c UNUSED, char *field[], session->gpsdata.attitude.depth = NAN; mask |= (ATTITUDE_SET); - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "time %.3f, heading %lf (%c).\n", session->newdata.time, session->gpsdata.attitude.heading, @@ -1005,7 +1005,7 @@ static gps_mask_t processOHPR(int c UNUSED, char *field[], session->gpsdata.attitude.gyro_y = safe_atof(field[16]); mask |= (ATTITUDE_SET); - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "Heading %lf.\n", session->gpsdata.attitude.heading); return mask; } @@ -1021,7 +1021,7 @@ static gps_mask_t processPASHR(int c UNUSED, char *field[], if (0 == strcmp("RID", field[1])) { /* Receiver ID */ (void)snprintf(session->subtype, sizeof(session->subtype) - 1, "%s ver %s", field[2], field[3]); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "PASHR,RID: subtype=%s mask={}\n", session->subtype); return mask; @@ -1054,7 +1054,7 @@ static gps_mask_t processPASHR(int c UNUSED, char *field[], mask |= (TIME_SET | LATLON_SET | ALTITUDE_SET); mask |= (SPEED_SET | TRACK_SET | CLIMB_SET); mask |= DOP_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "PASHR,POS: hhmmss=%s lat=%.2f lon=%.2f alt=%.f speed=%.2f track=%.2f climb=%.2f mode=%d status=%d pdop=%.2f hdop=%.2f vdop=%.2f tdop=%.2f\n", field[4], session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, @@ -1078,7 +1078,7 @@ static gps_mask_t processPASHR(int c UNUSED, char *field[], session->gpsdata.used[u++] = p; } session->gpsdata.satellites_used = u; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "PASHR,SAT: used=%d\n", session->gpsdata.satellites_used); session->gpsdata.skyview_time = NAN; @@ -1155,7 +1155,7 @@ static gps_mask_t processMTK3301(int c UNUSED, char *field[], case 001: /* ACK / NACK */ reason = atoi(field[2]); if (atoi(field[1]) == -1) - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "MTK NACK: unknown sentence\n"); else if (reason < 3) { const char *mtk_reasons[] = { @@ -1164,13 +1164,13 @@ static gps_mask_t processMTK3301(int c UNUSED, char *field[], "Valid but Failed", "Valid success" }; - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "MTK NACK: %s, reason: %s\n", field[1], mtk_reasons[reason]); } else - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "MTK ACK: %s\n", field[1]); return ONLINE_SET; default: @@ -1260,7 +1260,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) * packets. This may be a generic bug of all Garmin chipsets. */ if (strlen(sentence) > NMEA_MAX) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Overlong packet of %zd chars rejected.\n", strlen(sentence)); return ONLINE_SET; @@ -1341,7 +1341,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) * WARNING: This assumes time is always field 0, and that field 0 * is a timestamp whenever TIME_SET is set. */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "%s time is %2f = %d-%02d-%02dT%02d:%02d:%02.2fZ\n", session->nmea.field[0], session->newdata.time, 1900 + session->nmea.date.tm_year, @@ -1371,7 +1371,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) * mid-cycle, as in the Garmin eXplorist 210; those might jitter. */ if (session->nmea.latch_frac_time) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "%s sentence timestamped %.2f.\n", session->nmea.field[0], session->nmea.this_frac_time); @@ -1380,7 +1380,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) session->nmea.last_frac_time)) { uint lasttag = session->nmea.lasttag; retval |= CLEAR_IS; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "%s starts a reporting cycle.\n", session->nmea.field[0]); /* @@ -1393,7 +1393,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) && (session->nmea.cycle_enders & (1 << lasttag)) == 0 && !session->nmea.cycle_continue) { session->nmea.cycle_enders |= (1 << lasttag); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "tagged %s as a cycle ender.\n", nmea_phrase[lasttag - 1].name); } @@ -1401,11 +1401,11 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) } else { /* extend the cycle to an un-timestamped sentence? */ if ((session->nmea.lasttag & session->nmea.cycle_enders) != 0) - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "%s is just after a cycle ender.\n", session->nmea.field[0]); if (session->nmea.cycle_continue) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "%s extends the reporting cycle.\n", session->nmea.field[0]); session->nmea.cycle_enders &=~ (1 << session->nmea.lasttag); @@ -1415,7 +1415,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) /* here's where we check for end-of-cycle */ if ((session->nmea.latch_frac_time || session->nmea.cycle_continue) && (session->nmea.cycle_enders & (1 << thistag))!=0) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "%s ends a reporting cycle.\n", session->nmea.field[0]); retval |= REPORT_IS; diff --git a/driver_nmea2000.c b/driver_nmea2000.c index 6203c5fb..8d05edbc 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -73,7 +73,7 @@ static void print_data(struct gps_context_t *context, ptr += l2; for (l1=0;l1<len;l1++) { if (((l1 % 20) == 0) && (l1 != 0)) { - gpsd_report(context->debug, LOG_IO,"%s\n", bu); + gpsd_report(context->errout.debug, LOG_IO,"%s\n", bu); ptr = 0; l2 = sprintf(&bu[ptr], " : "); ptr += l2; @@ -81,7 +81,7 @@ static void print_data(struct gps_context_t *context, l2 = sprintf(&bu[ptr], "%02ux ", (unsigned int)buffer[l1]); ptr += l2; } - gpsd_report(context->debug, LOG_IO,"%s\n", bu); + gpsd_report(context->errout.debug, LOG_IO,"%s\n", bu); } /*@+bufferoverflowhigh@*/ #endif @@ -111,7 +111,7 @@ static int decode_ais_header(struct gps_context_t *context, ais->repeat = (unsigned int) ((bu[0] >> 6) & 0x03); ais->mmsi = (unsigned int) getleu32(bu, 1); ais->mmsi &= mask; - gpsd_report(context->debug, LOG_INF, + gpsd_report(context->errout.debug, LOG_INF, "NMEA2000 AIS message type %u, MMSI %09d:\n", ais->type, ais->mmsi); printf("NMEA2000 AIS message type %2u, MMSI %09u:\n", @@ -121,7 +121,7 @@ static int decode_ais_header(struct gps_context_t *context, ais->type = 0; ais->repeat = 0; ais->mmsi = 0; - gpsd_report(context->debug, LOG_ERROR, + gpsd_report(context->errout.debug, LOG_ERROR, "NMEA2000 AIS message type %u, too short message.\n", ais->type); printf("NMEA2000 AIS message type %u, too short message.\n", @@ -184,7 +184,7 @@ static double ais_direction(unsigned int val, double scale) static gps_mask_t hnd_059392(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -196,7 +196,7 @@ static gps_mask_t hnd_059392(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_060928(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -208,7 +208,7 @@ static gps_mask_t hnd_060928(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_126208(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -220,7 +220,7 @@ static gps_mask_t hnd_126208(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_126464(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -232,7 +232,7 @@ static gps_mask_t hnd_126464(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_126996(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -244,7 +244,7 @@ static gps_mask_t hnd_126996(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_127258(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -256,7 +256,7 @@ static gps_mask_t hnd_127258(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_129025(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); /*@-type@*//* splint has a bug here */ @@ -274,7 +274,7 @@ static gps_mask_t hnd_129025(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_129026(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); session->driver.nmea2000.sid[0] = bu[0]; @@ -297,7 +297,7 @@ static gps_mask_t hnd_126992(unsigned char *bu, int len, PGN *pgn, struct gps_de //uint8_t source; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); //sid = bu[0]; @@ -324,7 +324,7 @@ static gps_mask_t hnd_129539(unsigned char *bu, int len, PGN *pgn, struct gps_de unsigned int act_mode; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); mask = 0; @@ -349,7 +349,7 @@ static gps_mask_t hnd_129539(unsigned char *bu, int len, PGN *pgn, struct gps_de /*@+type@*/ mask |= DOP_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d): sid:%02x hdop:%5.2f vdop:%5.2f tdop:%5.2f\n", pgn->pgn, session->driver.nmea2000.unit, @@ -370,7 +370,7 @@ static gps_mask_t hnd_129540(unsigned char *bu, int len, PGN *pgn, struct gps_de int l1, l2; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); session->driver.nmea2000.sid[2] = bu[0]; @@ -414,7 +414,7 @@ static gps_mask_t hnd_129029(unsigned char *bu, int len, PGN *pgn, struct gps_de gps_mask_t mask; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); mask = 0; @@ -484,7 +484,7 @@ static gps_mask_t hnd_129038(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) { @@ -517,7 +517,7 @@ static gps_mask_t hnd_129039(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) { @@ -556,7 +556,7 @@ static gps_mask_t hnd_129040(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) { @@ -614,7 +614,7 @@ static gps_mask_t hnd_129794(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) { @@ -711,7 +711,7 @@ static gps_mask_t hnd_129798(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) { @@ -746,7 +746,7 @@ static gps_mask_t hnd_129802(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0x3fffffff) != 0) { @@ -774,7 +774,7 @@ static gps_mask_t hnd_129809(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) { @@ -782,7 +782,7 @@ static gps_mask_t hnd_129809(unsigned char *bu, int len, PGN *pgn, struct gps_de int index = session->driver.aivdm.context[0].type24_queue.index; struct ais_type24a_t *saveptr = &session->driver.aivdm.context[0].type24_queue.ships[index]; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "NMEA2000: AIS message 24A from %09u stashed.\n", ais->mmsi); @@ -817,7 +817,7 @@ static gps_mask_t hnd_129810(unsigned char *bu, int len, PGN *pgn, struct gps_de ais = &session->gpsdata.ais; print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) { @@ -865,7 +865,7 @@ static gps_mask_t hnd_129810(unsigned char *bu, int len, PGN *pgn, struct gps_de } ais->type24.shipname[AIS_SHIPNAME_MAXLEN] = (char) 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "NMEA2000: AIS 24B from %09u matches a 24A.\n", ais->mmsi); /* prevent false match if a 24B is repeated */ @@ -911,7 +911,7 @@ static gps_mask_t hnd_129810(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_127506(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -923,7 +923,7 @@ static gps_mask_t hnd_127506(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_127508(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -935,7 +935,7 @@ static gps_mask_t hnd_127508(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_127513(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -947,7 +947,7 @@ static gps_mask_t hnd_127513(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_127245(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -997,7 +997,7 @@ static gps_mask_t hnd_127250(unsigned char *bu, int len, PGN *pgn, struct gps_de session->gpsdata.attitude.temp = NAN; session->gpsdata.attitude.depth = NAN; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(ONLINE_SET | ATTITUDE_SET); } @@ -1009,7 +1009,7 @@ static gps_mask_t hnd_127250(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_128259(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1043,7 +1043,7 @@ static gps_mask_t hnd_128267(unsigned char *bu, int len, PGN *pgn, struct gps_de session->gpsdata.attitude.temp = NAN; /*@i@*/session->gpsdata.attitude.depth = getleu32(bu, 1) *.01; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(ONLINE_SET | ATTITUDE_SET); } @@ -1055,7 +1055,7 @@ static gps_mask_t hnd_128267(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_128275(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1067,7 +1067,7 @@ static gps_mask_t hnd_128275(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_129283(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1079,7 +1079,7 @@ static gps_mask_t hnd_129283(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_129284(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1091,7 +1091,7 @@ static gps_mask_t hnd_129284(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_129285(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1103,7 +1103,7 @@ static gps_mask_t hnd_129285(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_130306(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1115,7 +1115,7 @@ static gps_mask_t hnd_130306(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_130310(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1127,7 +1127,7 @@ static gps_mask_t hnd_130310(unsigned char *bu, int len, PGN *pgn, struct gps_de static gps_mask_t hnd_130311(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session) { print_data(session->context, bu, len, pgn); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); return(0); } @@ -1272,7 +1272,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) session->driver.nmea2000.workpgn = NULL; can_net = session->driver.nmea2000.can_net; if (can_net > (NMEA2000_NETS-1)) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 find_pgn: Invalid can network %d.\n", can_net); return; } @@ -1378,7 +1378,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) if (work->fast == 0) { size_t l2; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d:%s \n", work->pgn, work->name); session->driver.nmea2000.workpgn = (void *) work; /*@i1@*/session->lexer.outbuflen = frame->can_dlc & 0x0f; @@ -1392,7 +1392,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) /*@i2@*/session->driver.nmea2000.fast_packet_len = frame->data[1]; /*@i2@*/session->driver.nmea2000.idx = frame->data[0]; #if NMEA2000_FAST_DEBUG - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Set idx %2x %2x %2x %6d\n", frame->data[0], session->driver.nmea2000.unit, @@ -1404,7 +1404,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) for (l2=2;l2<8;l2++) { /*@i3@*/session->lexer.inbuffer[session->lexer.inbuflen++] = frame->data[l2]; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "pgn %6d:%s \n", work->pgn, work->name); } /*@i2@*/else if (frame->data[0] == session->driver.nmea2000.idx) { @@ -1417,7 +1417,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) } if (session->lexer.inbuflen == session->driver.nmea2000.fast_packet_len) { #if NMEA2000_FAST_DEBUG - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Fast done %2x %2x %2x %2x %6d\n", session->driver.nmea2000.idx, /*@i1@*/frame->data[0], @@ -1435,7 +1435,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) session->driver.nmea2000.idx += 1; } } else { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Fast error %2x %2x %2x %2x %6d\n", session->driver.nmea2000.idx, /*@i2@*/frame->data[0], @@ -1444,7 +1444,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) source_pgn); } } else { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "PGN not found %08d %08x \n", source_pgn, source_pgn); } @@ -1539,7 +1539,7 @@ int nmea2000_open(struct gps_device_t *session) } if (unit_ptr != NULL) { if (isdigit(interface_name[l]) == 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: Invalid character in unit number.\n"); return -1; } @@ -1549,7 +1549,7 @@ int nmea2000_open(struct gps_device_t *session) if (unit_ptr != NULL) { unit_number = atoi(unit_ptr); if ((unit_number < 0) || (unit_number > (NMEA2000_UNITS-1))) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: Unit number out of range.\n"); return -1; } @@ -1562,7 +1562,7 @@ int nmea2000_open(struct gps_device_t *session) } } if (can_net < 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: CAN device not open: %s .\n", interface_name); return -1; } @@ -1571,7 +1571,7 @@ int nmea2000_open(struct gps_device_t *session) if (strncmp(can_interface_name[l], interface_name, MIN(sizeof(interface_name), sizeof(can_interface_name[l]))) == 0) { - gpsd_report(session->context->debug, LOG_ERROR, "NMEA2000 open: CAN device duplicate open: %s .\n", interface_name); + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: CAN device duplicate open: %s .\n", interface_name); return -1; } } @@ -1582,7 +1582,7 @@ int nmea2000_open(struct gps_device_t *session) } } if (can_net < 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: Too many CAN networks open.\n"); return -1; } @@ -1592,14 +1592,14 @@ int nmea2000_open(struct gps_device_t *session) sock = socket(PF_CAN, SOCK_RAW, CAN_RAW); if (BAD_SOCKET(sock)) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: can not get socket.\n"); return -1; } status = fcntl(sock, F_SETFL, O_NONBLOCK); if (status != 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: can not set socket to O_NONBLOCK.\n"); close(sock); return -1; @@ -1611,7 +1611,7 @@ int nmea2000_open(struct gps_device_t *session) * with that device's index */ if (status != 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: can not find CAN device.\n"); close(sock); return -1; @@ -1622,7 +1622,7 @@ int nmea2000_open(struct gps_device_t *session) addr.can_ifindex = ifr.ifr_ifindex; status = bind(sock, (struct sockaddr*)&addr, sizeof(addr) ); if (status != 0) { - gpsd_report(session->context->debug, LOG_ERROR, "NMEA2000 open: bind failed.\n"); + gpsd_report(session->context->errout.debug, LOG_ERROR, "NMEA2000 open: bind failed.\n"); close(sock); return -1; } @@ -1656,7 +1656,7 @@ int nmea2000_open(struct gps_device_t *session) void nmea2000_close(struct gps_device_t *session) { if (!BAD_SOCKET(session->gpsdata.gps_fd)) { - gpsd_report(session->context->debug, LOG_SPIN, + gpsd_report(session->context->errout.debug, LOG_SPIN, "close(%d) in nmea2000_close(%s)\n", session->gpsdata.gps_fd, session->gpsdata.dev.path); (void)close(session->gpsdata.gps_fd); diff --git a/driver_oncore.c b/driver_oncore.c index a6d33b43..5724033d 100644 --- a/driver_oncore.c +++ b/driver_oncore.c @@ -75,7 +75,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, return 0; mask = ONLINE_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore NAVSOL - navigation data\n"); flags = (unsigned char)getub(buf, 72); @@ -88,7 +88,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, session->gpsdata.status = STATUS_FIX; session->newdata.mode = MODE_2D; } else { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "oncore NAVSOL no fix - flags 0x%02x\n", flags); session->newdata.mode = MODE_NO_FIX; session->gpsdata.status = STATUS_NO_FIX; @@ -114,7 +114,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, session->newdata.time = (timestamp_t)timegm(&unpacked_date) + nsec * 1e-9; /*@ +unrecog */ mask |= TIME_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore NAVSOL - time: %04d-%02d-%02d %02d:%02d:%02d.%09d\n", unpacked_date.tm_year + 1900, unpacked_date.tm_mon + 1, unpacked_date.tm_mday, unpacked_date.tm_hour, @@ -130,7 +130,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, dop = getbeu16(buf, 35) / 10.0f; /*@+type@*/ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore NAVSOL - %lf %lf %.2lfm-%.2lfm | %.2fm/s %.1fdeg dop=%.1f\n", lat, lon, alt, wgs84_separation(lat, lon), speed, track, (float)dop); @@ -160,7 +160,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, sn = (int)getub(buf, off + 2); status = (int)getub(buf, off + 3); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "%2d %2d %2d %3d %02x\n", i, sv, mode, sn, status); if (sn) { @@ -215,7 +215,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, (void)oncore_control_send(session, (char *)pollBo, sizeof(pollBo)); (void)oncore_control_send(session, (char *)pollEn, sizeof(pollEn)); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NAVSOL: time=%.2f lat=%.2f lon=%.2f alt=%.2f speed=%.2f track=%.2f mode=%d status=%d visible=%d used=%d\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, @@ -238,7 +238,7 @@ oncore_msg_utc_offset(struct gps_device_t *session, unsigned char *buf, if (data_len != 8) return 0; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore UTCTIME - leap seconds\n"); utc_offset = (int)getub(buf, 4); if (utc_offset == 0) @@ -261,7 +261,7 @@ oncore_msg_pps_offset(struct gps_device_t *session, unsigned char *buf, if (data_len != 11) return 0; - gpsd_report(session->context->debug, LOG_DATA, "oncore PPS offset\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore PPS offset\n"); pps_offset_ns = (int)getbes32(buf, 4); session->driver.oncore.pps_offset_ns = pps_offset_ns; @@ -281,10 +281,10 @@ oncore_msg_svinfo(struct gps_device_t *session, unsigned char *buf, if (data_len != 92) return 0; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore SVINFO - satellite data\n"); nchan = (unsigned int)getub(buf, 4); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore SVINFO - %d satellites:\n", nchan); /* Then we clamp the value to not read outside the table. */ if (nchan > 12) @@ -298,7 +298,7 @@ oncore_msg_svinfo(struct gps_device_t *session, unsigned char *buf, int el = (int)getub(buf, off + 3); int az = (int)getbeu16(buf, off + 4); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "%2d %2d %2d %3d\n", i, sv, el, az); /* Store for use when Ea messages come. */ @@ -313,7 +313,7 @@ oncore_msg_svinfo(struct gps_device_t *session, unsigned char *buf, } } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SVINFO: mask={SATELLITE}\n"); return SATELLITE_SET; } @@ -331,7 +331,7 @@ oncore_msg_time_raim(struct gps_device_t *session UNUSED, return 0; sawtooth_ns = (int)getub(buf, 25); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "oncore PPS sawtooth: %d\n",sawtooth_ns); /* session->driver.oncore.traim_sawtooth_ns = sawtooth_ns; */ @@ -366,7 +366,7 @@ gps_mask_t oncore_dispatch(struct gps_device_t * session, unsigned char *buf, type = ONCTYPE(buf[2], buf[3]); /* we may need to dump the raw packet */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "raw Oncore packet type 0x%04x\n", type); session->cycle_end_reliable = true; @@ -391,7 +391,7 @@ gps_mask_t oncore_dispatch(struct gps_device_t * session, unsigned char *buf, default: /* FIX-ME: This gets noisy in a hurry. Change once your driver works */ - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "unknown packet id @@%c%c length %zd\n", type >> 8, type & 0xff, len); return 0; @@ -426,7 +426,7 @@ static ssize_t oncore_control_send(struct gps_device_t *session, session->msgbuf[msglen + 4] = '\n'; session->msgbuflen = msglen + 5; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "writing oncore control type %c%c\n", msg[0], msg[1]); return gpsd_write(session, session->msgbuf, session->msgbuflen); } diff --git a/driver_proto.c b/driver_proto.c index c215d376..b5d9aff0 100644 --- a/driver_proto.c +++ b/driver_proto.c @@ -72,7 +72,7 @@ _proto__msg_navsol(struct gps_device_t *session, unsigned char *buf, size_t data if (data_len != _PROTO__NAVSOL_MSG_LEN) return 0; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "_proto_ NAVSOL - navigation data\n"); /* if this protocol has a way to test message validity, use it */ flags = GET_FLAGS(); @@ -121,7 +121,7 @@ _proto__msg_navsol(struct gps_device_t *session, unsigned char *buf, size_t data * the fields it potentially set and the transfer mask. Doing this * makes it relatively easy to track down data-management problems. */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NAVSOL: time=%.2f, lat=%.2f lon=%.2f alt=%.2f mode=%d status=%d\n", session->newdata.time, session->newdata.latitude, @@ -144,7 +144,7 @@ _proto__msg_utctime(struct gps_device_t *session, unsigned char *buf, size_t dat if (data_len != UTCTIME_MSG_LEN) return 0; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "_proto_ UTCTIME - navigation data\n"); /* if this protocol has a way to test message validity, use it */ flags = GET_FLAGS(); @@ -171,7 +171,7 @@ _proto__msg_svinfo(struct gps_device_t *session, unsigned char *buf, size_t data if (data_len != SVINFO_MSG_LEN ) return 0; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "_proto_ SVINFO - navigation data\n"); /* if this protocol has a way to test message validity, use it */ flags = GET_FLAGS(); @@ -187,7 +187,7 @@ _proto__msg_svinfo(struct gps_device_t *session, unsigned char *buf, size_t data */ nchan = GET_NUMBER_OF_CHANNELS(); if ((nchan < 1) || (nchan > MAXCHANNELS)) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "too many channels reported\n"); return 0; } @@ -212,7 +212,7 @@ _proto__msg_svinfo(struct gps_device_t *session, unsigned char *buf, size_t data session->gpsdata.skyview_time = NaN; session->gpsdata.satellites_used = nsv; session->gpsdata.satellites_visible = st; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SVINFO: visible=%d used=%d mask={SATELLITE|USED}\n", session->gpsdata.satellites_visible, session->gpsdata.satellites_used); @@ -231,7 +231,7 @@ _proto__msg_raw(struct gps_device_t *session, unsigned char *buf, size_t data_le if (data_len != RAW_MSG_LEN ) return 0; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "_proto_ RAW - raw measurements\n"); /* if this protocol has a way to test message validity, use it */ flags = GET_FLAGS(); @@ -247,7 +247,7 @@ _proto__msg_raw(struct gps_device_t *session, unsigned char *buf, size_t data_le */ nchan = GET_NUMBER_OF_CHANNELS(); if ((nchan < 1) || (nchan > MAXCHANNELS)) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "too many channels reported\n"); return 0; } @@ -292,7 +292,7 @@ gps_mask_t _proto__dispatch(struct gps_device_t *session, unsigned char *buf, si type = GET_MESSAGE_TYPE(); /* we may need to dump the raw packet */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "raw _proto_ packet type 0x%02x\n", type); switch (type) @@ -300,7 +300,7 @@ gps_mask_t _proto__dispatch(struct gps_device_t *session, unsigned char *buf, si /* Deliver message to specific decoder based on message type */ default: - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "unknown packet id %d length %d\n", type, len); return 0; } @@ -351,7 +351,7 @@ static ssize_t _proto__control_send(struct gps_device_t *session, /* we may need to dump the message */ return gpsd_write(session, session->msgbuf, session->msgbuflen); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "writing _proto_ control type %02x\n"); return gpsd_write(session, session->msgbuf, session->msgbuflen); } diff --git a/driver_rtcm3.c b/driver_rtcm3.c index 5b9c9009..c8109dfe 100644 --- a/driver_rtcm3.c +++ b/driver_rtcm3.c @@ -97,7 +97,7 @@ void rtcm3_unpack(const struct gps_context_t *context, rtcm->length = (uint)ugrab(10); rtcm->type = (uint)ugrab(12); - gpsd_report(context->debug, LOG_RAW, "RTCM3: type %d payload length %d\n", + gpsd_report(context->errout.debug, LOG_RAW, "RTCM3: type %d payload length %d\n", rtcm->type, rtcm->length); switch (rtcm->type) { diff --git a/driver_sirf.c b/driver_sirf.c index 2f1d299c..a81295dd 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -248,7 +248,7 @@ static bool sirf_write(struct gps_device_t *session, unsigned char *msg) */ /* can also be false because ACK was received after last send */ if (session->driver.sirf.need_ack > 0) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "SiRF: warning, write of control type %02x while awaiting ACK for %02x.\n", type, session->driver.sirf.need_ack); } @@ -265,7 +265,7 @@ static bool sirf_write(struct gps_device_t *session, unsigned char *msg) msg[len + 4] = (unsigned char)((crc & 0xff00) >> 8); msg[len + 5] = (unsigned char)(crc & 0x00ff); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Writing control type %02x:\n", type); ok = (gpsd_write(session, (const char *)msg, len+8) == (ssize_t) (len+8)); @@ -313,11 +313,11 @@ static bool sirfbin_speed(struct gps_device_t *session, speed_t speed, char pari 0x00, 0x00, 0xb0, 0xb3 }; /*@ -charint @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: sirf_speed(%u,%c,%d)\n", (unsigned int)speed, parity, stopbits); if (9600 >= speed) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "SiRF may lag at 9600bps or less.\n"); } @@ -368,7 +368,7 @@ static bool sirf_to_nmea(struct gps_device_t *session, speed_t speed) /*@ -charint @*/ if (speed >= 0xffff) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "SiRF: can't switch from SiRF to NMEA because current speed %u is big.", (unsigned int)speed); return false; @@ -424,7 +424,7 @@ static gps_mask_t sirf_msg_debug(struct gps_device_t *device, (void)snprintf(msgbuf + strlen(msgbuf), sizeof(msgbuf) - strlen(msgbuf), "%c", buf[i] ^ 0xff); - gpsd_report(device->context->debug, LOG_PROG, + gpsd_report(device->context->errout.debug, LOG_PROG, "SiRF: DEV 0xe1: %s\n", msgbuf); } else if (0xff == (unsigned char)buf[0]) { /* Debug messages */ for (i = 1; i < (int)len; i++) @@ -435,7 +435,7 @@ static gps_mask_t sirf_msg_debug(struct gps_device_t *device, (void)snprintf(msgbuf + strlen(msgbuf), sizeof(msgbuf) - strlen(msgbuf), "\\x%02x", (unsigned int)buf[i]); - gpsd_report(device->context->debug, LOG_PROG, + gpsd_report(device->context->errout.debug, LOG_PROG, "SiRF: DBG 0xff: %s\n", msgbuf); } /*@ -charint @*/ @@ -448,18 +448,18 @@ static gps_mask_t sirf_msg_errors(struct gps_device_t *device, { switch (getbeu16(buf, 1)) { case 2: - gpsd_report(device->context->debug, LOG_PROG, + gpsd_report(device->context->errout.debug, LOG_PROG, "SiRF: EID 0x0a type 2: Subframe %u error on PRN %u\n", getbeu32(buf, 9), getbeu32(buf, 5)); break; case 4107: - gpsd_report(device->context->debug, LOG_PROG, + gpsd_report(device->context->errout.debug, LOG_PROG, "SiRF: EID 0x0a type 4107: neither KF nor LSQ fix.\n"); break; default: - gpsd_report(device->context->debug, LOG_PROG, + gpsd_report(device->context->errout.debug, LOG_PROG, "SiRF: EID 0x0a: Error MID %d\n", getbeu16(buf, 1)); break; @@ -481,7 +481,7 @@ static gps_mask_t sirf_msg_nlmd(struct gps_device_t *session, * different double orders, neither IEEE754 */ /* FIXME - decode the time, since this is the first MID with a * good time stamp this will be good for ntpshm time */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: MID 0x1c, NLMD, gps_tow: %f\n", (double)gps_tow); @@ -514,15 +514,15 @@ static gps_mask_t sirf_msg_swversion(struct gps_device_t *session, session->driver.sirf.driverstate |= SIRF_GE_232; } if (strstr((char *)(buf + 1), "ES")) - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "SiRF: Firmware has XTrac capability\n"); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: fv: %0.2f, Driver state flags are: %0x\n", fv, session->driver.sirf.driverstate); #ifdef TIMEHINT_ENABLE session->driver.sirf.time_seen = 0; #endif /* TIMEHINT_ENABLE */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SiRF: FV MID 0x06: subtype='%s' mask={DEVICEID}\n", session->subtype); return DEVICEID_SET; @@ -544,14 +544,14 @@ static gps_mask_t sirf_msg_navdata(struct gps_device_t *session, words[i] = (uint32_t)getbeu32(buf, 4 * i + 3); } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SiRF: NavData chan %u svid %u\n",chan,svid); #ifdef RECONFIGURE_ENABLE /* SiRF recommends at least 57600 for SiRF IV nav data */ if (!session->context->readonly && session->gpsdata.dev.baudrate < 57600) { /* some USB are also too slow, no way to tell which ones */ - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "WARNING: SiRF: link too slow, disabling subframes.\n"); (void)sirf_write(session, disablesubframe); } @@ -593,7 +593,7 @@ static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session, session->gpsdata.azimuth[st] != 0 && session->gpsdata.elevation[st] != 0; #ifdef __UNUSED__ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: PRN=%2d El=%3.2f Az=%3.2f ss=%3d stat=%04x %c\n", getub(buf, off), getub(buf, off + 2) / 2.0, @@ -614,18 +614,18 @@ static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session, } #ifdef TIMEHINT_ENABLE if (st < 3) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD not enough satellites seen: %d\n", st); } else { /* SiRF says if 3 sats in view the time is good */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD valid time MID 0x04, seen=0x%02x, time:%.2lf, leap:%d\n", session->driver.sirf.time_seen, session->gpsdata.skyview_time, session->context->leap_seconds); } #endif /* TIMEHINT_ENABLE */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SiRF: MTD 0x04: visible=%d mask={SATELLITE}\n", session->gpsdata.satellites_visible); return SATELLITE_SET; @@ -723,7 +723,7 @@ static gps_mask_t sirf_msg_navsol(struct gps_device_t *session, session->newdata.mode = MODE_2D; if (session->newdata.mode == MODE_3D) mask |= ALTITUDE_SET | CLIMB_SET; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: MND 0x02: Navtype = 0x%0x, Status = %d, mode = %d\n", navtype, session->gpsdata.status, session->newdata.mode); /* byte 20 is HDOP, see below */ @@ -732,11 +732,11 @@ static gps_mask_t sirf_msg_navsol(struct gps_device_t *session, (unsigned short)getbes16(buf, 22), (double)getbeu32(buf, 24) * 1e-2); #ifdef TIMEHINT_ENABLE if (session->newdata.mode <= MODE_NO_FIX) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD no fix, mode: %d\n", session->newdata.mode); } else { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD valid time MID 0x02, seen=0x%02x, time;%.2lf, leap:%d\n", session->driver.sirf.time_seen, session->newdata.time, session->context->leap_seconds); @@ -750,7 +750,7 @@ static gps_mask_t sirf_msg_navsol(struct gps_device_t *session, if ( 3 <= session->gpsdata.satellites_visible ) { mask |= PPSTIME_IS; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SiRF: MND 0x02: time=%.2f lat=%.2f lon=%.2f alt=%.2f track=%.2f speed=%.2f mode=%d status=%d hdop=%.2f used=%d\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, @@ -809,7 +809,7 @@ static gps_mask_t sirf_msg_geodetic(struct gps_device_t *session, session->newdata.mode = MODE_3D; else if (session->gpsdata.status) session->newdata.mode = MODE_2D; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: GND 0x29: Navtype = 0x%0x, Status = %d, mode = %d\n", navtype, session->gpsdata.status, session->newdata.mode); mask |= STATUS_SET | MODE_SET; @@ -877,20 +877,20 @@ static gps_mask_t sirf_msg_geodetic(struct gps_device_t *session, /*@ -compdef -unrecog */ session->newdata.time = (timestamp_t)timegm(&unpacked_date) + subseconds; /*@ +compdef +unrecog */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: GND 0x29 UTC: %lf\n", session->newdata.time); #ifdef TIMEHINT_ENABLE if (session->newdata.mode <= MODE_NO_FIX) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD no fix, mode: $d\n", session->newdata.mode); } else if (0 == unpacked_date.tm_year) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD no year\n", session->newdata.mode); } else { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD valid time MID 0x29, seen=0x%02x\n", session->driver.sirf.time_seen); } @@ -910,7 +910,7 @@ static gps_mask_t sirf_msg_geodetic(struct gps_device_t *session, if (session->newdata.mode == MODE_3D) mask |= ALTITUDE_SET | CLIMB_SET; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SiRF: GND 0x29: time=%.2f lat=%.2f lon=%.2f alt=%.2f track=%.2f speed=%.2f mode=%d status=%d\n", session->newdata.time, session->newdata.latitude, @@ -985,7 +985,7 @@ static gps_mask_t sirf_msg_ublox(struct gps_device_t *session, session->newdata.mode = MODE_3D; else if (session->gpsdata.status) session->newdata.mode = MODE_2D; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: EMND 0x62: Navtype = 0x%0x, Status = %d, mode = %d\n", navtype, session->gpsdata.status, session->newdata.mode); @@ -1008,10 +1008,10 @@ static gps_mask_t sirf_msg_ublox(struct gps_device_t *session, /*@ +compdef */ #ifdef TIMEHINT_ENABLE if (0 == (session->driver.sirf.time_seen & TIME_SEEN_UTC_2)) { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "SiRF: NTPD just SEEN_UTC_2\n"); } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD valid time MID 0x62, seen=0x%02x\n", session->driver.sirf.time_seen); session->driver.sirf.time_seen |= TIME_SEEN_UTC_2; @@ -1025,7 +1025,7 @@ static gps_mask_t sirf_msg_ublox(struct gps_device_t *session, session->gpsdata.dop.vdop = (int)getub(buf, 37) / 5.0; session->gpsdata.dop.tdop = (int)getub(buf, 38) / 5.0; session->driver.sirf.driverstate |= UBLOX; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SiRF: EMD 0x62: time=%.2f lat=%.2f lon=%.2f alt=%.f speed=%.2f track=%.2f climb=%.2f mode=%d status=%d gdop=%.2f pdop=%.2f hdop=%.2f vdop=%.2f tdop=%.2f\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, @@ -1045,7 +1045,7 @@ static gps_mask_t sirf_msg_ppstime(struct gps_device_t *session, if (len != 19) return 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: PPS 0x34: Status = 0x%02x\n", getub(buf, 14)); if (((int)getub(buf, 14) & 0x07) == 0x07) { /* valid UTC time? */ @@ -1063,10 +1063,10 @@ static gps_mask_t sirf_msg_ppstime(struct gps_device_t *session, session->context->valid |= LEAP_SECOND_VALID; #ifdef TIMEHINT_ENABLE if (0 == (session->driver.sirf.time_seen & TIME_SEEN_UTC_2)) { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "SiRF: NTPD just SEEN_UTC_2\n"); } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NTPD valid time MID 0x34, seen=0x%02x, leap=%d\n", session->driver.sirf.time_seen, session->context->leap_seconds); @@ -1089,47 +1089,47 @@ static gps_mask_t sirf_msg_nl(struct gps_device_t *session, switch ( buf[1] ) { case 1: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 1, GPS Data\n"); break; case 2: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 2, EE Integrity\n"); break; case 3: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 3, EE Integrity\n"); break; case 4: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 4, EE Clock Bias\n"); break; case 5: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 4, 50bps\n"); break; case 32: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 4, ECLM ACK/NACK\n"); break; case 33: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 4, ECLM EE Age\n"); break; case 34: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 4, ECLM SGEE Age\n"); break; case 35: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 4, ECLM Download Intiate\n"); break; case 255: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, SubID: 4, EE ACK\n"); break; default: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused EE 0x38, unknown SubID: %d\n", buf[1]); } @@ -1146,16 +1146,16 @@ static gps_mask_t sirf_msg_ee(struct gps_device_t *session, switch ( buf[1] ) { case 1: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused NL 0x40, SubID: 1\n"); break; case 2: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused NL 0x40, SubID: 2, PRN: %d\n", buf[2]); break; default: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused NL 0x40, unknown SubID: %d\n", buf[1]); } @@ -1173,7 +1173,7 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, buf += 4; len -= 8; - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "SiRF: Raw packet type 0x%02x\n", buf[0]); session->driver.sirf.lastid = buf[0]; @@ -1186,7 +1186,7 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return sirf_msg_navsol(session, buf, len) | (CLEAR_IS | REPORT_IS); else { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: MND 0x02 skipped, u-blox flag is on.\n"); return 0; } @@ -1194,7 +1194,7 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return sirf_msg_svinfo(session, buf, len); case 0x05: /* Raw Tracker Data Out MID 5 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: unused Raw Tracker Data 0x05\n"); return 0; @@ -1202,7 +1202,7 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return sirf_msg_swversion(session, buf, len); case 0x07: /* Clock Status Data MID 7 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused CLK 0x07\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused CLK 0x07\n"); return 0; case 0x08: /* subframe data MID 8 */ @@ -1220,7 +1220,7 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return sirf_msg_navdata(session, buf, len); case 0x09: /* CPU Throughput MID 9 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: THR 0x09: SegStatMax=%.3f, SegStatLat=%3.f, AveTrkTime=%.3f, Last MS=%u\n", (float)getbeu16(buf, 1) / 186, (float)getbeu16(buf, 3) / 186, @@ -1231,36 +1231,36 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return sirf_msg_errors(session, buf, len); case 0x0b: /* Command Acknowledgement MID 11 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: ACK 0x0b: %02x\n", getub(buf, 1)); session->driver.sirf.need_ack = 0; return 0; case 0x0c: /* Command NAcknowledgement MID 12 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: NAK 0x0c: %02x\n", getub(buf, 1)); /* ugh -- there's no alternative but silent failure here */ session->driver.sirf.need_ack = 0; return 0; case 0x0d: /* Visible List MID 13 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused VIS 0x0d\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused VIS 0x0d\n"); return 0; case 0x0e: /* Almanac Data MID 14 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused ALM 0x0e\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused ALM 0x0e\n"); return 0; case 0x0f: /* Ephemeris Data MID 15 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused EPH 0x0f\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused EPH 0x0f\n"); return 0; case 0x11: /* Differential Corrections MID 17 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused DIFF 0x11\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused DIFF 0x11\n"); return 0; case 0x12: /* OK To Send MID 18 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: OTS 0x12: send indicator = %d\n", getub(buf, 1)); return 0; @@ -1275,23 +1275,23 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return sirf_msg_nlmd(session, buf, len); case 0x1d: /* Navigation Library DGPS Data MID 29 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused NLDG 0x1d\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused NLDG 0x1d\n"); return 0; case 0x1e: /* Navigation Library SV State Data MID 30 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused NLSV 0x1e\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused NLSV 0x1e\n"); return 0; case 0x1f: /* Navigation Library Initialization Data MID 31 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused NLID 0x1f\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused NLID 0x1f\n"); return 0; case 0x29: /* Geodetic Navigation Data MID 41 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused GND 0x29\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused GND 0x29\n"); return 0; case 0x32: /* SBAS corrections MID 50 */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unused SBAS 0x32\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unused SBAS 0x32\n"); return 0; case 0x34: /* PPS Time MID 52 */ @@ -1325,28 +1325,28 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return sirf_msg_nl(session, buf, len); case 0x47: /* Hardware Config MID 71 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused Hardware Config 0x47\n"); return 0; case 0x5c: /* CW Controller Output MID 92 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused CW Controller Output 0x5c\n"); return 0; case 0x5d: /* TCXO Output MID 93 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF IV: unused TCXO Output 0x5d, SubID: %d\n", buf[1]); return 0; case 0x62: /* u-blox Extended Measured Navigation Data MID 98 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: u-blox EMND 0x62\n"); return sirf_msg_ublox(session, buf, len) | (CLEAR_IS | REPORT_IS); case 0x80: /* Initialize Data Source MID 128 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: unused INIT 0x80\n"); return 0; @@ -1357,7 +1357,7 @@ gps_mask_t sirf_parse(struct gps_device_t * session, unsigned char *buf, return 0; default: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Unknown packet id %d length %zd\n", buf[0], len); return 0; @@ -1379,7 +1379,7 @@ static gps_mask_t sirfbin_parse_input(struct gps_device_t *session) static void sirfbin_init_query(struct gps_device_t *session) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Probing for firmware version.\n"); (void)sirf_write(session, versionprobe); } @@ -1391,7 +1391,7 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) if (event == event_identified || event == event_reactivate) { if (session->lexer.type == NMEA_PACKET) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Switching chip mode to binary.\n"); (void)nmea_send(session, "$PSRF100,0,%d,8,1,0", @@ -1414,7 +1414,7 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) case 1: #ifdef RECONFIGURE_ENABLE /* unset MID 0x40 = 64 first since there is a flood of them */ - gpsd_report(session->context->debug, LOG_PROG,"SiRF: unset MID 64.\n"); + gpsd_report(session->context->errout.debug, LOG_PROG,"SiRF: unset MID 64.\n"); putbyte(unsetmidXX, 6, 0x40); (void)sirf_write(session, unsetmidXX); break; @@ -1424,14 +1424,14 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) * The response to this request will save the navigation * parameters so they can be reverted before close. */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Requesting navigation parameters.\n"); (void)sirf_write(session, navparams); break; case 3: /* unset GND (0x29 = 41), it's not reliable on SiRF II */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: unset MID 64.\n"); putbyte(unsetmidXX, 6, 0x29); (void)sirf_write(session, unsetmidXX); @@ -1439,38 +1439,38 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) case 4: if (!session->context->readonly) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Setting Navigation Parameters.\n"); (void)sirf_write(session, modecontrol); } break; case 5: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Requesting periodic ecef reports.\n"); (void)sirf_write(session, requestecef); break; case 6: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Requesting periodic tracker reports.\n"); (void)sirf_write(session, requesttracker); break; case 7: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Setting DGPS control to use SBAS.\n"); (void)sirf_write(session, dgpscontrol); break; case 8: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Setting SBAS to auto/integrity mode.\n"); (void)sirf_write(session, sbasparams); break; case 9: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Enabling PPS message.\n"); (void)sirf_write(session, enablemid52); break; @@ -1479,12 +1479,12 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) /* SiRF recommends at least 57600 for SiRF IV nav data */ if (session->gpsdata.dev.baudrate >= 57600) { /* fast enough, turn on nav data */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Enabling subframe transmission.\n"); (void)sirf_write(session, enablesubframe); } else { /* too slow, turn off nav data */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Disabling subframe transmission.\n"); (void)sirf_write(session, disablesubframe); } @@ -1495,7 +1495,7 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) * Disable navigation debug messages (the value 5 is magic) * must be done *after* subframe enable. */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: disable MID 7, 28, 29, 30, 31.\n"); putbyte(unsetmidXX, 5, 0x05); (void)sirf_write(session, unsetmidXX); @@ -1534,7 +1534,7 @@ static void sirfbin_event_hook(struct gps_device_t *session, event_t event) putbyte(moderevert, 16, session->driver.sirf.dr_timeout); putbyte(moderevert, 17, session->driver.sirf.track_smooth_mode); /*@ +shiftimplementation @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "SiRF: Reverting navigation parameters...\n"); (void)sirf_write(session, moderevert); } diff --git a/driver_superstar2.c b/driver_superstar2.c index 51a06044..fa636aa2 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -54,7 +54,7 @@ superstar2_msg_ack(struct gps_device_t *session, unsigned char *buf, size_t data_len) { if (data_len == 11) - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #126 - " "ACK %d %d %d %d %d\n", buf[5], buf[6], buf[7], buf[8], buf[9]); @@ -80,7 +80,7 @@ superstar2_msg_navsol_lla(struct gps_device_t *session, if (data_len != 77) return 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #20 - user navigation data\n"); mask = 0; @@ -142,7 +142,7 @@ superstar2_msg_navsol_lla(struct gps_device_t *session, } mask |= MODE_SET | STATUS_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NAVSOL_LLA: time=%.2f lat=%.2f lon=%.2f alt=%.2f track=%.2f speed=%.2f climb=%.2f mode=%d status=%d hdop=%.2f hdop=%.2f used=%d\n", session->newdata.time, session->newdata.latitude, @@ -171,7 +171,7 @@ superstar2_msg_svinfo(struct gps_device_t *session, if (data_len != 67) return 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #33 - satellite data\n"); nchan = 12; @@ -201,7 +201,7 @@ superstar2_msg_svinfo(struct gps_device_t *session, session->gpsdata.skyview_time = NAN; session->gpsdata.satellites_used = nsv; session->gpsdata.satellites_visible = st; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SVINFO: visible=%d used=%d mask={SATELLITE|USED}\n", session->gpsdata.satellites_visible, session->gpsdata.satellites_used); @@ -226,12 +226,12 @@ superstar2_msg_version(struct gps_device_t *session, (void)snprintf(boot_sw, 15, "%s", (char *)buf + 36); (void)snprintf(ser_num, 14, "%s", (char *)buf + 73); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #45 - " "hw part %s boot sw %s main sw %s ser num %s\n", hw_part, boot_sw, main_sw, ser_num); (void)strlcpy(session->subtype, main_sw, sizeof(session->subtype)); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "VERSION: subtype='%s' mask={DEVEICEID}\n", session->subtype); return DEVICEID_SET; @@ -250,7 +250,7 @@ superstar2_msg_timing(struct gps_device_t *session, unsigned char *buf, if (data_len != 65) return 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #113 - timing status\n"); /*@ +charint @*/ if ((getub(buf, 55) & 0x30) != 0) @@ -272,7 +272,7 @@ superstar2_msg_timing(struct gps_device_t *session, unsigned char *buf, session->context->leap_seconds = (int)getsb(buf, 20); mask = TIME_SET | PPSTIME_IS; } - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "TIMING: time=%.2f mask={TIME}\n", session->newdata.time); return mask; @@ -289,12 +289,12 @@ superstar2_msg_measurement(struct gps_device_t *session, unsigned char *buf, int i, n; double t; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #23 - measurement block\n"); n = (int)getub(buf, 6); /* number of measurements */ if ((n < 1) || (n > MAXCHANNELS)) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "too many measurements\n"); return 0; } @@ -335,7 +335,7 @@ superstar2_msg_iono_utc(struct gps_device_t *session, unsigned char *buf, i = (unsigned int)getub(buf, 12); u = (unsigned int)getub(buf, 21); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #75 - ionospheric & utc data: iono %s utc %s\n", i ? "ok" : "bad", u ? "ok" : "bad"); session->driver.superstar2.last_iono = time(NULL); @@ -353,7 +353,7 @@ superstar2_msg_ephemeris(struct gps_device_t *session, unsigned char *buf, { unsigned int prn; prn = (unsigned int)(getub(buf, 4) & 0x1f); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "superstar2 #22 - ephemeris data - prn %u\n", prn); /* ephemeris data updates fairly slowly, but when it does, poll UTC */ @@ -376,7 +376,7 @@ superstar2_write(struct gps_device_t *session, char *msg, size_t msglen) c += 0x100; msg[(int)msg[3] + 4] = (char)((c >> 8) & 0xff); msg[(int)msg[3] + 5] = (char)(c & 0xff); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "writing superstar2 control type %d len %zu\n", (int)msg[1] & 0x7f, msglen); return gpsd_write(session, msg, msglen); @@ -417,7 +417,7 @@ superstar2_dispatch(struct gps_device_t * session, unsigned char *buf, return superstar2_msg_ephemeris(session, buf, len); default: - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "unknown superstar2 packet id 0x%02x length %zd\n", type, len); return 0; diff --git a/driver_tsip.c b/driver_tsip.c index c2a5f7df..544afcc3 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -57,7 +57,7 @@ static int tsip_write(struct gps_device_t *session, *ep++ = '\x03'; session->msgbuflen = (size_t) (ep - session->msgbuf); /*@ -charint @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Sent TSIP packet id 0x%02x\n", id); if (gpsd_write(session, session->msgbuf, session->msgbuflen) != (ssize_t) session->msgbuflen) @@ -106,7 +106,7 @@ static bool tsip_detect(struct gps_device_t *session) break; if (generic_get(session) >= 0) { if (session->lexer.type == TSIP_PACKET) { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "tsip_detect found\n"); ret = true; break; @@ -138,7 +138,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) char buf2[BUFSIZ]; if (session->lexer.type != TSIP_PACKET) { - gpsd_report(session->context->debug, LOG_INF, "tsip_analyze packet type %d\n", + gpsd_report(session->context->errout.debug, LOG_INF, "tsip_analyze packet type %d\n", session->lexer.type); return 0; } @@ -163,7 +163,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) /*@ -charint @*/ id = (unsigned)session->lexer.outbuffer[1]; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "TSIP packet id 0x%02x length %d: %s\n", id, len, buf2); (void)time(&now); @@ -173,11 +173,11 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) case 0x13: /* Packet Received */ u1 = getub(buf, 0); u2 = getub(buf, 1); - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Received packet of type %02x cannot be parsed\n", u1); #if USE_SUPERPACKET if ((int)u1 == 0x8e && (int)u2 == 0x23) { /* no Compact Super Packet */ - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "No Compact Super Packet, use LFwEI\n"); /* Request LFwEI Super Packet */ @@ -211,7 +211,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) "sw %u %u %u %02u.%02u.%04u %s", u2, u3, u4, u6, u5, s1, buf2); /*@ +formattype @*/ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Software version: %s\n", session->subtype); @@ -234,7 +234,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) (void)snprintf(session->subtype, sizeof(session->subtype), "hw %u %02u.%02u.%04u %02u %u %s", ul1, u2, u3, s1, u4, s2, buf2); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Hardware version: %s\n", session->subtype); @@ -242,7 +242,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) /* Detecting device by Hardware Code */ if (s2 == 3001) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "This device is Accutime Gold\n"); session->driver.tsip.subtype = TSIP_ACCUTIME_GOLD; configuration_packets_accutime_gold(session); @@ -267,7 +267,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) gpsd_gpstime_resolve(session, (unsigned short)s1, (double)f1); mask |= TIME_SET | PPSTIME_IS; } - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS Time %f %d %f\n", f1, s1, f2); break; case 0x42: /* Single-Precision Position Fix, XYZ ECEF */ @@ -277,7 +277,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) f2 = getbef32((char *)buf, 4); /* Y */ f3 = getbef32((char *)buf, 8); /* Z */ f4 = getbef32((char *)buf, 12); /* time-of-fix */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS Position XYZ %f %f %f %f\n", f1, f2, f3, f4); break; case 0x43: /* Velocity Fix, XYZ ECEF */ @@ -288,7 +288,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) f3 = getbef32((char *)buf, 8); /* Z velocity */ f4 = getbef32((char *)buf, 12); /* bias rate */ f5 = getbef32((char *)buf, 16); /* time-of-fix */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS Velocity XYZ %f %f %f %f %f\n", f1, f2, f3, f4, f5); break; @@ -309,7 +309,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) getub(buf, 7), getub(buf, 8)); /*@ +formattype @*/ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Software version: %s\n", session->subtype); mask |= DEVICEID_SET; break; @@ -328,7 +328,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) mask |= STATUS_SET; } } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Receiver health %02x %02x\n", u1, u2); break; case 0x47: /* Signal Levels for all Satellites */ @@ -349,13 +349,13 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) (void)snprintf(buf2 + strlen(buf2), sizeof(buf2) - strlen(buf2), " %d=%.1f", (int)u1, f1); } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Signal Levels (%d):%s\n", count, buf2); mask |= SATELLITE_SET; break; case 0x48: /* GPS System Message */ buf[len] = '\0'; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "GPS System Message: %s\n", buf); break; case 0x49: /* Almanac Health Page */ @@ -376,7 +376,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) mask |= TIME_SET | PPSTIME_IS; } mask |= LATLON_SET | ALTITUDE_SET | CLEAR_IS | REPORT_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SPPLLA 0x4a time=%.2f lat=%.2f lon=%.2f alt=%.2f\n", session->newdata.time, session->newdata.latitude, @@ -389,11 +389,11 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) u1 = getub(buf, 0); /* Machine ID */ u2 = getub(buf, 1); /* Status 1 */ u3 = getub(buf, 2); /* Status 2 */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Machine ID %02x %02x %02x\n", u1, u2, u3); #if USE_SUPERPACKET if ((u3 & 0x01) != (uint8_t) 0 && !session->driver.tsip.superpkt) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Switching to Super Packet mode\n"); /* set new I/O Options for Super Packet output */ @@ -417,7 +417,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) u2 = getub(buf, 1); /* Velocity */ u3 = getub(buf, 2); /* Timing */ u4 = getub(buf, 3); /* Aux */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "IO Options %02x %02x %02x %02x\n", u1, u2, u3, u4); #if USE_SUPERPACKET if ((u1 & 0x20) != (uint8_t) 0) { /* Output Super Packets? */ @@ -448,11 +448,11 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) /*@ +evalorder @*/ if ((session->newdata.track = atan2(f1, f2) * RAD_2_DEG) < 0) session->newdata.track += 360.0; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS Velocity ENU %f %f %f %f %f\n", f1, f2, f3, f4, f5); mask |= SPEED_SET | TRACK_SET | CLIMB_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "VFENU 0x56 time=%.2f speed=%.2f track=%.2f climb=%.2f\n", session->newdata.time, session->newdata.speed, @@ -470,7 +470,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) if (getub(buf, 0) == 0x01) /* good current fix? */ (void)gpsd_gpstime_resolve(session, (unsigned short)s1, (double)f1); /*@ -charint @*/ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Fix info %02x %02x %d %f\n", u1, u2, s1, f1); break; case 0x58: /* Satellite System Data/Acknowledge from Receiver */ @@ -484,7 +484,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) f2 = getbef32((char *)buf, 9); /* Code phase */ f3 = getbef32((char *)buf, 13); /* Doppler */ d1 = getbed64((char *)buf, 17); /* Time of Measurement */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Raw Measurement Data %d %f %f %f %f\n", getub(buf, 0), f1, f2, f3, d1); break; @@ -502,7 +502,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) d1 = getbef32((char *)buf, 12) * RAD_2_DEG; /* Elevation */ d2 = getbef32((char *)buf, 16) * RAD_2_DEG; /* Azimuth */ i = (int)(u2 >> 3); /* channel number */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Satellite Tracking Status: Ch %2d PRN %3d Res %d Acq %d Eph %2d SNR %4.1f LMT %.04f El %4.1f Az %5.1f\n", i, u1, u2 & 7, u3, u4, f1, f2, d1, d2); if (i < TSIP_CHANNELS) { @@ -576,7 +576,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) " %d", session->gpsdata.used[i] = (int)getub(buf, 17 + i)); /*@ -charint @*/ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "AIVSS: 0x6d status=%d used=%d " "pdop=%.1f hdop=%.1f vdop=%.1f tdop=%.1f gdup=%.1f\n", session->gpsdata.status, @@ -614,7 +614,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) mask |= STATUS_SET; } /*@ -charint @*/ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "DPFM 0x82 status=%d\n", session->gpsdata.status); break; case 0x83: /* Double-Precision XYZ Position Fix and Bias Information */ @@ -625,7 +625,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) d3 = getbed64((char *)buf, 16); /* Z */ d4 = getbed64((char *)buf, 24); /* clock bias */ f1 = getbef32((char *)buf, 32); /* time-of-fix */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS Position XYZ %f %f %f %f %f\n", d1, d2, d3, d4, f1); break; case 0x84: /* Double-Precision LLA Position Fix and Bias Information */ @@ -643,13 +643,13 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) (double)f1); mask |= TIME_SET | PPSTIME_IS; } - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS DP LLA %f %f %f %f\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude); mask |= LATLON_SET | ALTITUDE_SET | CLEAR_IS | REPORT_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "DPPLLA 0x84 time=%.2f lat=%.2f lon=%.2f alt=%.2f\n", session->newdata.time, session->newdata.latitude, @@ -670,7 +670,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) d3 = getbed64((char *)buf, 19); /* DZ */ d4 = getbed64((char *)buf, 27); /* A-axis */ d5 = getbed64((char *)buf, 35); /* Eccentricity Squared */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Current Datum %d %f %f %f %f %f\n", s1, d1, d2, d3, d4, d5); break; @@ -692,7 +692,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) u4 = getub(buf, 29); /* utc offset */ s4 = getbes16(buf, 30); /* tsip.gps_week */ /* PRN/IODE data follows */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "LFwEI %d %d %d %u %d %u %u %x %x %u %u %d\n", s1, s2, s3, ul1, sl1, ul2, sl2, u1, u2, u3, u4, s4); @@ -740,7 +740,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) TIME_SET | PPSTIME_IS | LATLON_SET | ALTITUDE_SET | SPEED_SET | TRACK_SET | CLIMB_SET | STATUS_SET | MODE_SET | CLEAR_IS | REPORT_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SP-LFEI 0x20: time=%.2f lat=%.2f lon=%.2f alt=%.2f " "speed=%.2f track=%.2f climb=%.2f " "mode=%d status=%d\n", @@ -765,7 +765,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) s2 = getbes16(buf, 21); /* east velocity */ s3 = getbes16(buf, 23); /* north velocity */ s4 = getbes16(buf, 25); /* up velocity */ - gpsd_report(session->context->debug, LOG_INF, "CSP %u %d %u %u %d %u %d %d %d %d\n", ul1, + gpsd_report(session->context->errout.debug, LOG_INF, "CSP %u %d %u %u %d %u %d %d %d %d\n", ul1, s1, u1, u2, sl1, ul2, sl3, s2, s3, s4); if ((int)u1 > 10) { session->context->leap_seconds = (int)u1; @@ -811,7 +811,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) TIME_SET | PPSTIME_IS | LATLON_SET | ALTITUDE_SET | SPEED_SET | TRACK_SET |CLIMB_SET | STATUS_SET | MODE_SET | CLEAR_IS | REPORT_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SP-CSP 0x23: time=%.2f lat=%.2f lon=%.2f alt=%.2f " "speed=%.2f track=%.2f climb=%.2f mode=%d status=%d\n", session->newdata.time, @@ -823,7 +823,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) case 0xab: /* Thunderbolt Timing Superpacket */ if (len != 17) { - gpsd_report(session->context->debug, 4, "pkt 0xab len=%d\n", len); + gpsd_report(session->context->errout.debug, 4, "pkt 0xab len=%d\n", len); break; } session->driver.tsip.last_41 = now; /* keep timestamp for request */ @@ -837,19 +837,19 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) session->newdata.time = gpsd_gpstime_resolve(session, (unsigned short)s1, (double)ul1); mask |= TIME_SET | PPSTIME_IS | CLEAR_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SP-TTS 0xab time=%.2f mask={TIME}\n", session->newdata.time); } - gpsd_report(session->context->debug, 4, + gpsd_report(session->context->errout.debug, 4, "GPS Time %u %d %d\n", ul1, s1, s2); break; case 0xac: /* Thunderbolt Position Superpacket */ if (len != 68) { - gpsd_report(session->context->debug, 4, "pkt 0xac len=%d\n", len); + gpsd_report(session->context->errout.debug, 4, "pkt 0xac len=%d\n", len); break; } @@ -915,7 +915,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) } mask |= LATLON_SET | ALTITUDE_SET | MODE_SET | REPORT_IS; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SP-TPS 0xac time=%.2f lat=%.2f lon=%.2f alt=%.2f\n", session->newdata.time, session->newdata.latitude, @@ -924,7 +924,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) break; default: - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Unhandled TSIP superpacket type 0x%02x\n", u1); } @@ -941,12 +941,12 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) f3 = getbef32((char *)buf, 13); /* DOP Mask */ f4 = getbef32((char *)buf, 17); /* DOP Switch */ u5 = getub(buf, 21); /* DGPS Age Limit (not in Accutime Gold) */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "Navigation Configuration %u %u %u %u %f %f %f %f %u\n", u1, u2, u3, u4, f1, f2, f3, f4, u5); break; default: - gpsd_report(session->context->debug, LOG_WARN, "Unhandled TSIP packet type 0x%02x\n", id); + gpsd_report(session->context->errout.debug, LOG_WARN, "Unhandled TSIP packet type 0x%02x\n", id); break; } @@ -988,7 +988,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) ((now - session->driver.tsip.req_compact) > 5)) { /* Compact Superpacket requested but no response */ session->driver.tsip.req_compact = 0; - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "No Compact Super Packet, use LFwEI\n"); /* Request LFwEI Super Packet */ @@ -1142,7 +1142,7 @@ static void tsip_mode(struct gps_device_t *session, int mode) ; } else { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "unknown mode %i requested\n", mode); } } diff --git a/driver_ubx.c b/driver_ubx.c index 2e2f8201..a70a8303 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -148,7 +148,7 @@ ubx_msg_nav_sol(struct gps_device_t *session, unsigned char *buf, session->gpsdata.status = STATUS_FIX; mask |= MODE_SET | STATUS_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NAVSOL: time=%.2f lat=%.2f lon=%.2f alt=%.2f track=%.2f speed=%.2f climb=%.2f mode=%d status=%d used=%d\n", session->newdata.time, session->newdata.latitude, @@ -196,7 +196,7 @@ ubx_msg_nav_dop(struct gps_device_t *session, unsigned char *buf, session->gpsdata.dop.tdop = (double)(getleu16(buf, 8) / 100.0); session->gpsdata.dop.vdop = (double)(getleu16(buf, 10) / 100.0); session->gpsdata.dop.hdop = (double)(getleu16(buf, 12) / 100.0); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NAVDOP: gdop=%.2f pdop=%.2f " "hdop=%.2f vdop=%.2f tdop=%.2f mask={DOP}\n", session->gpsdata.dop.gdop, @@ -227,7 +227,7 @@ ubx_msg_nav_timegps(struct gps_device_t *session, unsigned char *buf, (unsigned short int)gw, (double)tow / 1000.0); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "TIMEGPS: time=%.2f mask={TIME}\n", session->newdata.time); return TIME_SET | PPSTIME_IS; @@ -243,14 +243,14 @@ ubx_msg_nav_svinfo(struct gps_device_t *session, unsigned char *buf, unsigned int i, j, nchan, nsv, st; if (data_len < 152) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "runt svinfo (datalen=%zd)\n", data_len); return 0; } /*@ +charint @*/ nchan = (unsigned int)getub(buf, 4); if (nchan > MAXCHANNELS) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Invalid NAV SVINFO message, >%d reported visible", MAXCHANNELS); return 0; @@ -280,7 +280,7 @@ ubx_msg_nav_svinfo(struct gps_device_t *session, unsigned char *buf, session->gpsdata.skyview_time = NAN; session->gpsdata.satellites_visible = (int)st; session->gpsdata.satellites_used = (int)nsv; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "SVINFO: visible=%d used=%d mask={SATELLITE|USED}\n", session->gpsdata.satellites_visible, session->gpsdata.satellites_used); @@ -295,7 +295,7 @@ static void ubx_msg_sbas(struct gps_device_t *session, unsigned char *buf) #ifdef __UNUSED_DEBUG__ unsigned int i, nsv; - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "SBAS: %d %d %d %d %d\n", (int)getub(buf, 4), (int)getub(buf, 5), (int)getub(buf, 6), (int)getub(buf, 7), (int)getub(buf, 8)); @@ -303,7 +303,7 @@ static void ubx_msg_sbas(struct gps_device_t *session, unsigned char *buf) nsv = (int)getub(buf, 8); for (i = 0; i < nsv; i++) { int off = 12 + 12 * i; - gpsd_report(session->context->debug, LOG_WARN, "SBAS info on SV: %d\n", (int)getub(buf, off)); + gpsd_report(session->context->errout.debug, LOG_WARN, "SBAS info on SV: %d\n", (int)getub(buf, off)); } #endif /* __UNUSED_DEBUG__ */ /* really 'in_use' depends on the sats info, EGNOS is still in test */ @@ -321,7 +321,7 @@ static gps_mask_t ubx_msg_sfrb(struct gps_device_t *session, unsigned char *buf) chan = (unsigned int)getub(buf, 0); svid = (unsigned int)getub(buf, 1); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_RXM_SFRB: %u %u\n", chan, svid); /* UBX does all the parity checking, but still bad data gets through */ @@ -345,19 +345,19 @@ static void ubx_msg_inf(struct gps_device_t *session, unsigned char *buf, size_t txtbuf[data_len] = '\0'; switch (msgid) { case UBX_INF_DEBUG: - gpsd_report(session->context->debug, LOG_PROG, "UBX_INF_DEBUG: %s\n", txtbuf); + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_INF_DEBUG: %s\n", txtbuf); break; case UBX_INF_TEST: - gpsd_report(session->context->debug, LOG_PROG, "UBX_INF_TEST: %s\n", txtbuf); + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_INF_TEST: %s\n", txtbuf); break; case UBX_INF_NOTICE: - gpsd_report(session->context->debug, LOG_INF, "UBX_INF_NOTICE: %s\n", txtbuf); + gpsd_report(session->context->errout.debug, LOG_INF, "UBX_INF_NOTICE: %s\n", txtbuf); break; case UBX_INF_WARNING: - gpsd_report(session->context->debug, LOG_WARN, "UBX_INF_WARNING: %s\n", txtbuf); + gpsd_report(session->context->errout.debug, LOG_WARN, "UBX_INF_WARNING: %s\n", txtbuf); break; case UBX_INF_ERROR: - gpsd_report(session->context->debug, LOG_WARN, "UBX_INF_ERROR: %s\n", txtbuf); + gpsd_report(session->context->errout.debug, LOG_WARN, "UBX_INF_ERROR: %s\n", txtbuf); break; default: break; @@ -384,109 +384,109 @@ gps_mask_t ubx_parse(struct gps_device_t * session, unsigned char *buf, data_len = (size_t) getles16(buf, 4); switch (msgid) { case UBX_NAV_POSECEF: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_POSECEF\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_POSECEF\n"); break; case UBX_NAV_POSLLH: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_POSLLH\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_POSLLH\n"); mask = ubx_msg_nav_posllh(session, &buf[UBX_PREFIX_LEN], data_len); break; case UBX_NAV_STATUS: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_STATUS\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_STATUS\n"); break; case UBX_NAV_DOP: - gpsd_report(session->context->debug, LOG_PROG, "UBX_NAV_DOP\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_NAV_DOP\n"); mask = ubx_msg_nav_dop(session, &buf[UBX_PREFIX_LEN], data_len); break; case UBX_NAV_SOL: - gpsd_report(session->context->debug, LOG_PROG, "UBX_NAV_SOL\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_NAV_SOL\n"); mask = ubx_msg_nav_sol(session, &buf[UBX_PREFIX_LEN], data_len) | (CLEAR_IS | REPORT_IS); break; case UBX_NAV_POSUTM: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_POSUTM\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_POSUTM\n"); break; case UBX_NAV_VELECEF: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_VELECEF\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_VELECEF\n"); break; case UBX_NAV_VELNED: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_VELNED\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_VELNED\n"); break; case UBX_NAV_TIMEGPS: - gpsd_report(session->context->debug, LOG_PROG, "UBX_NAV_TIMEGPS\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_NAV_TIMEGPS\n"); mask = ubx_msg_nav_timegps(session, &buf[UBX_PREFIX_LEN], data_len); break; case UBX_NAV_TIMEUTC: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_TIMEUTC\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_TIMEUTC\n"); break; case UBX_NAV_CLOCK: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_CLOCK\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_CLOCK\n"); break; case UBX_NAV_SVINFO: - gpsd_report(session->context->debug, LOG_PROG, "UBX_NAV_SVINFO\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_NAV_SVINFO\n"); mask = ubx_msg_nav_svinfo(session, &buf[UBX_PREFIX_LEN], data_len); break; case UBX_NAV_DGPS: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_DGPS\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_DGPS\n"); break; case UBX_NAV_SBAS: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_SBAS\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_SBAS\n"); ubx_msg_sbas(session, &buf[6]); break; case UBX_NAV_EKFSTATUS: - gpsd_report(session->context->debug, LOG_DATA, "UBX_NAV_EKFSTATUS\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_NAV_EKFSTATUS\n"); break; case UBX_RXM_RAW: - gpsd_report(session->context->debug, LOG_DATA, "UBX_RXM_RAW\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_RXM_RAW\n"); break; case UBX_RXM_SFRB: mask = ubx_msg_sfrb(session, &buf[UBX_PREFIX_LEN]); break; case UBX_RXM_SVSI: - gpsd_report(session->context->debug, LOG_PROG, "UBX_RXM_SVSI\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "UBX_RXM_SVSI\n"); break; case UBX_RXM_ALM: - gpsd_report(session->context->debug, LOG_DATA, "UBX_RXM_ALM\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_RXM_ALM\n"); break; case UBX_RXM_EPH: - gpsd_report(session->context->debug, LOG_DATA, "UBX_RXM_EPH\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_RXM_EPH\n"); break; case UBX_RXM_POSREQ: - gpsd_report(session->context->debug, LOG_DATA, "UBX_RXM_POSREQ\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_RXM_POSREQ\n"); break; case UBX_MON_SCHED: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_SCHED\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_SCHED\n"); break; case UBX_MON_IO: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_IO\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_IO\n"); break; case UBX_MON_IPC: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_IPC\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_IPC\n"); break; case UBX_MON_VER: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_VER\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_VER\n"); (void)strlcpy(session->subtype, (char *)&buf[UBX_MESSAGE_DATA_OFFSET + 0], 30); break; case UBX_MON_EXCEPT: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_EXCEPT\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_EXCEPT\n"); break; case UBX_MON_MSGPP: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_MSGPP\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_MSGPP\n"); break; case UBX_MON_RXBUF: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_RXBUF\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_RXBUF\n"); break; case UBX_MON_TXBUF: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_TXBUF\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_TXBUF\n"); break; case UBX_MON_HW: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_HW\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_HW\n"); break; case UBX_MON_USB: - gpsd_report(session->context->debug, LOG_DATA, "UBX_MON_USB\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_MON_USB\n"); break; case UBX_INF_DEBUG: @@ -503,38 +503,38 @@ gps_mask_t ubx_parse(struct gps_device_t * session, unsigned char *buf, case UBX_CFG_PRT: session->driver.ubx.port_id = (unsigned char)buf[UBX_MESSAGE_DATA_OFFSET + 0]; - gpsd_report(session->context->debug, LOG_INF, "UBX_CFG_PRT: port %d\n", + gpsd_report(session->context->errout.debug, LOG_INF, "UBX_CFG_PRT: port %d\n", session->driver.ubx.port_id); break; case UBX_TIM_TP: - gpsd_report(session->context->debug, LOG_DATA, "UBX_TIM_TP\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_TIM_TP\n"); break; case UBX_TIM_TM: - gpsd_report(session->context->debug, LOG_DATA, "UBX_TIM_TM\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_TIM_TM\n"); break; case UBX_TIM_TM2: - gpsd_report(session->context->debug, LOG_DATA, "UBX_TIM_TM2\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_TIM_TM2\n"); break; case UBX_TIM_SVIN: - gpsd_report(session->context->debug, LOG_DATA, "UBX_TIM_SVIN\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_TIM_SVIN\n"); break; case UBX_ACK_NAK: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_ACK_NAK, class: %02x, id: %02x\n", buf[UBX_CLASS_OFFSET], buf[UBX_TYPE_OFFSET]); break; case UBX_ACK_ACK: - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX_ACK_ACK, class: %02x, id: %02x\n", buf[UBX_CLASS_OFFSET], buf[UBX_TYPE_OFFSET]); break; default: - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "UBX: unknown packet id 0x%04hx (length %zd)\n", msgid, len); } @@ -598,7 +598,7 @@ bool ubx_write(struct gps_device_t * session, /*@ +type @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> GPS: UBX class: %02x, id: %02x, len: %zd, crc: %02x%02x\n", msg_class, msg_id, data_len, CK_A, CK_B); @@ -636,7 +636,7 @@ static void ubx_event_hook(struct gps_device_t *session, event_t event) else if (event == event_identified) { unsigned char msg[32]; - gpsd_report(session->context->debug, LOG_DATA, "UBX configure\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX configure\n"); /*@ -type @*/ msg[0] = 0x03; /* SBAS mode enabled, accept testbed mode */ @@ -667,7 +667,7 @@ static void ubx_event_hook(struct gps_device_t *session, event_t event) }; /* reserved */ /*@ +type @*/ - gpsd_report(session->context->debug, LOG_DATA, "UBX revert\n"); + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX revert\n"); /* Reverting all in one fast and reliable reset */ (void)ubx_write(session, 0x06, 0x04, msg, 4); /* CFG-RST */ @@ -954,7 +954,7 @@ static bool ubx_rate(struct gps_device_t *session, double cycletime) if (cycletime < 200.0) cycletime = 200.0; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "UBX rate change, report every %f secs\n", cycletime); s = (unsigned short)cycletime; msg[0] = (unsigned char)(s >> 8); diff --git a/driver_zodiac.c b/driver_zodiac.c index 7f1a1f1b..f3680051 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -85,7 +85,7 @@ static ssize_t zodiac_spew(struct gps_device_t *session, unsigned short type, if (end_write(session->gpsdata.gps_fd, &h, hlen) != (ssize_t) hlen || end_write(session->gpsdata.gps_fd, dat, datlen) != (ssize_t) datlen) { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "Reconfigure write failed\n"); return -1; } @@ -98,7 +98,7 @@ static ssize_t zodiac_spew(struct gps_device_t *session, unsigned short type, (void)snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %04x", dat[i]); - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "Sent Zodiac packet: %s\n", buf); return 0; @@ -203,7 +203,7 @@ static gps_mask_t handle1000(struct gps_device_t *session) mask = TIME_SET | PPSTIME_IS | LATLON_SET | ALTITUDE_SET | CLIMB_SET | SPEED_SET | TRACK_SET | STATUS_SET | MODE_SET; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "1000: time=%.2f lat=%.2f lon=%.2f alt=%.2f track=%.2f speed=%.2f climb=%.2f mode=%d status=%d\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, @@ -249,7 +249,7 @@ static gps_mask_t handle1002(struct gps_device_t *session) session->gpsdata.skyview_time = gpsd_gpstime_resolve(session, (unsigned short)gps_week, (double)gps_seconds); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "1002: visible=%d used=%d mask={SATELLITE|USED}\n", session->gpsdata.satellites_visible, session->gpsdata.satellites_used); @@ -295,7 +295,7 @@ static gps_mask_t handle1003(struct gps_device_t *session) } } session->gpsdata.skyview_time = NAN; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "NAVDOP: visible=%d gdop=%.2f pdop=%.2f " "hdop=%.2f vdop=%.2f tdop=%.2f mask={SATELLITE|DOP}\n", session->gpsdata.satellites_visible, @@ -330,7 +330,7 @@ static gps_mask_t handle1011(struct gps_device_t *session) * The Zodiac is supposed to send one of these messages on startup. */ getstringz(session->subtype, session->lexer.outbuffer, 19, 28); /* software version field */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "1011: subtype=%s mask={DEVICEID}\n", session->subtype); return DEVICEID_SET; @@ -355,7 +355,7 @@ static gps_mask_t zodiac_analyze(struct gps_device_t *session) unsigned int id = (unsigned int)((session->lexer.outbuffer[3] << 8) | session->lexer.outbuffer[2]); - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "Raw Zodiac packet type %d length %zd: %s\n", id, session->lexer.outbuflen, gpsd_prettydump(session)); @@ -34,21 +34,21 @@ gps_mask_t generic_parse_input(struct gps_device_t *session) char *sentence = (char *)session->lexer.outbuffer; if (sentence[strlen(sentence)-1] != '\n') - gpsd_report(session->context->debug, LOG_IO, + gpsd_report(session->context->errout.debug, LOG_IO, "<= GPS: %s\n", sentence); else - gpsd_report(session->context->debug, LOG_IO, + gpsd_report(session->context->errout.debug, LOG_IO, "<= GPS: %s", sentence); if ((st=nmea_parse(sentence, session)) == 0) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "unknown sentence: \"%s\"\n", sentence); } for (dp = gpsd_drivers; *dp; dp++) { char *trigger = (*dp)->trigger; if (trigger!=NULL && strncmp(sentence,trigger,strlen(trigger))==0) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "found trigger string %s.\n", trigger); if (*dp != session->device_type) { (void)gpsd_switch_driver(session, (*dp)->type_name); @@ -63,7 +63,7 @@ gps_mask_t generic_parse_input(struct gps_device_t *session) return st; #endif /* NMEA_ENABLE */ } else { - gpsd_report(session->context->debug, LOG_SHOUT, + gpsd_report(session->context->errout.debug, LOG_SHOUT, "packet type %d fell through (should never happen): %s.\n", session->lexer.type, gpsd_prettydump(session)); return 0; @@ -147,7 +147,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) #ifdef NMEA_ENABLE case 0: /* probe for Garmin serial GPS -- expect $PGRMC followed by data */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for Garmin NMEA\n"); (void)nmea_send(session, "$PGRMCE"); break; @@ -171,7 +171,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) * mode! Fix this if we ever find a nondisruptive probe * string. */ - gpsd_report(session->context->debug, LOG_PROG, "=> Probing for SiRF\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for SiRF\n"); (void)nmea_send(session, "$PSRF100,0,%d,%d,%d,0", session->gpsdata.dev.baudrate, @@ -183,19 +183,19 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) #ifdef NMEA_ENABLE case 2: /* probe for the FV-18 -- expect $PFEC,GPint followed by data */ - gpsd_report(session->context->debug, LOG_PROG, "=> Probing for FV-18\n"); + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for FV-18\n"); (void)nmea_send(session, "$PFEC,GPint"); break; case 3: /* probe for the Trimble Copernicus */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for Trimble Copernicus\n"); (void)nmea_send(session, "$PTNLSNM,0139,01"); break; #endif /* NMEA_ENABLE */ #ifdef EVERMORE_ENABLE case 4: - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for Evermore\n"); /* Enable checksum and GGA(1s), GLL(0s), GSA(1s), GSV(1s), RMC(1s), VTG(0s), PEMT101(0s) */ /* EverMore will reply with: \x10\x02\x04\x38\x8E\xC6\x10\x03 */ @@ -207,7 +207,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) #ifdef GPSCLOCK_ENABLE case 5: /* probe for Furuno Electric GH-79L4-N (GPSClock); expect $PFEC,GPssd */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for GPSClock\n"); (void)nmea_send(session, "$PFEC,GPsrq"); break; @@ -215,7 +215,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) #ifdef ASHTECH_ENABLE case 6: /* probe for Ashtech -- expect $PASHR,RID */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for Ashtech\n"); (void)nmea_send(session, "$PASHQ,RID"); break; @@ -223,7 +223,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) #ifdef UBLOX_ENABLE case 7: /* probe for UBX -- query port configuration */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for UBX\n"); (void)ubx_write(session, 0x06, 0x00, NULL, 0); break; @@ -231,7 +231,7 @@ static void nmea_event_hook(struct gps_device_t *session, event_t event) #ifdef MTK3301_ENABLE case 8: /* probe for MTK-3301 -- expect $PMTK705 */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "=> Probing for MediaTek\n"); (void)nmea_send(session, "$PMTK605"); break; @@ -512,7 +512,7 @@ static void gpsclock_event_hook(struct gps_device_t *session, event_t event) * ignore the trailing PPS edge when extracting time from this chip. */ if (event == event_identified || event == event_reactivate) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "PPS trailing edge will be ignored\n"); session->nmea.ignore_trailing_edge = true; } @@ -685,7 +685,7 @@ static ssize_t tnt_control_send(struct gps_device_t *session, } #ifdef __UNUSED__ else { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Bad TNT sentence: '%s'\n", msg); } #endif /* __UNUSED__ */ @@ -711,11 +711,11 @@ static bool tnt_send(struct gps_device_t *session, const char *fmt, ...) va_end(ap); sent = tnt_control_send(session, buf, strlen(buf)); if (sent == (ssize_t) strlen(buf)) { - gpsd_report(session->context->debug, LOG_IO, + gpsd_report(session->context->errout.debug, LOG_IO, "=> GPS: %s\n", buf); return true; } else { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "=> GPS: %s FAILED\n", buf); return false; } @@ -823,10 +823,10 @@ static void oceanserver_event_hook(struct gps_device_t *session, return; if (event == event_configure && session->lexer.counter == 0) { /* report in NMEA format */ - (void)oceanserver_send(session->context->debug, + (void)oceanserver_send(session->context->errout.debug, session->gpsdata.gps_fd, "2\n"); /* ship all fields */ - (void)oceanserver_send(session->context->debug, + (void)oceanserver_send(session->context->errout.debug, session->gpsdata.gps_fd, "X2047"); } } @@ -940,8 +940,8 @@ static gps_mask_t rtcm104v2_analyze(struct gps_device_t *session) { 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, + if (session->context->errout.debug >= LOG_RAW) + gpsd_report(session->context->errout.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, @@ -993,7 +993,7 @@ static gps_mask_t rtcm104v3_analyze(struct gps_device_t *session) { uint16_t type = getbeu16(session->lexer.inbuffer, 3) >> 4; - gpsd_report(session->context->debug, LOG_RAW, "RTCM 3.x packet %d\n", type); + gpsd_report(session->context->errout.debug, LOG_RAW, "RTCM 3.x packet %d\n", type); rtcm3_unpack(session->context, &session->gpsdata.rtcm3, (char *)session->lexer.outbuffer); @@ -1204,7 +1204,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, return false; /* we may need to dump the raw packet */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "AIVDM packet length %zd: %s\n", buflen, buf); /* first clear the result, making sure we don't return garbage */ @@ -1212,7 +1212,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, /* discard overlong sentences */ if (strlen(buf) > sizeof(fieldcopy)-1) { - gpsd_report(session->context->debug, LOG_ERROR, "overlong AIVDM packet.\n"); + gpsd_report(session->context->errout.debug, LOG_ERROR, "overlong AIVDM packet.\n"); return false; } @@ -1228,7 +1228,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, /* discard sentences with exiguous commas; catches run-ons */ if (nfields < 7) { - gpsd_report(session->context->debug, LOG_ERROR, "malformed AIVDM packet.\n"); + gpsd_report(session->context->errout.debug, LOG_ERROR, "malformed AIVDM packet.\n"); return false; } @@ -1240,14 +1240,14 @@ static bool aivdm_decode(const char *buf, size_t buflen, * is going to break if there's ever an AIVDO type 24, though. */ if (strncmp((const char *)field[0], "!AIVDO", 6) != 0) - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "invalid empty AIS channel. Assuming 'A'\n"); ais_context = &session->driver.aivdm.context[0]; session->driver.aivdm.ais_channel ='A'; break; case '1': if (strcmp((char *)field[4], (char *)"12") == 0) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "ignoring bogus AIS channel '12'.\n"); return false; } @@ -1263,11 +1263,11 @@ static bool aivdm_decode(const char *buf, size_t buflen, session->driver.aivdm.ais_channel ='B'; break; case 'C': - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "ignoring AIS channel C (secure AIS).\n"); return false; default: - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "invalid AIS channel 0x%0X .\n", field[4][0]); return false; } @@ -1276,7 +1276,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, ifrag = atoi((char *)field[2]); /* fragment id */ data = field[5]; pad = field[6][0]; /* number of padding bits */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "nfrags=%d, ifrag=%d, decoded_frags=%d, data=%s\n", nfrags, ifrag, ais_context->decoded_frags, data); @@ -1284,7 +1284,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, /* check fragment ordering */ if (ifrag != ais_context->decoded_frags + 1) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "invalid fragment #%d received, expected #%d.\n", ifrag, ais_context->decoded_frags + 1); if (ifrag != 1) @@ -1307,7 +1307,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, if (ch >= 40) ch -= 8; #ifdef __UNUSED_DEBUG__ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "%c: %s\n", *cp, sixbits[ch]); #endif /* __UNUSED_DEBUG__ */ /*@ -shiftnegative @*/ @@ -1318,7 +1318,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, } ais_context->bitlen++; if (ais_context->bitlen > sizeof(ais_context->bits)) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "overlong AIVDM payload truncated.\n"); return false; } @@ -1333,7 +1333,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, if (ifrag == nfrags) { if (debug >= LOG_INF) { size_t clen = (ais_context->bitlen + 7) / 8; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "AIVDM payload is %zd bits, %zd chars: %s\n", ais_context->bitlen, clen, gpsd_hexdump(session->msgbuf, sizeof(session->msgbuf), @@ -1344,7 +1344,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, ais_context->decoded_frags = 0; /* decode the assembled binary packet */ - return ais_binary_decode(session->context->debug, + return ais_binary_decode(session->context->errout.debug, ais, ais_context->bits, ais_context->bitlen, @@ -1363,7 +1363,7 @@ static gps_mask_t aivdm_analyze(struct gps_device_t *session) if (aivdm_decode ((char *)session->lexer.outbuffer, session->lexer.outbuflen, session, &session->gpsdata.ais, - session->context->debug)) { + session->context->errout.debug)) { return ONLINE_SET | AIS_SET; } else return ONLINE_SET; @@ -1445,7 +1445,7 @@ static void path_rewrite(struct gps_device_t *session, char *prefix) static gps_mask_t json_pass_packet(struct gps_device_t *session) { - gpsd_report(session->context->debug, LOG_IO, + gpsd_report(session->context->errout.debug, LOG_IO, "<= GPS: %s\n", (char *)session->lexer.outbuffer); if (strncmp(session->gpsdata.dev.path, "gpsd://localhost:", 17) != 0) @@ -1473,7 +1473,7 @@ static gps_mask_t json_pass_packet(struct gps_device_t *session) session->lexer.outbuflen = strlen((char *)session->lexer.outbuffer); } } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "JSON, passing through %s\n", (char *)session->lexer.outbuffer); /*@-nullpass@*/ @@ -96,18 +96,18 @@ static bool gps_query(/*@out@*/struct gps_data_t *gpsdata, (void)strlcat(buf, "\n", BUFSIZ); /*@-usedef@*/ if (write(gpsdata->gps_fd, buf, strlen(buf)) <= 0) { - gpsd_report(context.debug, LOG_ERROR, "gps_query(), write failed\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "gps_query(), write failed\n"); return false; } /*@+usedef@*/ - gpsd_report(context.debug, LOG_PROG, "gps_query(), wrote, %s\n", buf); + gpsd_report(context.errout.debug, LOG_PROG, "gps_query(), wrote, %s\n", buf); FD_ZERO(&rfds); starttime = time(NULL); for (;;) { FD_CLR(gpsdata->gps_fd, &rfds); - gpsd_report(context.debug, LOG_PROG, "waiting...\n"); + gpsd_report(context.errout.debug, LOG_PROG, "waiting...\n"); /*@ -usedef -type -nullpass -compdef @*/ tv.tv_sec = 2; @@ -120,16 +120,16 @@ static bool gps_query(/*@out@*/struct gps_data_t *gpsdata, #endif if (errno == EINTR || !FD_ISSET(gpsdata->gps_fd, &rfds)) continue; - gpsd_report(context.debug, LOG_ERROR, "select %s\n", strerror(errno)); + gpsd_report(context.errout.debug, LOG_ERROR, "select %s\n", strerror(errno)); exit(EXIT_FAILURE); } /*@ +usedef +type +nullpass +compdef @*/ - gpsd_report(context.debug, LOG_PROG, "reading...\n"); + gpsd_report(context.errout.debug, LOG_PROG, "reading...\n"); (void)gps_read(gpsdata); if (ERROR_SET & gpsdata->set) { - gpsd_report(context.debug, LOG_ERROR, "error '%s'\n", gpsdata->error); + gpsd_report(context.errout.debug, LOG_ERROR, "error '%s'\n", gpsdata->error); return false; } @@ -137,7 +137,7 @@ static bool gps_query(/*@out@*/struct gps_data_t *gpsdata, if ((expect == NON_ERROR) || (expect & gpsdata->set) != 0) return true; else if (timeout > 0 && (time(NULL) - starttime > timeout)) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "timed out after %d seconds\n", timeout); return false; @@ -151,10 +151,10 @@ static bool gps_query(/*@out@*/struct gps_data_t *gpsdata, static void onsig(int sig) { if (sig == SIGALRM) { - gpsd_report(context.debug, LOG_ERROR, "packet recognition timed out.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "packet recognition timed out.\n"); exit(EXIT_FAILURE); } else { - gpsd_report(context.debug, LOG_ERROR, "killed by signal %d\n", sig); + gpsd_report(context.errout.debug, LOG_ERROR, "killed by signal %d\n", sig); exit(EXIT_SUCCESS); } } @@ -216,7 +216,7 @@ int main(int argc, char **argv) #ifdef RECONFIGURE_ENABLE rate = optarg; #else - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "cycle-change capability has been conditioned out.\n"); #endif /* RECONFIGURE_ENABLE */ break; @@ -225,12 +225,12 @@ int main(int argc, char **argv) control = optarg; lowlevel = true; if ((cooklen = hex_escapes(cooked, control)) <= 0) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "invalid escape string (error %d)\n", (int)cooklen); exit(EXIT_FAILURE); } #else - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "control_send capability has been conditioned out.\n"); #endif /* CONTROLSEND_ENABLE */ break; @@ -270,7 +270,7 @@ int main(int argc, char **argv) #ifdef RECONFIGURE_ENABLE to_nmea = true; #else - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "speed-change capability has been conditioned out.\n"); #endif /* RECONFIGURE_ENABLE */ break; @@ -279,7 +279,7 @@ int main(int argc, char **argv) reset = true; lowlevel = false; /* so we'll abort if the daemon is running */ #else - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "reset capability has been conditioned out.\n"); #endif /* RECONFIGURE_ENABLE */ break; @@ -287,7 +287,7 @@ int main(int argc, char **argv) #ifdef RECONFIGURE_ENABLE speed = optarg; #else - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "speed-change capability has been conditioned out.\n"); #endif /* RECONFIGURE_ENABLE */ break; @@ -327,22 +327,22 @@ int main(int argc, char **argv) } } if (matchcount == 0) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "no driver type name matches '%s'.\n", devtype); else if (matchcount == 1) { assert(forcetype != NULL); - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "%s driver selected.\n", forcetype->type_name); } else { forcetype = NULL; - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%d driver type names match '%s'.\n", matchcount, devtype); } } if (((int)to_nmea + (int)to_binary + (int)reset) > 1) { - gpsd_report(context.debug, LOG_ERROR, "make up your mind, would you?\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "make up your mind, would you?\n"); exit(EXIT_SUCCESS); } @@ -354,7 +354,7 @@ int main(int argc, char **argv) if (!lowlevel) { /* Try to open the stream to gpsd. */ if (gps_open(NULL, NULL, &gpsdata) != 0) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "no gpsd running or network error: %s.\n", gps_errstr(errno)); lowlevel = true; @@ -370,21 +370,21 @@ int main(int argc, char **argv) /* what devices have we available? */ if (!gps_query(&gpsdata, DEVICELIST_SET, (int)timeout, "?DEVICES;\n")) { - gpsd_report(context.debug, LOG_ERROR, "no DEVICES response received.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "no DEVICES response received.\n"); (void)gps_close(&gpsdata); exit(EXIT_FAILURE); } if (gpsdata.devices.ndevices == 0) { - gpsd_report(context.debug, LOG_ERROR, "no devices connected.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "no devices connected.\n"); (void)gps_close(&gpsdata); exit(EXIT_FAILURE); } else if (gpsdata.devices.ndevices > 1 && device == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "multiple devices and no device specified.\n"); (void)gps_close(&gpsdata); exit(EXIT_FAILURE); } - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "%d device(s) found.\n",gpsdata.devices.ndevices); /* try to mine the devicelist return for the data we want */ @@ -397,7 +397,7 @@ int main(int argc, char **argv) if (strcmp(device, gpsdata.devices.list[i].path) == 0) { goto devicelist_entry_matches; } - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "specified device not found in device list.\n"); (void)gps_close(&gpsdata); exit(EXIT_FAILURE); @@ -411,7 +411,7 @@ int main(int argc, char **argv) /* if the device has not identified, watch it until it does so */ if (gpsdata.dev.driver[0] == '\0') { if (gps_stream(&gpsdata, WATCH_ENABLE|WATCH_JSON, NULL) == -1) { - gpsd_report(context.debug, LOG_ERROR, "stream set failed.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "stream set failed.\n"); (void)gps_close(&gpsdata); exit(EXIT_FAILURE); } @@ -419,7 +419,7 @@ int main(int argc, char **argv) while (devcount > 0) { errno = 0; if (gps_read(&gpsdata) == -1) { - gpsd_report(context.debug, LOG_ERROR, "data read failed.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "data read failed.\n"); (void)gps_close(&gpsdata); exit(EXIT_FAILURE); } @@ -432,7 +432,7 @@ int main(int argc, char **argv) } } } - gpsd_report(context.debug, LOG_ERROR, "data read failed.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "data read failed.\n"); (void)gps_close(&gpsdata); exit(EXIT_FAILURE); matching_device_seen:; @@ -440,7 +440,7 @@ int main(int argc, char **argv) /* sanity check */ if (gpsdata.dev.driver[0] == '\0') { - gpsd_report(context.debug, LOG_SHOUT, "%s can't be identified.\n", + gpsd_report(context.errout.debug, LOG_SHOUT, "%s can't be identified.\n", gpsdata.dev.path); (void)gps_close(&gpsdata); exit(EXIT_SUCCESS); @@ -464,7 +464,7 @@ int main(int argc, char **argv) #ifdef RECONFIGURE_ENABLE if (reset) { - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "cannot reset with gpsd running.\n"); exit(EXIT_SUCCESS); } @@ -482,24 +482,24 @@ int main(int argc, char **argv) if (!gps_query(&gpsdata, NON_ERROR, (int)timeout, "?DEVICE={\"path\":\"%s\",\"native\":0}\r\n", device)) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s mode change to NMEA failed\n", gpsdata.dev.path); status = 1; } else - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "%s mode change succeeded\n", gpsdata.dev.path); } else if (to_binary) { if (!gps_query(&gpsdata, NON_ERROR, (int)timeout, "?DEVICE={\"path\":\"%s\",\"native\":1}\r\n", device)) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s mode change to native mode failed\n", gpsdata.dev.path); status = 1; } else - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "%s mode change succeeded\n", gpsdata.dev.path); } @@ -519,19 +519,19 @@ int main(int argc, char **argv) if (modespec!=NULL) { *modespec = '\0'; if (strchr("78", *++modespec) == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "No support for that word length.\n"); status = 1; } parity = *++modespec; if (strchr("NOE", parity) == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "What parity is '%c'?\n", parity); status = 1; } stopbits = *++modespec; if (strchr("12", stopbits) == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Stop bits must be 1 or 2.\n"); status = 1; } @@ -543,13 +543,13 @@ int main(int argc, char **argv) device, speed, parity, stopbits); } if (atoi(speed) != (int)gpsdata.dev.baudrate) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s driver won't support %s%c%c\n", gpsdata.dev.path, speed, parity, stopbits); status = 1; } else - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "%s change to %s%c%c succeeded\n", gpsdata.dev.path, speed, parity, stopbits); @@ -571,14 +571,14 @@ int main(int argc, char **argv) int i; if (device == NULL || forcetype == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "device and type must be specified for the reset operation.\n"); exit(EXIT_FAILURE); } /*@ -mustfreeonly -immediatetrans @*/ gps_context_init(&context); - context.debug = debuglevel; + context.errout.debug = debuglevel; session.context = &context; gpsd_tty_init(&session); (void)strlcpy(session.gpsdata.dev.path, device, sizeof(session.gpsdata.dev.path)); @@ -614,7 +614,7 @@ int main(int argc, char **argv) /*@ -mustfreeonly -immediatetrans @*/ gps_context_init(&context); - context.debug = debuglevel; + context.errout.debug = debuglevel; session.context = &context; /* in case gps_init isn't called */ if (echo) @@ -632,19 +632,19 @@ int main(int argc, char **argv) if (!(forcetype != NULL && echo)) { int maxfd = 0; if (device == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "device must be specified for low-level access.\n"); exit(EXIT_FAILURE); } gpsd_init(&session, &context, device); if (gpsd_activate(&session, O_PROBEONLY) < 0) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "initial GPS device %s open failed\n", device); exit(EXIT_FAILURE); } - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "device %s activated\n", session.gpsdata.dev.path); /*@i1@*/FD_SET(session.gpsdata.gps_fd, &all_fds); if (session.gpsdata.gps_fd > maxfd) @@ -658,7 +658,7 @@ int main(int argc, char **argv) for (hunting = true; hunting; ) { fd_set efds; - switch(gpsd_await_data(&rfds, &efds, maxfd, &all_fds, context.debug)) + switch(gpsd_await_data(&rfds, &efds, maxfd, &all_fds, context.errout.debug)) { case AWAIT_GOT_INPUT: break; @@ -682,11 +682,11 @@ int main(int argc, char **argv) break; case DEVICE_ERROR: /* this is where a failure to sync lands */ - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "device error, bailing out.\n"); exit(EXIT_FAILURE); case DEVICE_EOF: - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "device signed off, bailing out.\n"); exit(EXIT_SUCCESS); default: @@ -695,13 +695,13 @@ int main(int argc, char **argv) } /*@+compdef@*/ - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "%s looks like a %s at %d.\n", device, gpsd_id(&session), session.gpsdata.dev.baudrate); if (forcetype!=NULL && strcmp("NMEA0183", session.device_type->type_name) !=0 && strcmp(forcetype->type_name, session.device_type->type_name)!=0) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "'%s' doesn't match non-generic type '%s' of selected device.\n", forcetype->type_name, session.device_type->type_name); @@ -732,14 +732,14 @@ int main(int argc, char **argv) bool write_enable = context.readonly; context.readonly = false; if (session.device_type->mode_switcher == NULL) { - gpsd_report(context.debug, LOG_SHOUT, + gpsd_report(context.errout.debug, LOG_SHOUT, "%s devices have no mode switch.\n", session.device_type->type_name); status = 1; } else { int target_mode = to_nmea ? MODE_NMEA : MODE_BINARY; - gpsd_report(context.debug, LOG_SHOUT, + gpsd_report(context.errout.debug, LOG_SHOUT, "switching to mode %s.\n", to_nmea ? "NMEA" : "BINARY"); session.device_type->mode_switcher(&session, target_mode); @@ -758,19 +758,19 @@ int main(int argc, char **argv) if (modespec!=NULL) { *modespec = '\0'; if (strchr("78", *++modespec) == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "No support for that word lengths.\n"); status = 1; } parity = *++modespec; if (strchr("NOE", parity) == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "What parity is '%c'?\n", parity); status = 1; } stopbits = *++modespec; if (strchr("12", parity) == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Stop bits must be 1 or 2.\n"); status = 1; } @@ -778,7 +778,7 @@ int main(int argc, char **argv) } if (status == 0) { if (session.device_type->speed_switcher == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s devices have no speed switch.\n", session.device_type->type_name); status = 1; @@ -788,12 +788,12 @@ int main(int argc, char **argv) parity, stopbits)) { settle(&session); - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "%s change to %s%c%d succeeded\n", session.gpsdata.dev.path, speed, parity, stopbits); } else { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s driver won't support %s%c%d.\n", session.gpsdata.dev.path, speed, parity, stopbits); @@ -805,7 +805,7 @@ int main(int argc, char **argv) bool write_enable = context.readonly; context.readonly = false; if (session.device_type->rate_switcher == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s devices have no rate switcher.\n", session.device_type->type_name); status = 1; @@ -813,7 +813,7 @@ int main(int argc, char **argv) double rate_dbl = strtod(rate, NULL); if (!session.device_type->rate_switcher(&session, rate_dbl)) { - gpsd_report(context.debug, LOG_ERROR, "rate switch failed.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "rate switch failed.\n"); status = 1; } settle(&session); @@ -827,7 +827,7 @@ int main(int argc, char **argv) bool write_enable = context.readonly; context.readonly = false; if (session.device_type->control_send == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s devices have no control sender.\n", session.device_type->type_name); status = 1; @@ -835,7 +835,7 @@ int main(int argc, char **argv) if (session.device_type->control_send(&session, cooked, (size_t)cooklen) == -1) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "control transmission failed.\n"); status = 1; } @@ -261,18 +261,18 @@ static socket_t filesock(char *filename) /*@ -mayaliasunique -usedef @*/ if (BAD_SOCKET(sock = socket(AF_UNIX, SOCK_STREAM, 0))) { - gpsd_report(context.debug, LOG_ERROR, "Can't create device-control socket\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "Can't create device-control socket\n"); return -1; } (void)strlcpy(addr.sun_path, filename, sizeof(addr.sun_path)); addr.sun_family = (sa_family_t)AF_UNIX; if (bind(sock, (struct sockaddr *)&addr, (int)sizeof(addr)) < 0) { - gpsd_report(context.debug, LOG_ERROR, "can't bind to local socket %s\n", filename); + gpsd_report(context.errout.debug, LOG_ERROR, "can't bind to local socket %s\n", filename); (void)close(sock); return -1; } if (listen(sock, QLEN) == -1) { - gpsd_report(context.debug, LOG_ERROR, "can't listen on local socket %s\n", filename); + gpsd_report(context.errout.debug, LOG_ERROR, "can't listen on local socket %s\n", filename); (void)close(sock); return -1; } @@ -360,7 +360,7 @@ static socket_t passivesock_af(int af, char *service, char *tcp_or_udp, int qlen port = ntohs((in_port_t) pse->s_port); // cppcheck-suppress unreadVariable else if ((port = (in_port_t) atoi(service)) == 0) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "can't get \"%s\" service entry.\n", service); return -1; } @@ -397,7 +397,7 @@ static socket_t passivesock_af(int af, char *service, char *tcp_or_udp, int qlen /*@-unrecog@*/ /* Set packet priority */ if (setsockopt(s, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) == -1) - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "Warning: SETSOCKOPT TOS failed\n"); } /*@+unrecog@*/ @@ -438,57 +438,57 @@ static socket_t passivesock_af(int af, char *service, char *tcp_or_udp, int qlen if (s > -1) { int on = 1; if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Error: SETSOCKOPT IPV6_V6ONLY\n"); (void)close(s); return -1; } /* Set packet priority */ if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &dscp, sizeof(dscp)) == -1) - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "Warning: SETSOCKOPT TOS failed\n"); } #endif /* S_SPLINT_S */ break; #endif /* IPV6_ENABLE */ default: - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "unhandled address family %d\n", af); return -1; } - gpsd_report(context.debug, LOG_IO, + gpsd_report(context.errout.debug, LOG_IO, "opening %s socket\n", af_str); if (BAD_SOCKET(s)) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "can't create %s socket\n", af_str); return -1; } if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&one, (int)sizeof(one)) == -1) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Error: SETSOCKOPT SO_REUSEADDR\n"); (void)close(s); return -1; } if (bind(s, &sat.sa, sin_len) < 0) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "can't bind to %s port %s, %s\n", af_str, service, strerror(errno)); if (errno == EADDRINUSE) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "maybe gpsd is already running!\n"); } (void)close(s); return -1; } if (type == SOCK_STREAM && listen(s, qlen) == -1) { - gpsd_report(context.debug, LOG_ERROR, "can't listen on port %s\n", service); + gpsd_report(context.errout.debug, LOG_ERROR, "can't listen on port %s\n", service); (void)close(s); return -1; } - gpsd_report(context.debug, LOG_SPIN, "passivesock_af() -> %d\n", s); + gpsd_report(context.errout.debug, LOG_SPIN, "passivesock_af() -> %d\n", s); return s; /*@ +mustfreefresh -matchanyintegral @*/ } @@ -587,11 +587,11 @@ static void detach_client(struct subscriber_t *sub) } c_ip = netlib_sock2ip(sub->fd); (void)shutdown(sub->fd, SHUT_RDWR); - gpsd_report(context.debug, LOG_SPIN, + gpsd_report(context.errout.debug, LOG_SPIN, "close(%d) in detach_client()\n", sub->fd); (void)close(sub->fd); - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "detaching %s (sub %d, fd %d) in detach_client\n", c_ip, sub_index(sub), sub->fd); FD_CLR(sub->fd, &all_fds); @@ -616,9 +616,9 @@ static ssize_t throttled_write(struct subscriber_t *sub, char *buf, { ssize_t status; - if (context.debug >= LOG_CLIENT) { + if (context.errout.debug >= LOG_CLIENT) { if (isprint(buf[0])) - gpsd_report(context.debug, LOG_CLIENT, + gpsd_report(context.errout.debug, LOG_CLIENT, "=> client(%d): %s\n", sub_index(sub), buf); else { char *cp, buf2[MAX_PACKET_LENGTH * 3]; @@ -627,7 +627,7 @@ static ssize_t throttled_write(struct subscriber_t *sub, char *buf, (void)snprintf(buf2 + strlen(buf2), sizeof(buf2) - strlen(buf2), "%02x", (unsigned int)(*cp & 0xff)); - gpsd_report(context.debug, LOG_CLIENT, + gpsd_report(context.errout.debug, LOG_CLIENT, "=> client(%d): =%s\n", sub_index(sub), buf2); } } @@ -643,7 +643,7 @@ static ssize_t throttled_write(struct subscriber_t *sub, char *buf, if (status == (ssize_t) len) return status; else if (status > -1) { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "short write disconnecting client(%d)\n", sub_index(sub)); detach_client(sub); @@ -651,13 +651,13 @@ static ssize_t throttled_write(struct subscriber_t *sub, char *buf, } else if (errno == EAGAIN || errno == EINTR) return 0; /* no data written, and errno says to retry */ else if (errno == EBADF) - gpsd_report(context.debug, LOG_WARN, "client(%d) has vanished.\n", sub_index(sub)); + gpsd_report(context.errout.debug, LOG_WARN, "client(%d) has vanished.\n", sub_index(sub)); else if (errno == EWOULDBLOCK && timestamp() - sub->active > NOREAD_TIMEOUT) - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "client(%d) timed out.\n", sub_index(sub)); else - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "client(%d) write: %s\n", sub_index(sub), strerror(errno)); detach_client(sub); @@ -736,12 +736,12 @@ static bool open_device( /*@null@*/struct gps_device_t *device) * 1PPS derived time data to ntpd/chrony. */ ntpshm_link_activate(device); - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "NTPD ntpshm_link_activate: %d\n", (int)device->shmIndex >= 0); #endif /* NTPSHM_ENABLE */ - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "device %s activated\n", device->gpsdata.dev.path); FD_SET(device->gpsdata.gps_fd, &all_fds); adjust_max_fd(device->gpsdata.gps_fd, true); @@ -755,7 +755,7 @@ bool gpsd_add_device(const char *device_name, bool flag_nowait) bool ret = false; /* we can't handle paths longer than GPS_PATH_MAX, so don't try */ if (strlen(device_name) >= GPS_PATH_MAX) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "ignoring device %s: path length exceeds maximum %d\n", device_name, GPS_PATH_MAX); return false; @@ -767,7 +767,7 @@ bool gpsd_add_device(const char *device_name, bool flag_nowait) #ifdef NTPSHM_ENABLE ntpshm_session_init(devp); #endif /* NTPSHM_ENABLE */ - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "stashing device %s at slot %d\n", device_name, (int)(devp - devices)); if (!flag_nowait) { @@ -820,7 +820,7 @@ static void handle_control(int sfd, char *buf) if (buf[0] == '-') { /* remove device named after - */ (void)snarfline(buf + 1, &stash); - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): removing %s\n", sfd, stash); if ((devp = find_device(stash))) { deactivate_device(devp); @@ -832,12 +832,12 @@ static void handle_control(int sfd, char *buf) /* add device named after + */ (void)snarfline(buf + 1, &stash); if (find_device(stash)) { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): %s already active \n", sfd, stash); ignore_return(write(sfd, "ERROR\n", 6)); } else { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): adding %s\n", sfd, stash); if (gpsd_add_device(stash, NOWAIT)) ignore_return(write(sfd, "OK\n", 3)); @@ -850,7 +850,7 @@ static void handle_control(int sfd, char *buf) (void)snarfline(buf + 1, &stash); eq = strchr(stash, '='); if (eq == NULL) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "<= control(%d): ill-formed command \n", sfd); ignore_return(write(sfd, "ERROR\n", 6)); @@ -858,16 +858,16 @@ static void handle_control(int sfd, char *buf) *eq++ = '\0'; if ((devp = find_device(stash))) { if (devp->context->readonly || (devp->sourcetype <= source_blockdev)) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "<= control(%d): attempted to write to a read-only device\n", sfd); ignore_return(write(sfd, "ERROR\n", 6)); } else { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): writing to %s \n", sfd, stash); if (write(devp->gpsdata.gps_fd, eq, strlen(eq)) <= 0) { - gpsd_report(context.debug, LOG_WARN, "<= control(%d): write to device failed\n", + gpsd_report(context.errout.debug, LOG_WARN, "<= control(%d): write to device failed\n", sfd); ignore_return(write(sfd, "ERROR\n", 6)); } else { @@ -875,7 +875,7 @@ static void handle_control(int sfd, char *buf) } } } else { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): %s not active \n", sfd, stash); ignore_return(write(sfd, "ERROR\n", 6)); @@ -887,7 +887,7 @@ static void handle_control(int sfd, char *buf) (void)snarfline(buf + 1, &stash); eq = strchr(stash, '='); if (eq == NULL) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "<= control(%d): ill-formed command\n", sfd); ignore_return(write(sfd, "ERROR\n", 6)); @@ -897,7 +897,7 @@ static void handle_control(int sfd, char *buf) len = strlen(eq) + 5; if ((devp = find_device(stash)) != NULL) { if (devp->context->readonly || (devp->sourcetype <= source_blockdev)) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "<= control(%d): attempted to write to a read-only device\n", sfd); ignore_return(write(sfd, "ERROR\n", 6)); @@ -906,16 +906,16 @@ static void handle_control(int sfd, char *buf) /* NOTE: this destroys the original buffer contents */ st = gpsd_hexpack(eq, eq, len); if (st <= 0) { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): invalid hex string (error %d).\n", sfd, st); ignore_return(write(sfd, "ERROR\n", 6)); } else { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): writing %d bytes fromhex(%s) to %s\n", sfd, st, eq, stash); if (write(devp->gpsdata.gps_fd, eq, (size_t) st) <= 0) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "<= control(%d): write to device failed\n", sfd); ignore_return(write(sfd, "ERROR\n", 6)); @@ -925,7 +925,7 @@ static void handle_control(int sfd, char *buf) } } } else { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "<= control(%d): %s not active\n", sfd, stash); ignore_return(write(sfd, "ERROR\n", 6)); @@ -954,7 +954,7 @@ static bool awaken(struct gps_device_t *device) /* open that device */ if (!initialized_device(device)) { if (!open_device(device)) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "%s: open failed\n", device->gpsdata.dev.path); free_device(device); @@ -963,19 +963,19 @@ static bool awaken(struct gps_device_t *device) } if (!BAD_SOCKET(device->gpsdata.gps_fd)) { - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "device %d (fd=%d, path %s) already active.\n", (int)(device - devices), device->gpsdata.gps_fd, device->gpsdata.dev.path); return true; } else { if (gpsd_activate(device, O_OPTIMIZE) < 0) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "%s: device activation failed.\n", device->gpsdata.dev.path); return false; } else { - gpsd_report(context.debug, LOG_RAW, + gpsd_report(context.errout.debug, LOG_RAW, "flagging descriptor %d in assign_channel()\n", device->gpsdata.gps_fd); FD_SET(device->gpsdata.gps_fd, &all_fds); @@ -1026,7 +1026,7 @@ static void set_serial(struct gps_device_t *device, } } - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "set_serial(%s,%u,%s) %c%d\n", device->gpsdata.dev.path, (unsigned int)speed, modestring, parity, stopbits); @@ -1141,7 +1141,7 @@ static void handle_request(struct subscriber_t *sub, (void)snprintf(reply, replylen, "{\"class\":\"ERROR\",\"message\":\"Invalid WATCH: %s\"}\r\n", json_error_string(status)); - gpsd_report(context.debug, LOG_ERROR, "response: %s\n", reply); + gpsd_report(context.errout.debug, LOG_ERROR, "response: %s\n", reply); } else if (sub->policy.watcher) { if (sub->policy.devpath[0] == '\0') { /* awaken all devices */ @@ -1159,7 +1159,7 @@ static void handle_request(struct subscriber_t *sub, (void)snprintf(reply, replylen, "{\"class\":\"ERROR\",\"message\":\"No such device as %s\"}\r\n", sub->policy.devpath); - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "response: %s\n", reply); goto bailout; } else if (awaken(devp)) { @@ -1171,7 +1171,7 @@ static void handle_request(struct subscriber_t *sub, (void)snprintf(reply, replylen, "{\"class\":\"ERROR\",\"message\":\"Can't assign %s\"}\r\n", sub->policy.devpath); - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "response: %s\n", reply); goto bailout; } @@ -1207,7 +1207,7 @@ static void handle_request(struct subscriber_t *sub, (void)snprintf(reply, replylen, "{\"class\":\"ERROR\",\"message\":\"Invalid DEVICE: \"%s\"}\r\n", json_error_string(status)); - gpsd_report(context.debug, LOG_ERROR, "response: %s\n", reply); + gpsd_report(context.errout.debug, LOG_ERROR, "response: %s\n", reply); goto bailout; } else { if (devconf.path[0] != '\0') { @@ -1218,7 +1218,7 @@ static void handle_request(struct subscriber_t *sub, (void)snprintf(reply, replylen, "{\"class\":\"ERROR\",\"message\":\"Can't open %s.\"}\r\n", devconf.path); - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "response: %s\n", reply); goto bailout; } @@ -1234,14 +1234,14 @@ static void handle_request(struct subscriber_t *sub, (void)strlcat(reply, "{\"class\":\"ERROR\",\"message\":\"Can't perform DEVICE configuration, no devices attached.\"}\r\n", replylen); - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "response: %s\n", reply); goto bailout; } else if (devcount > 1) { (void)snprintf(reply + strlen(reply), replylen - strlen(reply), "{\"class\":\"ERROR\",\"message\":\"No path specified in DEVICE, but multiple devices are attached.\"}\r\n"); - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "response: %s\n", reply); goto bailout; } @@ -1377,7 +1377,7 @@ static void handle_request(struct subscriber_t *sub, (void)snprintf(reply, replylen, "{\"class\":\"ERROR\",\"message\":\"Unrecognized request '%.*s'\"}\r\n", (int)(errend - buf), buf); - gpsd_report(context.debug, LOG_ERROR, "ERROR response: %s\n", reply); + gpsd_report(context.errout.debug, LOG_ERROR, "ERROR response: %s\n", reply); buf += strlen(buf); } bailout: @@ -1439,7 +1439,7 @@ static void pseudonmea_report(struct subscriber_t *sub, if ((changed & REPORT_IS) != 0) { nmea_tpv_dump(device, buf, sizeof(buf)); - gpsd_report(context.debug, LOG_IO, + gpsd_report(context.errout.debug, LOG_IO, "<= GPS (binary tpv) %s: %s\n", device->gpsdata.dev.path, buf); (void)throttled_write(sub, buf, strlen(buf)); @@ -1447,7 +1447,7 @@ static void pseudonmea_report(struct subscriber_t *sub, if ((changed & SATELLITE_SET) != 0) { nmea_sky_dump(device, buf, sizeof(buf)); - gpsd_report(context.debug, LOG_IO, + gpsd_report(context.errout.debug, LOG_IO, "<= GPS (binary sky) %s: %s\n", device->gpsdata.dev.path, buf); (void)throttled_write(sub, buf, strlen(buf)); @@ -1455,7 +1455,7 @@ static void pseudonmea_report(struct subscriber_t *sub, if ((changed & SUBFRAME_SET) != 0) { nmea_subframe_dump(device, buf, sizeof(buf)); - gpsd_report(context.debug, LOG_IO, + gpsd_report(context.errout.debug, LOG_IO, "<= GPS (binary subframe) %s: %s\n", device->gpsdata.dev.path, buf); (void)throttled_write(sub, buf, strlen(buf)); @@ -1463,7 +1463,7 @@ static void pseudonmea_report(struct subscriber_t *sub, #ifdef AIVDM_ENABLE if ((changed & AIS_SET) != 0) { nmea_ais_dump(device, buf, sizeof(buf)); - gpsd_report(context.debug, LOG_IO, + gpsd_report(context.errout.debug, LOG_IO, "<= AIS (binary ais) %s: %s\n", device->gpsdata.dev.path, buf); (void)throttled_write(sub, buf, strlen(buf)); @@ -1509,7 +1509,7 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) */ if ((changed & RTCM2_SET) != 0 || (changed & RTCM3_SET) != 0) { if (device->lexer.outbuflen > RTCM_MAX) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "overlong RTCM packet (%zd bytes)\n", device->lexer.outbuflen); } else { @@ -1521,10 +1521,10 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) if (dp->device_type->rtcm_writer(dp, (const char *)device->lexer.outbuffer, device->lexer.outbuflen) == 0) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Write to RTCM sink failed\n"); else { - gpsd_report(context.debug, LOG_IO, + gpsd_report(context.errout.debug, LOG_IO, "<= DGPS: %zd bytes of RTCM relayed.\n", device->lexer.outbuflen); } @@ -1550,13 +1550,13 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) * Else we may be providing GPS time. */ if ((changed & TIME_SET) == 0) { - //gpsd_report(context.debug, LOG_PROG, "NTP: No time this packet\n"); + //gpsd_report(context.errout.debug, LOG_PROG, "NTP: No time this packet\n"); } else if (isnan(device->newdata.time)) { - //gpsd_report(context.debug, LOG_PROG, "NTP: bad new time\n"); + //gpsd_report(context.errout.debug, LOG_PROG, "NTP: bad new time\n"); } else if (device->newdata.time == device->last_fixtime.real) { - //gpsd_report(context.debug, LOG_PROG, "NTP: Not a new time\n"); + //gpsd_report(context.errout.debug, LOG_PROG, "NTP: Not a new time\n"); } else if (!device->ship_to_ntpd) { - //gpsd_report(context.debug, LOG_PROG, "NTP: No precision time report\n"); + //gpsd_report(context.errout.debug, LOG_PROG, "NTP: No precision time report\n"); } else { /*@-compdef@*/ struct timedrift_t td; @@ -1628,13 +1628,13 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) if (sub->policy.watcher) { if (changed & DATA_IS) { /* guard keeps mask dumper from eating CPU */ - if (context.debug >= LOG_PROG) - gpsd_report(context.debug, LOG_PROG, + if (context.errout.debug >= LOG_PROG) + gpsd_report(context.errout.debug, LOG_PROG, "Changed mask: %s with %sreliable cycle detection\n", gps_maskdump(changed), device->cycle_end_reliable ? "" : "un"); if ((changed & REPORT_IS) != 0) - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "time to report a fix\n"); if (sub->policy.nmea) @@ -1729,7 +1729,7 @@ static void netgnss_autoconnect(struct gps_context_t *context, FILE *sfp = fopen(serverlist, "r"); if (sfp == NULL) { - gpsd_report(context.debug, LOG_ERROR, "no DGPS server list found.\n"); + gpsd_report(context.errout.debug, LOG_ERROR, "no DGPS server list found.\n"); return; } @@ -1763,7 +1763,7 @@ static void netgnss_autoconnect(struct gps_context_t *context, (void)fclose(sfp); if (keep[0].server[0] == '\0') { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "no DGPS servers within %dm.\n", (int)(DGPS_THRESHOLD / 1000)); return; @@ -1774,7 +1774,7 @@ static void netgnss_autoconnect(struct gps_context_t *context, qsort((void *)keep, SERVER_SAMPLE, sizeof(struct dgps_server_t), srvcmp); for (sp = keep; sp < keep + SERVER_SAMPLE; sp++) { if (sp->server[0] != '\0') { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "%s is %dkm away.\n", sp->server, (int)(sp->dist / 1000)); if (dgpsip_open(context, sp->server) >= 0) @@ -1823,7 +1823,7 @@ int main(int argc, char *argv[]) bool go_background = true; volatile bool in_restart; - context.debug = 0; + context.errout.debug = 0; gps_context_init(&context); #ifdef CONTROL_SOCKET_ENABLE @@ -1836,9 +1836,9 @@ int main(int argc, char *argv[]) while ((option = getopt(argc, argv, "F:D:S:bGhlNnP:V")) != -1) { switch (option) { case 'D': - context.debug = (int)strtol(optarg, 0, 0); + context.errout.debug = (int)strtol(optarg, 0, 0); #ifdef CLIENTDEBUG_ENABLE - gps_enable_debug(context.debug, stderr); + gps_enable_debug(context.errout.debug, stderr); #endif /* CLIENTDEBUG_ENABLE */ break; #ifdef CONTROL_SOCKET_ENABLE @@ -1887,7 +1887,7 @@ int main(int argc, char *argv[]) #ifdef SYSTEMD_ENABLE sd_socket_count = sd_get_socket_count(); if (sd_socket_count > 0 && control_socket != NULL) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "control socket passed on command line ignored\n"); control_socket = NULL; } @@ -1905,7 +1905,7 @@ int main(int argc, char *argv[]) sd_socket_count <= 0 #endif && optind >= argc) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "can't run with neither control socket nor devices\n"); exit(EXIT_FAILURE); } @@ -1926,24 +1926,24 @@ int main(int argc, char *argv[]) if (control_socket) { (void)unlink(control_socket); if (BAD_SOCKET(csock = filesock(control_socket))) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "control socket create failed, netlib error %d\n", csock); exit(EXIT_FAILURE); } else - gpsd_report(context.debug, LOG_SPIN, + gpsd_report(context.errout.debug, LOG_SPIN, "control socket %s is fd %d\n", control_socket, csock); FD_SET(csock, &all_fds); adjust_max_fd(csock, true); - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "control socket opened at %s\n", control_socket); } #endif /* CONTROL_SOCKET_ENABLE */ #else if (optind >= argc) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "can't run with no devices specified\n"); exit(EXIT_FAILURE); } @@ -1955,7 +1955,7 @@ int main(int argc, char *argv[]) if (go_background) { /* not SuS/POSIX portable, but we have our own fallback version */ if (daemon(0, 0) != 0) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "demonization failed: %s\n",strerror(errno)); } /*@+unrecog@*/ @@ -1967,13 +1967,13 @@ int main(int argc, char *argv[]) (void)fprintf(fp, "%u\n", (unsigned int)getpid()); (void)fclose(fp); } else { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Cannot create PID file: %s.\n", pid_file); } } openlog("gpsd", LOG_PID, LOG_USER); - gpsd_report(context.debug, LOG_INF, "launching (Version %s)\n", VERSION); + gpsd_report(context.errout.debug, LOG_INF, "launching (Version %s)\n", VERSION); #ifdef SOCKET_EXPORT_ENABLE /*@ -observertrans @*/ @@ -1982,12 +1982,12 @@ int main(int argc, char *argv[]) getservbyname("gpsd", "tcp") ? "gpsd" : DEFAULT_GPSD_PORT; /*@ +observertrans @*/ if (passivesocks(gpsd_service, "tcp", QLEN, msocks) < 1) { - gpsd_report(context.debug, LOG_ERR, + gpsd_report(context.errout.debug, LOG_ERR, "command sockets creation failed, netlib errors %d, %d\n", msocks[0], msocks[1]); exit(EXIT_FAILURE); } - gpsd_report(context.debug, LOG_INF, "listening on port %s\n", gpsd_service); + gpsd_report(context.errout.debug, LOG_INF, "listening on port %s\n", gpsd_service); #endif /* SOCKET_EXPORT_ENABLE */ #ifdef NTPSHM_ENABLE @@ -1996,7 +1996,7 @@ int main(int argc, char *argv[]) // nice() can ONLY succeed when run as root! // do not even bother as non-root if (nice(NICEVAL) == -1 && errno != 0) - gpsd_report(context.debug, LOG_INF, "NTPD Priority setting failed.\n"); + gpsd_report(context.errout.debug, LOG_INF, "NTPD Priority setting failed.\n"); } /* * By initializing before we drop privileges, we guarantee that even @@ -2010,20 +2010,20 @@ int main(int argc, char *argv[]) /* we need to connect to dbus as root */ if (initialize_dbus_connection()) { /* the connection could not be started */ - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "unable to connect to the DBUS system bus\n"); } else - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "successfully connected to the DBUS system bus\n"); #endif /* defined(DBUS_EXPORT_ENABLE) && !defined(S_SPLINT_S) */ #ifdef SHM_EXPORT_ENABLE /* create the shared segment as root so readers can't mess with it */ if (!shm_acquire(&context)) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "shared-segment creation failed,\n"); } else - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "shared-segment creation succeeded,\n"); #endif /* SHM_EXPORT_ENABLE */ @@ -2035,7 +2035,7 @@ int main(int argc, char *argv[]) in_restart = false; for (i = optind; i < argc; i++) { if (!gpsd_add_device(argv[i], NOWAIT)) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "initial GPS device %s open failed\n", argv[i]); } @@ -2061,7 +2061,7 @@ int main(int argc, char *argv[]) */ /*@-nullpass@*/ if (setgroups(0, NULL) != 0) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "setgroups() failed, errno %s\n", strerror(errno)); /*@+nullpass@*/ @@ -2071,17 +2071,17 @@ int main(int argc, char *argv[]) struct group *grp = getgrnam(GPSD_GROUP); if (grp) if (setgid(grp->gr_gid) != 0) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "setgid() failed, errno %s\n", strerror(errno)); } #else if ((optind < argc && stat(argv[optind], &stb) == 0) || stat(PROTO_TTY, &stb) == 0) { - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "changing to group %d\n", stb.st_gid); if (setgid(stb.st_gid) != 0) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "setgid() failed, errno %s\n", strerror(errno)); } @@ -2089,14 +2089,14 @@ int main(int argc, char *argv[]) pw = getpwnam(GPSD_USER); if (pw) if (setuid(pw->pw_uid) != 0) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "setuid() failed, errno %s\n", strerror(errno)); /*@+type@*/ } - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "running with effective group ID %d\n", getegid()); - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "running with effective user ID %d\n", geteuid()); #ifdef SOCKET_EXPORT_ENABLE @@ -2135,7 +2135,7 @@ int main(int argc, char *argv[]) if (setjmp(restartbuf) > 0) { gpsd_terminate(&context); in_restart = true; - gpsd_report(context.debug, LOG_WARN, "gpsd restarted by SIGHUP\n"); + gpsd_report(context.errout.debug, LOG_WARN, "gpsd restarted by SIGHUP\n"); } signalled = 0; @@ -2160,7 +2160,7 @@ int main(int argc, char *argv[]) if (in_restart) for (i = optind; i < argc; i++) { if (!gpsd_add_device(argv[i], NOWAIT)) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "GPS device %s open failed\n", argv[i]); } @@ -2168,7 +2168,7 @@ int main(int argc, char *argv[]) while (0 == signalled) { fd_set efds; - switch(gpsd_await_data(&rfds, &efds, maxfd, &all_fds, context.debug)) + switch(gpsd_await_data(&rfds, &efds, maxfd, &all_fds, context.errout.debug)) { case AWAIT_GOT_INPUT: break; @@ -2194,7 +2194,7 @@ int main(int argc, char *argv[]) /*@+matchanyintegral@*/ if (BAD_SOCKET(ssock)) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "accept: %s\n", strerror(errno)); else { struct subscriber_t *client = NULL; @@ -2208,7 +2208,7 @@ int main(int argc, char *argv[]) c_ip = netlib_sock2ip(ssock); client = allocate_client(); if (client == NULL) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Client %s connect on fd %d -" "no subscriber slots available\n", c_ip, ssock); @@ -2217,7 +2217,7 @@ int main(int argc, char *argv[]) if (setsockopt (ssock, SOL_SOCKET, SO_LINGER, (char *)&linger, (int)sizeof(struct linger)) == -1) { - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "Error: SETSOCKOPT SO_LINGER\n"); (void)close(ssock); } else { @@ -2226,7 +2226,7 @@ int main(int argc, char *argv[]) adjust_max_fd(ssock, true); client->fd = ssock; client->active = timestamp(); - gpsd_report(context.debug, LOG_SPIN, + gpsd_report(context.errout.debug, LOG_SPIN, "client %s (%d) connect on fd %d\n", c_ip, sub_index(client), ssock); json_version_dump(announce, sizeof(announce)); @@ -2248,10 +2248,10 @@ int main(int argc, char *argv[]) /*@-matchanyintegral@*/ if (BAD_SOCKET(ssock)) - gpsd_report(context.debug, LOG_ERROR, + gpsd_report(context.errout.debug, LOG_ERROR, "accept: %s\n", strerror(errno)); else { - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "control socket connect on fd %d\n", ssock); FD_SET(ssock, &all_fds); @@ -2269,12 +2269,12 @@ int main(int argc, char *argv[]) while ((rd = read(cfd, buf, sizeof(buf) - 1)) > 0) { buf[rd] = '\0'; - gpsd_report(context.debug, LOG_CLIENT, + gpsd_report(context.errout.debug, LOG_CLIENT, "<= control(%d): %s\n", cfd, buf); /* coverity[tainted_data] Safe, never handed to exec */ handle_control(cfd, buf); } - gpsd_report(context.debug, LOG_SPIN, + gpsd_report(context.errout.debug, LOG_SPIN, "close(%d) of control socket\n", cfd); (void)close(cfd); FD_CLR(cfd, &all_fds); @@ -2332,7 +2332,7 @@ int main(int argc, char *argv[]) unlock_subscriber(sub); - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "checking client(%d)\n", sub_index(sub)); if ((buflen = @@ -2342,7 +2342,7 @@ int main(int argc, char *argv[]) if (buf[buflen - 1] != '\n') buf[buflen++] = '\n'; buf[buflen] = '\0'; - gpsd_report(context.debug, LOG_CLIENT, + gpsd_report(context.errout.debug, LOG_CLIENT, "<= client(%d): %s\n", sub_index(sub), buf); /* @@ -2360,7 +2360,7 @@ int main(int argc, char *argv[]) if (!sub->policy.watcher && timestamp() - sub->active > COMMAND_TIMEOUT) { - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "client(%d) timed out on command wait.\n", sub_index(sub)); detach_client(sub); @@ -2396,16 +2396,16 @@ int main(int argc, char *argv[]) device->lexer.type != BAD_PACKET) { if (device->releasetime == 0) { device->releasetime = timestamp(); - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "device %d (fd %d) released\n", (int)(device - devices), device->gpsdata.gps_fd); } else if (timestamp() - device->releasetime > RELEASE_TIMEOUT) { - gpsd_report(context.debug, LOG_PROG, + gpsd_report(context.errout.debug, LOG_PROG, "device %d closed\n", (int)(device - devices)); - gpsd_report(context.debug, LOG_RAW, + gpsd_report(context.errout.debug, LOG_RAW, "unflagging descriptor %d\n", device->gpsdata.gps_fd); deactivate_device(device); @@ -2416,7 +2416,7 @@ int main(int argc, char *argv[]) (device->opentime == 0 || timestamp() - device->opentime > DEVICE_RECONNECT)) { device->opentime = timestamp(); - gpsd_report(context.debug, LOG_INF, + gpsd_report(context.errout.debug, LOG_INF, "reconnection attempt on device %d\n", (int)(device - devices)); (void)awaken(device); @@ -2430,12 +2430,12 @@ int main(int argc, char *argv[]) if (SIGHUP == (int)signalled) longjmp(restartbuf, 1); - gpsd_report(context.debug, LOG_WARN, + gpsd_report(context.errout.debug, LOG_WARN, "received terminating signal %d.\n", signalled); gpsd_terminate(&context); - gpsd_report(context.debug, LOG_WARN, "exiting.\n"); + gpsd_report(context.errout.debug, LOG_WARN, "exiting.\n"); #ifdef SOCKET_EXPORT_ENABLE /* diff --git a/gpsd.h-tail b/gpsd.h-tail index 970865ea..204a0323 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -136,6 +136,11 @@ enum isgpsstat_t { #define SECS_PER_WEEK (7*SECS_PER_DAY) /* seconds per week */ #define GPS_ROLLOVER (1024*SECS_PER_WEEK) /* rollover period */ +struct errout_t { + int debug; /* lexer debug level */ + void (*report)(const char *); /* reporting hook for lexer errors */ +}; + struct gps_lexer_t { /* packet-getter internals */ int type; @@ -177,8 +182,7 @@ struct gps_lexer_t { unsigned long char_counter; /* count characters processed */ unsigned long retry_counter; /* count sniff retries */ unsigned counter; /* packets since last driver switch */ - int debug; /* lexer debug level */ - void (*report)(const char *); /* reporting hook for lexer errors */ + struct errout_t errout; /* how to report errors */ #ifdef TIMING_ENABLE timestamp_t start_time; /* timestamp of first input */ unsigned long start_char; /* char counter at first input */ @@ -209,8 +213,6 @@ struct gps_lexer_t { }; extern void lexer_init(/*@out@*/struct gps_lexer_t *); -extern void lexer_report(const struct gps_lexer_t *, - const int, const char *, ...); 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 *); @@ -239,7 +241,7 @@ struct gps_context_t { #define LEAP_SECOND_VALID 0x01 /* we have or don't need correction */ #define GPS_TIME_VALID 0x02 /* GPS week/tow is valid */ #define CENTURY_VALID 0x04 /* have received ZDA or 4-digit year */ - int debug; /* dehug verbosity level */ + struct errout_t errout; /* debug verbosity level and hook */ bool readonly; /* if true, never write to device */ /* DGPS status */ int fixcnt; /* count of good fixes seen */ @@ -902,6 +904,10 @@ extern void pps_thread_activate(struct gps_device_t *); extern void pps_thread_deactivate(struct gps_device_t *); extern int pps_thread_lastpps(struct gps_device_t *, struct timedrift_t *); +extern void errout_reset(struct errout_t *errout); +extern void gpsd_notify(const struct errout_t *, + const int, const char *, ...); + extern void gpsd_acquire_reporting_lock(void); extern void gpsd_release_reporting_lock(void); @@ -1106,7 +1106,7 @@ int main(int argc, char **argv) nocurses = true; break; case 'D': - context.debug = atoi(optarg); + context.errout.debug = atoi(optarg); break; case 'L': /* list known device types */ (void) @@ -1291,7 +1291,7 @@ int main(int argc, char **argv) for (;;) { fd_set efds; - switch(gpsd_await_data(&rfds, &efds, maxfd, &all_fds, context.debug)) + switch(gpsd_await_data(&rfds, &efds, maxfd, &all_fds, context.errout.debug)) { case AWAIT_GOT_INPUT: break; diff --git a/gpspacket.c b/gpspacket.c index 5d1fbe1f..9d89ec20 100644 --- a/gpspacket.c +++ b/gpspacket.c @@ -40,6 +40,45 @@ void gpsd_report(int unused UNUSED, int errlevel, const char *fmt, ... ) Py_DECREF(args); } +static void basic_report(const char *buf) +{ + (void)fputs(buf, stderr); +} + +void errout_reset(struct errout_t *errout) +{ + errout->debug = 0; + errout->report = basic_report; +} + +void gpsd_notify(const struct errout_t *errout UNUSED, + int errlevel, const char *fmt, ... ) +{ + char buf[BUFSIZ]; + PyObject *args; + va_list ap; + + if (!report_callback) /* no callback defined, exit early */ + return; + + if (!PyCallable_Check(report_callback)) { + PyErr_SetString(ErrorObject, "Cannot call Python callback function"); + return; + } + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + args = Py_BuildValue("(is)", errlevel, buf); + if (!args) + return; + + PyObject_Call(report_callback, args, NULL); + Py_DECREF(args); +} + + static PyTypeObject Lexer_Type; typedef struct { @@ -186,7 +186,7 @@ enum isgpsstat_t isgps_decode(struct gps_lexer_t *lexer, { /* ASCII characters 64-127, @ through DEL */ if ((c & MAG_TAG_MASK) != MAG_TAG_DATA) { - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 1, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 1, "ISGPS word tag not correct, skipping byte\n"); return ISGPS_SKIP; } @@ -206,18 +206,18 @@ enum isgpsstat_t isgps_decode(struct gps_lexer_t *lexer, lexer->isgps.curr_word |= c >> -(lexer->isgps.curr_offset); } - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 2, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 2, "ISGPS syncing at byte %lu: 0x%08x\n", lexer->char_counter, lexer->isgps.curr_word); if (preamble_match(&lexer->isgps.curr_word)) { if (isgps_parityok(lexer->isgps.curr_word)) { - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 1, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 1, "ISGPS preamble ok, parity ok -- locked\n"); lexer->isgps.locked = true; break; } - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 1, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 1, "ISGPS preamble ok, parity fail\n"); } lexer->isgps.curr_offset++; @@ -246,13 +246,13 @@ enum isgpsstat_t isgps_decode(struct gps_lexer_t *lexer, * another preamble pattern in the data stream. -wsr */ if (preamble_match(&lexer->isgps.curr_word)) { - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 2, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 2, "ISGPS preamble spotted (index: %u)\n", lexer->isgps.bufindex); lexer->isgps.bufindex = 0; } #endif - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 2, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 2, "ISGPS processing word %u (offset %d)\n", lexer->isgps.bufindex, lexer->isgps.curr_offset); @@ -263,7 +263,7 @@ enum isgpsstat_t isgps_decode(struct gps_lexer_t *lexer, */ if (lexer->isgps.bufindex >= (unsigned)maxlen) { lexer->isgps.bufindex = 0; - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 1, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 1, "ISGPS buffer overflowing -- resetting\n"); return ISGPS_NO_SYNC; } @@ -274,7 +274,7 @@ enum isgpsstat_t isgps_decode(struct gps_lexer_t *lexer, /* *INDENT-OFF* */ if ((lexer->isgps.bufindex == 0) && !preamble_match((isgps30bits_t *) lexer->isgps.buf)) { - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 1, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 1, "ISGPS word 0 not a preamble- punting\n"); return ISGPS_NO_SYNC; } @@ -298,13 +298,13 @@ enum isgpsstat_t isgps_decode(struct gps_lexer_t *lexer, c >> -(lexer->isgps.curr_offset); } } else { - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 0, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 0, "ISGPS parity failure, lost lock\n"); lexer->isgps.locked = false; } } lexer->isgps.curr_offset -= 6; - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 2, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 2, "ISGPS residual %d\n", lexer->isgps.curr_offset); return res; @@ -312,7 +312,7 @@ enum isgpsstat_t isgps_decode(struct gps_lexer_t *lexer, /*@ +shiftnegative @*/ /* never achieved lock */ - lexer_report(lexer, ISGPS_ERRLEVEL_BASE + 1, + gpsd_notify(&lexer->errout, ISGPS_ERRLEVEL_BASE + 1, "ISGPS lock never achieved\n"); return ISGPS_NO_SYNC; } diff --git a/libgpsd_core.c b/libgpsd_core.c index 3a9ce6ff..5ad37318 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -43,6 +43,33 @@ ssize_t gpsd_write(struct gps_device_t *session, return session->context->serial_write(session, buf, len); } +static void basic_report(const char *buf) +{ + (void)fputs(buf, stderr); +} + +void errout_reset(struct errout_t *errout) +{ + errout->debug = 0; + errout->report = basic_report; +} + +void gpsd_notify(const struct errout_t *errout, + const int errlevel, + const char *fmt, ...) +{ + if (errout->debug >= errlevel) + { + char buf[128]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + errout->report(buf); + va_end(ap); + } +} + #if defined(PPS_ENABLE) static pthread_mutex_t report_mutex; @@ -196,12 +223,12 @@ int gpsd_switch_driver(struct gps_device_t *session, char *type_name) if (first_sync && strcmp(session->device_type->type_name, type_name) == 0) return 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "switch_driver(%s) called...\n", type_name); /*@ -compmempass @*/ for (dp = gpsd_drivers, i = 0; *dp; dp++, i++) if (strcmp((*dp)->type_name, type_name) == 0) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "selecting %s driver...\n", (*dp)->type_name); gpsd_assert_sync(session); @@ -220,7 +247,7 @@ int gpsd_switch_driver(struct gps_device_t *session, char *type_name) #endif /* RECONFIGURE_ENABLE */ return 1; } - gpsd_report(session->context->debug, LOG_ERROR, "invalid GPS type \"%s\".\n", type_name); + gpsd_report(session->context->errout.debug, LOG_ERROR, "invalid GPS type \"%s\".\n", type_name); return 0; /*@ +compmempass @*/ /*@+mustfreeonly@*/ @@ -234,7 +261,6 @@ void gps_context_init(struct gps_context_t *context) /*@ -initallelements -nullassign -nullderef @*/ struct gps_context_t nullcontext = { .valid = 0, - .debug = 0, .readonly = false, .fixcnt = 0, .start_time = 0, @@ -262,6 +288,8 @@ void gps_context_init(struct gps_context_t *context) /* *INDENT-ON* */ (void)memcpy(context, &nullcontext, sizeof(struct gps_context_t)); + errout_reset(&context->errout); + #if !defined(S_SPLINT_S) && defined(PPS_ENABLE) /*@-nullpass@*/ (void)pthread_mutex_init(&report_mutex, NULL); @@ -324,7 +352,7 @@ void gpsd_deactivate(struct gps_device_t *session) session->device_type->mode_switcher(session, 0); } #endif /* RECONFIGURE_ENABLE */ - gpsd_report(session->context->debug, LOG_INF, "closing GPS=%s (%d)\n", + gpsd_report(session->context->errout.debug, LOG_INF, "closing GPS=%s (%d)\n", session->gpsdata.dev.path, session->gpsdata.gps_fd); #if defined(NMEA2000_ENABLE) if (session->sourcetype == source_can) @@ -333,7 +361,7 @@ void gpsd_deactivate(struct gps_device_t *session) #endif /* of defined(NMEA2000_ENABLE) */ (void)gpsd_close(session); if (session->mode == O_OPTIMIZE) - gpsd_run_device_hook(session->context->debug, + gpsd_run_device_hook(session->context->errout.debug, session->gpsdata.dev.path, "DEACTIVATE"); #ifdef PPS_ENABLE @@ -352,7 +380,7 @@ void gpsd_clear(struct gps_device_t *session) session->driver.sirf.satcounter = 0; #endif /* SIRF_ENABLE */ lexer_init(&session->lexer); - session->lexer.debug = session->context->debug; + session->lexer.errout = session->context->errout; // session->gpsdata.online = 0; gps_clear_fix(&session->gpsdata.fix); session->gpsdata.status = STATUS_NO_FIX; @@ -376,7 +404,7 @@ int gpsd_open(struct gps_device_t *session) session->gpsdata.gps_fd = netgnss_uri_open(session, session->gpsdata.dev.path); session->sourcetype = source_tcp; - gpsd_report(session->context->debug, LOG_SPIN, + gpsd_report(session->context->errout.debug, LOG_SPIN, "netgnss_uri_open(%s) returns socket on fd %d\n", session->gpsdata.dev.path, session->gpsdata.gps_fd); return session->gpsdata.gps_fd; @@ -388,21 +416,21 @@ int gpsd_open(struct gps_device_t *session) INVALIDATE_SOCKET(session->gpsdata.gps_fd); port = strchr(server, ':'); if (port == NULL) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Missing colon in TCP feed spec.\n"); return -1; } *port++ = '\0'; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "opening TCP feed at %s, port %s.\n", server, port); if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "tcp")) < 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "TCP device open error %s.\n", netlib_errstr(dsock)); return -1; } else - gpsd_report(session->context->debug, LOG_SPIN, + gpsd_report(session->context->errout.debug, LOG_SPIN, "TCP device opened on fd %d\n", dsock); session->gpsdata.gps_fd = dsock; session->sourcetype = source_tcp; @@ -415,21 +443,21 @@ int gpsd_open(struct gps_device_t *session) INVALIDATE_SOCKET(session->gpsdata.gps_fd); port = strchr(server, ':'); if (port == NULL) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "Missing colon in UDP feed spec.\n"); return -1; } *port++ = '\0'; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "opening UDP feed at %s, port %s.\n", server, port); if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "udp")) < 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "UDP device open error %s.\n", netlib_errstr(dsock)); return -1; } else - gpsd_report(session->context->debug, LOG_SPIN, + gpsd_report(session->context->errout.debug, LOG_SPIN, "UDP device opened on fd %d\n", dsock); session->gpsdata.gps_fd = dsock; session->sourcetype = source_udp; @@ -447,16 +475,16 @@ int gpsd_open(struct gps_device_t *session) port = DEFAULT_GPSD_PORT; } else *port++ = '\0'; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "opening remote gpsd feed at %s, port %s.\n", server, port); if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "tcp")) < 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "remote gpsd device open error %s.\n", netlib_errstr(dsock)); return -1; } else - gpsd_report(session->context->debug, LOG_SPIN, + gpsd_report(session->context->errout.debug, LOG_SPIN, "remote gpsd feed opened on fd %d\n", dsock); /*@+branchstate +nullpass@*/ /* watch to remote is issued when WATCH is */ @@ -479,7 +507,7 @@ int gpsd_activate(struct gps_device_t *session, const int mode) /* acquire a connection to the GPS device */ { if (session->mode == O_OPTIMIZE) - gpsd_run_device_hook(session->context->debug, + gpsd_run_device_hook(session->context->errout.debug, session->gpsdata.dev.path, "ACTIVATE"); session->gpsdata.gps_fd = gpsd_open(session); if (mode != O_CONTINUE) @@ -498,32 +526,32 @@ int gpsd_activate(struct gps_device_t *session, const int mode) /*@ -mustfreeonly @*/ for (dp = gpsd_drivers; *dp; dp++) { if ((*dp)->probe_detect != NULL) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Probing \"%s\" driver...\n", (*dp)->type_name); /* toss stale data */ (void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH); if ((*dp)->probe_detect(session) != 0) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Probe found \"%s\" driver...\n", (*dp)->type_name); session->device_type = *dp; gpsd_assert_sync(session); goto foundit; } else - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Probe not found \"%s\" driver...\n", (*dp)->type_name); } } /*@ +mustfreeonly @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "no probe matched...\n"); } foundit: #endif /* NON_NMEA_ENABLE */ gpsd_clear(session); - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "gpsd_activate(%d): activated GPS (fd %d)\n", session->mode, session->gpsdata.gps_fd); /* @@ -747,7 +775,7 @@ static gps_mask_t fill_dop(const struct gps_data_t * gpsdata, struct dop_t * dop /* If we don't have 4 satellites then we don't have enough information to calculate DOPS */ if (n < 4) { #ifdef __UNUSED__ - gpsd_report(session->context->debug, LOG_DATA + 2, + gpsd_report(session->context->errout.debug, LOG_DATA + 2, "Not enough satellites available %d < 4:\n", n); #endif /* __UNUSED__ */ @@ -758,7 +786,7 @@ static gps_mask_t fill_dop(const struct gps_data_t * gpsdata, struct dop_t * dop memset(inv, 0, sizeof(inv)); #ifdef __UNUSED__ - gpsd_report(session->context->debug, LOG_INF, "Line-of-sight matrix:\n"); + gpsd_report(session->context->errout.debug, LOG_INF, "Line-of-sight matrix:\n"); for (k = 0; k < n; k++) { gpsd_report(debug, LOG_INF, "%f %f %f %f\n", satpos[k][0], satpos[k][1], satpos[k][2], satpos[k][3]); @@ -777,7 +805,7 @@ static gps_mask_t fill_dop(const struct gps_data_t * gpsdata, struct dop_t * dop #ifdef __UNUSED__ gpsd_report(debug, LOG_INF, "product:\n"); for (k = 0; k < 4; k++) { - gpsd_report(session->context->debug, LOG_INF, "%f %f %f %f\n", + gpsd_report(session->context->errout.debug, LOG_INF, "%f %f %f %f\n", prod[k][0], prod[k][1], prod[k][2], prod[k][3]); } #endif /* __UNUSED__ */ @@ -790,7 +818,7 @@ static gps_mask_t fill_dop(const struct gps_data_t * gpsdata, struct dop_t * dop */ gpsd_report(debug, LOG_RAW, "inverse:\n"); for (k = 0; k < 4; k++) { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "%f %f %f %f\n", inv[k][0], inv[k][1], inv[k][2], inv[k][3]); } @@ -1180,10 +1208,10 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) double gap = now - session->lexer.start_time; if (gap > min_cycle) - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "cycle-start detector failed.\n"); else if (gap > quiet_time) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "transmission pause of %f\n", gap); session->sor = now; session->lexer.start_char = session->lexer.char_counter; @@ -1203,7 +1231,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) if (session->device_type != NULL) { newlen = session->device_type->get_packet(session); /* coverity[deref_ptr] */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "%s is known to be %s\n", session->gpsdata.dev.path, session->device_type->type_name); @@ -1212,11 +1240,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) } /* update the scoreboard structure from the GPS */ - gpsd_report(session->context->debug, LOG_RAW + 2, + gpsd_report(session->context->errout.debug, LOG_RAW + 2, "%s sent %zd new characters\n", session->gpsdata.dev.path, newlen); if (newlen < 0) { /* read error */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS on %s returned error %zd (%lf sec since data)\n", session->gpsdata.dev.path, newlen, timestamp() - session->gpsdata.online); @@ -1228,7 +1256,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) * wrong time... */ if (session->gpsdata.online > 0 && timestamp() - session->gpsdata.online >= session->gpsdata.dev.cycle * 2) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS on %s is offline (%lf sec since data)\n", session->gpsdata.dev.path, timestamp() - session->gpsdata.online); @@ -1236,17 +1264,17 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) } return NODATA_IS; } else /* (newlen > 0) */ { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "packet sniff on %s finds type %d\n", 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, + gpsd_report(session->context->errout.debug, LOG_PROG, "synthetic EOF\n"); return EOF_SET; } else - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "comment, sync lock deferred\n"); /* FALL THROUGH */ } else if (session->lexer.type > COMMENT_PACKET) { @@ -1287,7 +1315,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) for (dp = gpsd_drivers; *dp; dp++) if (session->lexer.type == (*dp)->packet_type) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "switching to match packet type %d: %s\n", session->lexer.type, gpsd_prettydump(session)); (void)gpsd_switch_driver(session, (*dp)->type_name); @@ -1299,7 +1327,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) 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, + gpsd_report(session->context->errout.debug, LOG_INF, "hunt on %s failed (%lf sec since data)\n", session->gpsdata.dev.path, timestamp() - session->gpsdata.online); @@ -1308,7 +1336,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) } if (session->lexer.outbuflen == 0) { /* got new data, but no packet */ - gpsd_report(session->context->debug, LOG_RAW + 3, + gpsd_report(session->context->errout.debug, LOG_RAW + 3, "New data on %s, not yet a packet\n", session->gpsdata.dev.path); return ONLINE_SET; @@ -1316,7 +1344,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) gps_mask_t received = PACKET_SET; session->gpsdata.online = timestamp(); - gpsd_report(session->context->debug, LOG_RAW + 3, + gpsd_report(session->context->errout.debug, LOG_RAW + 3, "Accepted packet on %s.\n", session->gpsdata.dev.path); @@ -1327,7 +1355,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) /*@-nullderef@*/ /* coverity[var_deref_op] */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "%s identified as type %s, %f sec @ %ubps\n", session->gpsdata.dev.path, session->device_type->type_name, @@ -1372,8 +1400,8 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) * gpsd_packetdump() function from being called even when the debug * level does not actually require it. */ - if (session->context->debug >= LOG_RAW) - gpsd_report(session->context->debug, LOG_RAW, + if (session->context->errout.debug >= LOG_RAW) + gpsd_report(session->context->errout.debug, LOG_RAW, "raw packet of type %d, %zd:%s\n", session->lexer.type, session->lexer.outbuflen, @@ -1398,7 +1426,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) && session->last_controller != NULL) { session->device_type = session->last_controller; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "reverted to %s driver...\n", session->device_type->type_name); } @@ -1423,7 +1451,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) */ if ((received & SATELLITE_SET) != 0 && session->gpsdata.satellites_visible > 0) { - session->gpsdata.set |= fill_dop(&session->gpsdata, &session->gpsdata.dop, session->context->debug); + session->gpsdata.set |= fill_dop(&session->gpsdata, &session->gpsdata.dop, session->context->errout.debug); session->gpsdata.epe = NAN; } #endif /* CHEAPFLOATS_ENABLE */ @@ -1435,7 +1463,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) /* don't downgrade mode if holding previous fix */ if (session->gpsdata.fix.mode > session->newdata.mode) session->gpsdata.set &= ~MODE_SET; - //gpsd_report(session->context->debug, LOG_PROG, + //gpsd_report(session->context->errout.debug, LOG_PROG, // "transfer mask: %02x\n", session->gpsdata.set); gps_merge_fix(&session->gpsdata.fix, session->gpsdata.set, &session->newdata); @@ -1474,10 +1502,10 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) /*@+relaxtypes +longunsignedintegral@*/ if ((session->gpsdata.set & TIME_SET) != 0) { if (session->newdata.time > time(NULL) + (60 * 60 * 24 * 365)) - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "date more than a year in the future!\n"); else if (session->newdata.time < 0) - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "date is negative!\n"); } /*@-relaxtypes -longunsignedintegral@*/ @@ -1496,7 +1524,7 @@ int gpsd_multipoll(const bool data_ready, { int fragments; - gpsd_report(device->context->debug, LOG_RAW + 1, + gpsd_report(device->context->errout.debug, LOG_RAW + 1, "polling %d\n", device->gpsdata.gps_fd); #ifdef NETFEED_ENABLE @@ -1509,7 +1537,7 @@ int gpsd_multipoll(const bool data_ready, (void)ntrip_open(device, ""); if (device->ntrip.conn_state == ntrip_conn_err) { - gpsd_report(device->context->debug, LOG_WARN, + gpsd_report(device->context->errout.debug, LOG_WARN, "connection to ntrip server failed\n"); device->ntrip.conn_state = ntrip_conn_init; return DEVICE_ERROR; @@ -1523,12 +1551,12 @@ int gpsd_multipoll(const bool data_ready, gps_mask_t changed = gpsd_poll(device); if (changed == EOF_SET) { - gpsd_report(device->context->debug, LOG_WARN, + gpsd_report(device->context->errout.debug, LOG_WARN, "device signed off %s\n", device->gpsdata.dev.path); return DEVICE_EOF; } else if (changed == ERROR_SET) { - gpsd_report(device->context->debug, LOG_WARN, + gpsd_report(device->context->errout.debug, LOG_WARN, "device read of %s returned error or packet sniffer failed sync (flags %s)\n", device->gpsdata.dev.path, gps_maskdump(changed)); @@ -1539,7 +1567,7 @@ int gpsd_multipoll(const bool data_ready, * fd may have been in an end-of-file condition on select. */ if (fragments == 0) { - gpsd_report(device->context->debug, LOG_DATA, + gpsd_report(device->context->errout.debug, LOG_DATA, "%s returned zero bytes\n", device->gpsdata.dev.path); if (device->zerokill) { @@ -1548,11 +1576,11 @@ int gpsd_multipoll(const bool data_ready, if (device->ntrip.works) { device->ntrip.works = false; // reset so we try this once only if (gpsd_activate(device, O_CONTINUE) < 0) { - gpsd_report(device->context->debug, LOG_WARN, + gpsd_report(device->context->errout.debug, LOG_WARN, "reconnect to ntrip server failed\n"); return DEVICE_ERROR; } else { - gpsd_report(device->context->debug, LOG_INFO, + gpsd_report(device->context->errout.debug, LOG_INFO, "reconnecting to ntrip server\n"); return DEVICE_READY; } @@ -1564,7 +1592,7 @@ int gpsd_multipoll(const bool data_ready, * Disable listening to this fd for long enough * that the buffer can fill up again. */ - gpsd_report(device->context->debug, LOG_DATA, + gpsd_report(device->context->errout.debug, LOG_DATA, "%s will be repolled in %f seconds\n", device->gpsdata.dev.path, reawake_time); device->reawake = timestamp() + reawake_time; @@ -1589,13 +1617,13 @@ int gpsd_multipoll(const bool data_ready, break; /* conditional prevents mask dumper from eating CPU */ - if (device->context->debug >= LOG_DATA) { + if (device->context->errout.debug >= LOG_DATA) { if (device->lexer.type == BAD_PACKET) - gpsd_report(device->context->debug, LOG_DATA, + gpsd_report(device->context->errout.debug, LOG_DATA, "packet with bad checksum from %s\n", device->gpsdata.dev.path); else - gpsd_report(device->context->debug, LOG_DATA, + gpsd_report(device->context->errout.debug, LOG_DATA, "packet type %d from %s with %s\n", device->lexer.type, device->gpsdata.dev.path, @@ -1624,7 +1652,7 @@ int gpsd_multipoll(const bool data_ready, } else if (device->reawake>0 && timestamp()>device->reawake) { /* device may have had a zero-length read */ - gpsd_report(device->context->debug, LOG_DATA, + gpsd_report(device->context->errout.debug, LOG_DATA, "%s reawakened after zero-length read\n", device->gpsdata.dev.path); device->reawake = (timestamp_t)0; diff --git a/net_dgpsip.c b/net_dgpsip.c index b74ab758..39c5cf42 100644 --- a/net_dgpsip.c +++ b/net_dgpsip.c @@ -37,7 +37,7 @@ int dgpsip_open(struct gps_device_t *device, const char *dgpsserver) // cppcheck-suppress pointerPositive if (device->gpsdata.gps_fd >= 0) { char hn[256], buf[BUFSIZ]; - gpsd_report(device->context->debug, LOG_PROG, + gpsd_report(device->context->errout.debug, LOG_PROG, "connection to DGPS server %s established.\n", dgpsserver); (void)gethostname(hn, sizeof(hn)); @@ -45,11 +45,11 @@ int dgpsip_open(struct gps_device_t *device, const char *dgpsserver) (void)snprintf(buf, sizeof(buf), "HELO %s gpsd %s\r\nR\r\n", hn, VERSION); if (write(device->gpsdata.gps_fd, buf, strlen(buf)) != (ssize_t) strlen(buf)) - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "hello to DGPS server %s failed\n", dgpsserver); } else - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "can't connect to DGPS server %s, netlib error %d.\n", dgpsserver, device->gpsdata.gps_fd); opts = fcntl(device->gpsdata.gps_fd, F_GETFL); @@ -81,9 +81,9 @@ void dgpsip_report(struct gps_context_t *context, gps->gpsdata.fix.altitude); if (write(dgpsip->gpsdata.gps_fd, buf, strlen(buf)) == (ssize_t) strlen(buf)) - gpsd_report(context->debug, LOG_IO, "=> dgps %s\n", buf); + gpsd_report(context->errout.debug, LOG_IO, "=> dgps %s\n", buf); else - gpsd_report(context->debug, LOG_IO, "write to dgps FAILED\n"); + gpsd_report(context->errout.debug, LOG_IO, "write to dgps FAILED\n"); } } } diff --git a/net_ntrip.c b/net_ntrip.c index 31dd8c20..9f28d678 100644 --- a/net_ntrip.c +++ b/net_ntrip.c @@ -183,12 +183,12 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) if (match) { return 1; } - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "ntrip stream read error %d on fd %d\n", errno, fd); return -1; } else if (rlen == 0) { // server closed the connection - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "ntrip stream unexpected close %d on fd %d during sourcetable read\n", errno, fd); return -1; @@ -197,7 +197,7 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) line = buf; rlen = len += rlen; - gpsd_report(device->context->debug, LOG_RAW, + gpsd_report(device->context->errout.debug, LOG_RAW, "Ntrip source table buffer %s\n", buf); sourcetable = device->ntrip.sourcetable_parse; @@ -211,7 +211,7 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) line += llen; len -= llen; } else { - gpsd_report(device->context->debug, LOG_WARN, + gpsd_report(device->context->errout.debug, LOG_WARN, "Received unexpexted Ntrip reply %s.\n", buf); return -1; @@ -229,7 +229,7 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) if (!(eol = strstr(line, NTRIP_BR))) break; - gpsd_report(device->context->debug, LOG_DATA, + gpsd_report(device->context->errout.debug, LOG_DATA, "next Ntrip source table line %s\n", line); *eol = '\0'; @@ -241,18 +241,18 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) if (strncmp(line, NTRIP_STR, strlen(NTRIP_STR)) == 0) { ntrip_str_parse(line + strlen(NTRIP_STR), (size_t) (llen - strlen(NTRIP_STR)), - &hold, device->context->debug); + &hold, device->context->errout.debug); if (strcmp(device->ntrip.stream.mountpoint, hold.mountpoint) == 0) { /* todo: support for RTCM 3.0, SBAS (WAAS, EGNOS), ... */ if (hold.format == fmt_unknown) { - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "Ntrip stream %s format not supported\n", line); return -1; } /* todo: support encryption and compression algorithms */ if (hold.compr_encryp != cmp_enc_none) { - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "Ntrip stream %s compression/encryption algorithm not supported\n", line); return -1; @@ -260,7 +260,7 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) /* todo: support digest authentication */ if (hold.authentication != auth_none && hold.authentication != auth_basic) { - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "Ntrip stream %s authentication method not supported\n", line); return -1; @@ -290,7 +290,7 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) llen += strlen(NTRIP_BR); line += llen; len -= llen; - gpsd_report(device->context->debug, LOG_RAW, + gpsd_report(device->context->errout.debug, LOG_RAW, "Remaining Ntrip source table buffer %zd %s\n", len, line); } @@ -478,7 +478,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) tmp = amp + 1; url = tmp; } else { - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "can't extract user-ID and password from %s\n", caster); device->ntrip.conn_state = ntrip_conn_err; @@ -491,7 +491,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) stream = slash + 1; } else { /* todo: add autoconnect like in dgpsip.c */ - gpsd_report(device->context->debug, LOG_ERROR, + gpsd_report(device->context->errout.debug, LOG_ERROR, "can't extract Ntrip stream from %s\n", caster); device->ntrip.conn_state = ntrip_conn_err; @@ -528,7 +528,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) sizeof(device->ntrip.stream.port)); ret = ntrip_stream_req_probe(&device->ntrip.stream, - device->context->debug); + device->context->errout.debug); if (ret == -1) { device->ntrip.conn_state = ntrip_conn_err; return -1; @@ -551,7 +551,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) return -1; } ret = ntrip_stream_get_req(&device->ntrip.stream, - device->context->debug); + device->context->errout.debug); if (ret == -1) { device->ntrip.conn_state = ntrip_conn_err; return -1; @@ -562,7 +562,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) case ntrip_conn_sent_get: ret = ntrip_stream_get_parse(&device->ntrip.stream, device->gpsdata.gps_fd, - device->context->debug); + device->context->errout.debug); if (ret == -1) { device->ntrip.conn_state = ntrip_conn_err; return -1; @@ -598,9 +598,9 @@ void ntrip_report(struct gps_context_t *context, gpsd_position_fix_dump(gps, buf, sizeof(buf)); if (write(caster->gpsdata.gps_fd, buf, strlen(buf)) == (ssize_t) strlen(buf)) { - gpsd_report(context->debug, LOG_IO, "=> dgps %s\n", buf); + gpsd_report(context->errout.debug, LOG_IO, "=> dgps %s\n", buf); } else { - gpsd_report(context->debug, LOG_IO, "ntrip report write failed\n"); + gpsd_report(context->errout.debug, LOG_IO, "ntrip report write failed\n"); } } } @@ -140,7 +140,7 @@ static /*@null@*/ volatile struct shmTime *getShmTime(struct gps_context_t *cont shmid = shmget((key_t) (NTPD_BASE + unit), sizeof(struct shmTime), (int)(IPC_CREAT | perms)); if (shmid == -1) { - gpsd_report(context->debug, LOG_ERROR, + gpsd_report(context->errout.debug, LOG_ERROR, "NTPD shmget(%ld, %zd, %o) fail: %s\n", (long int)(NTPD_BASE + unit), sizeof(struct shmTime), (int)perms, strerror(errno)); @@ -149,12 +149,12 @@ static /*@null@*/ volatile struct shmTime *getShmTime(struct gps_context_t *cont p = (struct shmTime *)shmat(shmid, 0, 0); /*@ -mustfreefresh */ if ((int)(long)p == -1) { - gpsd_report(context->debug, LOG_ERROR, + gpsd_report(context->errout.debug, LOG_ERROR, "NTPD shmat failed: %s\n", strerror(errno)); return NULL; } - gpsd_report(context->debug, LOG_PROG, + gpsd_report(context->errout.debug, LOG_PROG, "NTPD shmat(%d,0,0) succeeded, segment %d\n", shmid, unit); return p; @@ -239,7 +239,7 @@ int ntpshm_put(struct gps_device_t *session, int shmIndex, struct timedrift_t *t int precision = -1; /* default precision */ if (shmIndex < 0 || (shmTime = session->context->shmTime[shmIndex]) == NULL) { - gpsd_report(session->context->debug, LOG_RAW, "NTPD missing shm\n"); + gpsd_report(session->context->errout.debug, LOG_RAW, "NTPD missing shm\n"); return 0; } @@ -284,7 +284,7 @@ int ntpshm_put(struct gps_device_t *session, int shmIndex, struct timedrift_t *t shmTime->valid = 1; /*@-type@*/ /* splint is confused about struct timespec */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "NTP ntpshm_put(%d) %lu.%09lu @ %lu.%09lu\n", shmIndex, (unsigned long)td->real.tv_sec, @@ -329,16 +329,16 @@ static void init_hook(struct gps_device_t *session) } if (access(chrony_path, F_OK) != 0) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "PPS chrony socket %s doesn't exist\n", chrony_path); } else { session->chronyfd = netlib_localsocket(chrony_path, SOCK_DGRAM); if (session->chronyfd < 0) - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "PPS connect chrony socket failed: %s, error: %d, errno: %d/%s\n", chrony_path, session->chronyfd, errno, strerror(errno)); else - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "PPS using chrony socket: %s\n", chrony_path); } } @@ -366,7 +366,7 @@ static void chrony_send(struct gps_device_t *session, struct timedrift_t *td) /*@+type@*/ /*@-type@*/ /* splint is confused about struct timespec */ - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "PPS chrony_send %lu.%09lu @ %lu.%09lu Offset: %0.9f\n", (unsigned long)td->real.tv_sec, (unsigned long)td->real.tv_nsec, @@ -434,7 +434,7 @@ void ntpshm_link_activate(struct gps_device_t *session) session->shmIndex = ntpshm_alloc(session->context); if (0 > session->shmIndex) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "NTPD ntpshm_alloc() failed\n"); #if defined(PPS_ENABLE) } else if (session->sourcetype == source_usb || session->sourcetype == source_rs232) { @@ -443,7 +443,7 @@ void ntpshm_link_activate(struct gps_device_t *session) * transitions */ if ((session->shmIndexPPS = ntpshm_alloc(session->context)) < 0) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "NTPD ntpshm_alloc(1) failed\n"); } else { init_hook(session); @@ -119,22 +119,6 @@ enum #include "packet_states.h" }; -void lexer_report(const struct gps_lexer_t *lexer, - const int errlevel, - const char *fmt, ...) -{ - if (lexer->debug >= errlevel) - { - char buf[128]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); - lexer->report(buf); - va_end(ap); - } -} - #define SOH (unsigned char)0x01 #define DLE (unsigned char)0x10 #define STX (unsigned char)0x02 @@ -205,7 +189,7 @@ static void character_pushback(struct gps_lexer_t *lexer) --lexer->inbufptr; /*@+modobserver@*/ --lexer->char_counter; - lexer_report(lexer, LOG_RAW + 2, + gpsd_notify(&lexer->errout, LOG_RAW + 2, "%08ld: character pushed back\n", lexer->char_counter); } @@ -942,7 +926,7 @@ static void nextstate(struct gps_lexer_t *lexer, unsigned char c) n++) csum ^= lexer->inbuffer[n]; if (csum != c) { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "Navcom packet type 0x%hhx bad checksum 0x%hhx, expecting 0x%x\n", lexer->inbuffer[3], csum, c); lexer->state = GROUND_STATE; @@ -1029,14 +1013,14 @@ static void nextstate(struct gps_lexer_t *lexer, unsigned char c) short sum = getword(0) + getword(1) + getword(2) + getword(3); sum *= -1; if (sum != getword(4)) { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "Zodiac Header checksum 0x%hx expecting 0x%hx\n", sum, getword(4)); lexer->state = GROUND_STATE; break; } } - lexer_report(lexer, LOG_RAW + 1, + gpsd_notify(&lexer->errout, LOG_RAW + 1, "Zodiac header id=%hd len=%hd flags=%hx\n", getword(1), getword(2), getword(3)); #undef getword @@ -1167,7 +1151,7 @@ static void nextstate(struct gps_lexer_t *lexer, unsigned char c) if ((c == '>') && (lexer->inbufptr[0] == '<') && (lexer->inbufptr[1] == '!')) { lexer->state = ITALK_RECOGNIZED; - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "ITALK: trying to process runt packet\n"); break; } else if (--lexer->length == 0) @@ -1315,7 +1299,7 @@ static void nextstate(struct gps_lexer_t *lexer, unsigned char c) lexer->state = JSON_STRINGLITERAL; lexer->json_after = JSON_END_ATTRIBUTE; } else { - lexer_report(lexer, LOG_RAW + 2, + gpsd_notify(&lexer->errout, LOG_RAW + 2, "%08ld: missing attribute start after header\n", lexer->char_counter); lexer->state = GROUND_STATE; @@ -1408,9 +1392,9 @@ static void packet_accept(struct gps_lexer_t *lexer, int packet_type) lexer->outbuflen = packetlen; lexer->outbuffer[packetlen] = '\0'; lexer->type = packet_type; - if (lexer->debug >= LOG_RAW+1) { + if (lexer->errout.debug >= LOG_RAW+1) { char scratchbuf[MAX_PACKET_LENGTH*2+1]; - lexer_report(lexer, LOG_RAW+1, + gpsd_notify(&lexer->errout, LOG_RAW+1, "Packet type %d accepted %zu = %s\n", packet_type, packetlen, gpsd_packetdump(scratchbuf, sizeof(scratchbuf), @@ -1418,7 +1402,7 @@ static void packet_accept(struct gps_lexer_t *lexer, int packet_type) lexer->outbuflen)); } } else { - lexer_report(lexer, LOG_ERROR, + gpsd_notify(&lexer->errout, LOG_ERROR, "Rejected too long packet type %d len %zu\n", packet_type, packetlen); } @@ -1431,9 +1415,9 @@ static void packet_discard(struct gps_lexer_t *lexer) size_t remaining = lexer->inbuflen - discard; lexer->inbufptr = memmove(lexer->inbuffer, lexer->inbufptr, remaining); lexer->inbuflen = remaining; - if (lexer->debug >= LOG_RAW+1) { + if (lexer->errout.debug >= LOG_RAW+1) { char scratchbuf[MAX_PACKET_LENGTH*2+1]; - lexer_report(lexer, LOG_RAW + 1, + gpsd_notify(&lexer->errout, LOG_RAW + 1, "Packet discard of %zu, chars remaining is %zu = %s\n", discard, remaining, gpsd_packetdump(scratchbuf, sizeof(scratchbuf), @@ -1446,9 +1430,9 @@ static void character_discard(struct gps_lexer_t *lexer) { memmove(lexer->inbuffer, lexer->inbuffer + 1, (size_t)-- lexer->inbuflen); lexer->inbufptr = lexer->inbuffer; - if (lexer->debug >= LOG_RAW+1) { + if (lexer->errout.debug >= LOG_RAW+1) { char scratchbuf[MAX_PACKET_LENGTH*2+1]; - lexer_report(lexer, LOG_RAW + 1, + gpsd_notify(&lexer->errout, LOG_RAW + 1, "Character discarded, buffer %zu chars = %s\n", lexer->inbuflen, gpsd_packetdump(scratchbuf, sizeof(scratchbuf), @@ -1459,11 +1443,6 @@ static void character_discard(struct gps_lexer_t *lexer) /* get 0-origin big-endian words relative to start of packet buffer */ #define getword(i) (short)(lexer->inbuffer[2*(i)] | (lexer->inbuffer[2*(i)+1] << 8)) -static void basic_lexer_report(const char *buf) -{ - (void)fputs(buf, stderr); -} - /* entry points begin here */ void lexer_init( /*@out@*/ struct gps_lexer_t *lexer) @@ -1477,7 +1456,7 @@ void lexer_init( /*@out@*/ struct gps_lexer_t *lexer) lexer->start_time = 0.0; #endif /* TIMING_ENABLE */ packet_reset(lexer); - lexer->report = basic_lexer_report; + errout_reset(&lexer->errout); } void packet_parse(struct gps_lexer_t *lexer) @@ -1492,7 +1471,7 @@ void packet_parse(struct gps_lexer_t *lexer) #include "packet_names.h" }; nextstate(lexer, c); - lexer_report(lexer, LOG_RAW + 2, + gpsd_notify(&lexer->errout, LOG_RAW + 2, "%08ld: character '%c' [%02x], new state: %s\n", lexer->char_counter, (isprint(c) ? c : '.'), c, state_table[lexer->state]); @@ -1534,7 +1513,7 @@ void packet_parse(struct gps_lexer_t *lexer) && csum[1] == toupper(end[2])); } if (!checksum_ok) { - lexer_report(lexer, LOG_WARN, + gpsd_notify(&lexer->errout, LOG_WARN, "bad checksum in NMEA packet; expected %s.\n", csum); packet_accept(lexer, BAD_PACKET); @@ -1587,11 +1566,11 @@ void packet_parse(struct gps_lexer_t *lexer) for (n = 0; n < lexer->length - 2; n++) a += (unsigned)lexer->inbuffer[n]; b = (unsigned)getleu16(lexer->inbuffer, lexer->length - 2); - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "SuperStarII pkt dump: type %u len %u\n", lexer->inbuffer[1], (unsigned int)lexer->length); if (a != b) { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "REJECT SuperStarII packet type 0x%02x" "%zd bad checksum 0x%04x, expecting 0x%04x\n", lexer->inbuffer[1], lexer->length, a, b); @@ -1615,12 +1594,12 @@ void packet_parse(struct gps_lexer_t *lexer) for (i = 2; i < len - 3; i++) b ^= lexer->inbuffer[i]; if (a == b) { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "Accept OnCore packet @@%c%c len %d\n", lexer->inbuffer[2], lexer->inbuffer[3], len); packet_accept(lexer, ONCORE_PACKET); } else { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "REJECT OnCore packet @@%c%c len %d\n", lexer->inbuffer[2], lexer->inbuffer[3], len); packet_accept(lexer, BAD_PACKET); @@ -1643,7 +1622,7 @@ void packet_parse(struct gps_lexer_t *lexer) if (dlecnt > 2) { dlecnt -= 2; dlecnt /= 2; - lexer_report(lexer, LOG_RAW, + gpsd_notify(&lexer->errout, LOG_RAW, "Unstuffed %d DLEs\n", dlecnt); packetlen -= dlecnt; } @@ -1694,7 +1673,7 @@ void packet_parse(struct gps_lexer_t *lexer) /*@ +charint */ chksum &= 0xff; if (chksum) { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "Garmin checksum failed: %02x!=0\n", chksum); goto not_garmin; } @@ -1702,7 +1681,7 @@ void packet_parse(struct gps_lexer_t *lexer) packet_discard(lexer); break; not_garmin:; - lexer_report(lexer, LOG_RAW + 1, + gpsd_notify(&lexer->errout, LOG_RAW + 1, "Not a Garmin packet\n"); #endif /* GARMIN_ENABLE */ #ifdef TSIP_ENABLE @@ -1753,7 +1732,7 @@ void packet_parse(struct gps_lexer_t *lexer) (0xbc == pkt_id) || (0x38 == pkt_id)) && ((0x41 > pkt_id) || (0x8f < pkt_id))) { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "Packet ID 0x%02x out of range for TSIP\n", pkt_id); goto not_tsip; @@ -1837,14 +1816,14 @@ void packet_parse(struct gps_lexer_t *lexer) /* pass */ ; else { /* pass */ ; - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "TSIP REJECT pkt_id = %#02x, packetlen= %zu\n", pkt_id, packetlen); goto not_tsip; } #undef TSIP_ID_AND_LENGTH /* Debug */ - lexer_report(lexer, LOG_RAW, + gpsd_notify(&lexer->errout, LOG_RAW, "TSIP pkt_id = %#02x, packetlen= %zu\n", pkt_id, packetlen); /*@ -charint +ifempty @*/ @@ -1852,7 +1831,7 @@ void packet_parse(struct gps_lexer_t *lexer) packet_discard(lexer); break; not_tsip: - lexer_report(lexer, LOG_RAW + 1, "Not a TSIP packet\n"); + gpsd_notify(&lexer->errout, LOG_RAW + 1, "Not a TSIP packet\n"); /* * More attempts to recognize ambiguous TSIP-like * packet types could go here. @@ -1871,7 +1850,7 @@ void packet_parse(struct gps_lexer_t *lexer) lexer->inbufptr - lexer->inbuffer)) { packet_accept(lexer, RTCM3_PACKET); } else { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "RTCM3 data checksum failure, " "%0x against %02x %02x %02x\n", crc24q_hash(lexer->inbuffer, @@ -1895,7 +1874,7 @@ void packet_parse(struct gps_lexer_t *lexer) if (len == 0 || sum == getword(5 + len)) { packet_accept(lexer, ZODIAC_PACKET); } else { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "Zodiac data checksum 0x%hx over length %hd, expecting 0x%hx\n", sum, len, getword(5 + len)); packet_accept(lexer, BAD_PACKET); @@ -1912,7 +1891,7 @@ void packet_parse(struct gps_lexer_t *lexer) unsigned char ck_a = (unsigned char)0; unsigned char ck_b = (unsigned char)0; len = lexer->inbufptr - lexer->inbuffer; - lexer_report(lexer, LOG_IO, "UBX: len %d\n", len); + gpsd_notify(&lexer->errout, LOG_IO, "UBX: len %d\n", len); for (n = 2; n < (len - 2); n++) { ck_a += lexer->inbuffer[n]; ck_b += ck_a; @@ -1921,7 +1900,7 @@ void packet_parse(struct gps_lexer_t *lexer) ck_b == lexer->inbuffer[len - 1]) packet_accept(lexer, UBX_PACKET); else { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "UBX checksum 0x%02hhx%02hhx over length %d," " expecting 0x%02hhx%02hhx (type 0x%02hhx%02hhx)\n", ck_a, @@ -1972,7 +1951,7 @@ void packet_parse(struct gps_lexer_t *lexer) goto not_evermore; crc &= 0xff; if (crc != checksum) { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "EverMore checksum failed: %02x != %02x\n", crc, checksum); goto not_evermore; @@ -2014,7 +1993,7 @@ void packet_parse(struct gps_lexer_t *lexer) if (len == 0 || csum == xsum) packet_accept(lexer, ITALK_PACKET); else { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "ITALK: checksum failed - " "type 0x%02x expected 0x%04x got 0x%04x\n", lexer->inbuffer[4], xsum, csum); @@ -2050,7 +2029,7 @@ void packet_parse(struct gps_lexer_t *lexer) if (cs == 0) packet_accept(lexer, GEOSTAR_PACKET); else { - lexer_report(lexer, LOG_IO, + gpsd_notify(&lexer->errout, LOG_IO, "GeoStar checksum failed 0x%x over length %d\n", cs, len); packet_accept(lexer, BAD_PACKET); @@ -2116,18 +2095,18 @@ ssize_t packet_get(int fd, struct gps_lexer_t *lexer) /*@ +modobserver @*/ if (recvd == -1) { if ((errno == EAGAIN) || (errno == EINTR)) { - lexer_report(lexer, LOG_RAW + 2, "no bytes ready\n"); + gpsd_notify(&lexer->errout, LOG_RAW + 2, "no bytes ready\n"); recvd = 0; /* fall through, input buffer may be nonempty */ } else { - lexer_report(lexer, LOG_RAW + 2, + gpsd_notify(&lexer->errout, LOG_RAW + 2, "errno: %s\n", strerror(errno)); return -1; } } else { - if (lexer->debug >= LOG_RAW+1) { + if (lexer->errout.debug >= LOG_RAW+1) { char scratchbuf[MAX_PACKET_LENGTH*2+1]; - lexer_report(lexer, LOG_RAW + 1, + gpsd_notify(&lexer->errout, LOG_RAW + 1, "Read %zd chars to buffer offset %zd (total %zd): %s\n", recvd, lexer->inbuflen, lexer->inbuflen + recvd, gpsd_packetdump(scratchbuf, sizeof(scratchbuf), @@ -2135,7 +2114,7 @@ ssize_t packet_get(int fd, struct gps_lexer_t *lexer) } lexer->inbuflen += recvd; } - lexer_report(lexer, LOG_SPIN, + gpsd_notify(&lexer->errout, LOG_SPIN, "packet_get() fd %d -> %zd (%d)\n", fd, recvd, errno); diff --git a/ppsthread.c b/ppsthread.c index 9bbcdcf6..06d81f3e 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -95,7 +95,7 @@ static int init_kernel_pps(struct gps_device_t *session) session->kernelpps_handle = -1; if ( isatty(session->gpsdata.gps_fd) == 0 ) { - gpsd_report(session->context->debug, LOG_INF, "KPPS gps_fd not a tty\n"); + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS gps_fd not a tty\n"); return -1; } @@ -115,7 +115,7 @@ static int init_kernel_pps(struct gps_device_t *session) /* This activates the magic /dev/pps0 device */ /* Note: this ioctl() requires root */ if ( 0 > ioctl(session->gpsdata.gps_fd, TIOCSETD, &ldisc)) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS cannot set PPS line discipline: %s\n", strerror(errno)); return -1; @@ -144,7 +144,7 @@ static int init_kernel_pps(struct gps_device_t *session) } (void)close(fd); } - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS checking %s, %s\n", globbuf.gl_pathv[i], path); if ( 0 == strncmp( path, session->gpsdata.dev.path, sizeof(path))) { @@ -159,7 +159,7 @@ static int init_kernel_pps(struct gps_device_t *session) globfree(&globbuf); if ( 0 == (int)pps_num ) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS device not found.\n"); return -1; } @@ -168,13 +168,13 @@ static int init_kernel_pps(struct gps_device_t *session) /* root privs are required for this device open */ if ( 0 != getuid() ) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS only works as root \n"); return -1; } ret = open(path, O_RDWR); if ( 0 > ret ) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS cannot open %s: %s\n", path, strerror(errno)); return -1; } @@ -187,14 +187,14 @@ static int init_kernel_pps(struct gps_device_t *session) ret = session->gpsdata.gps_fd; #endif /* assert(ret >= 0); */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS RFC2783 fd is %d\n", ret); /* RFC 2783 implies the time_pps_setcap() needs priviledges * * keep root a tad longer just in case */ if ( 0 > time_pps_create(ret, &session->kernelpps_handle )) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS time_pps_create(%d) failed: %s\n", ret, strerror(errno)); return -1; @@ -204,10 +204,10 @@ static int init_kernel_pps(struct gps_device_t *session) int caps; /* get features supported */ if ( 0 > time_pps_getcap(session->kernelpps_handle, &caps)) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "KPPS time_pps_getcap() failed\n"); } else { - gpsd_report(session->context->debug, + gpsd_report(session->context->errout.debug, LOG_INF, "KPPS caps %0x\n", caps); } @@ -224,7 +224,7 @@ static int init_kernel_pps(struct gps_device_t *session) #endif /* S_SPLINT_S */ if ( 0 > time_pps_setparams(session->kernelpps_handle, &pp)) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "KPPS time_pps_setparams() failed: %s\n", strerror(errno)); time_pps_destroy(session->kernelpps_handle); return -1; @@ -294,7 +294,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) /* we are lucky to have TIOCMIWAIT, so wait for next edge */ #define PPS_LINE_TIOC (TIOCM_CD|TIOCM_CAR|TIOCM_RI|TIOCM_CTS) if (ioctl(session->gpsdata.gps_fd, TIOCMIWAIT, PPS_LINE_TIOC) != 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "PPS ioctl(TIOCMIWAIT) failed: %d %.40s\n", errno, strerror(errno)); break; @@ -310,14 +310,14 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) * not uSec like gettimeofday */ if ( 0 > clock_gettime(CLOCK_REALTIME, &clock_ts) ) { /* uh, oh, can not get time! */ - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "PPS clock_gettime() failed\n"); break; } #else if ( 0 > gettimeofday(&clock_tv, NULL) ) { /* uh, oh, can not get time! */ - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "PPS gettimeofday() failed\n"); break; } @@ -329,7 +329,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) * get the edge state */ /*@ +ignoresigns */ if (ioctl(session->gpsdata.gps_fd, TIOCMGET, &state) != 0) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "PPS ioctl(TIOCMGET) failed\n"); break; } @@ -372,7 +372,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) #endif if ( 0 > time_pps_fetch(session->kernelpps_handle, PPS_TSFMT_TSPEC , &pi, &kernelpps_tv)) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "KPPS kernel PPS failed\n"); } else { // find the last edge @@ -396,7 +396,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) * unsigned long as a wider-or-equal type to * accomodate Linux's type. */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "KPPS assert %ld.%09ld, sequence: %ld - " "clear %ld.%09ld, sequence: %ld\n", pi.assert_timestamp.tv_sec, @@ -405,13 +405,13 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) pi.clear_timestamp.tv_sec, pi.clear_timestamp.tv_nsec, (unsigned long) pi.clear_sequence); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "KPPS data: using %s\n", edge_kpps ? "assert" : "clear"); cycle_kpps = timespec_diff_ns(ts_kpps, pulse_kpps[edge_kpps])/1000; duration_kpps = timespec_diff_ns(ts_kpps, pulse_kpps[(int)(edge_kpps == 0)])/1000; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "KPPS cycle: %7d uSec, duration: %7d uSec @ %lu.%09lu\n", cycle_kpps, duration_kpps, (unsigned long)ts_kpps.tv_sec, @@ -436,18 +436,18 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) if (999000 < cycle && 1001000 > cycle) { duration = 0; unchanged = 0; - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "PPS pps-detect on %s invisible pulse\n", session->gpsdata.dev.path); } else if (++unchanged == 10) { /* not really unchanged, just out of bounds */ unchanged = 1; - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "PPS TIOCMIWAIT returns unchanged state, ppsmonitor sleeps 10\n"); (void)sleep(10); } } else { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "PPS pps-detect on %s changed to %d\n", session->gpsdata.dev.path, state); unchanged = 0; @@ -455,7 +455,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) state_last = state; /* save this edge so we know next cycle time */ pulse[edge] = clock_ts; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "PPS edge: %d, cycle: %7d uSec, duration: %7d uSec @ %lu.%09lu\n", edge, cycle, duration, (unsigned long)clock_ts.tv_sec, @@ -558,7 +558,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) char *log1 = NULL; /* drift.real is the time we think the pulse represents */ struct timedrift_t drift; - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "PPS edge accepted %.100s", log); #if defined(HAVE_SYS_TIMEPPS_H) if ( 0 <= session->kernelpps_handle && ok_kpps) { @@ -595,7 +595,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) offset += ((drift.real.tv_nsec - drift.clock.tv_nsec) / 1e9); delay = (drift.clock.tv_sec + drift.clock.tv_nsec / 1e9) - last_fixtime_clock; if (0.0 > delay || 1.0 < delay) { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "PPS: no current GPS seconds: %f\n", delay); log1 = "timestamp out of range"; @@ -620,7 +620,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) /*@ +unrecog @*/ /*@+compdef@*/ /*@-type@*/ /* splint is confused about struct timespec */ - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "PPS hooks called with %.20s %lu.%09lu offset %.9f\n", log1, (unsigned long)clock_ts.tv_sec, @@ -629,7 +629,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) /*@+type@*/ } /*@-type@*/ /* splint is confused about struct timespec */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "PPS edge %.20s %lu.%09lu offset %.9f\n", log1, (unsigned long)clock_ts.tv_sec, @@ -637,20 +637,20 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) offset); /*@+type@*/ } else { - gpsd_report(session->context->debug, LOG_RAW, + gpsd_report(session->context->errout.debug, LOG_RAW, "PPS edge rejected %.100s", log); } } #if defined(HAVE_SYS_TIMEPPS_H) if (session->kernelpps_handle > 0) { - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "PPS descriptor cleaned up\n"); (void)time_pps_destroy(session->kernelpps_handle); } #endif if (session->thread_wrap_hook != NULL) session->thread_wrap_hook(session); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "PPS gpsd_ppsmonitor exited.\n"); return NULL; } @@ -669,14 +669,14 @@ void pps_thread_activate(struct gps_device_t *session) /* some operations in init_kernel_pps() require root privs */ (void)init_kernel_pps( session ); if ( 0 <= session->kernelpps_handle ) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "KPPS kernel PPS will be used\n"); } #endif /*@-compdef -nullpass@*/ retval = pthread_create(&pt, NULL, gpsd_ppsmonitor, (void *)session); /*@+compdef +nullpass@*/ - gpsd_report(session->context->debug, LOG_PROG, "PPS thread %s\n", + gpsd_report(session->context->errout.debug, LOG_PROG, "PPS thread %s\n", (retval==0) ? "launched" : "FAILED"); } @@ -195,7 +195,7 @@ bool gpsd_set_raw(struct gps_device_t * session) { (void)cfmakeraw(&session->ttyset); if (tcsetattr(session->gpsdata.gps_fd, TCIOFLUSH, &session->ttyset) == -1) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "error changing port attributes: %s\n", strerror(errno)); return false; } @@ -328,7 +328,7 @@ void gpsd_set_speed(struct gps_device_t *session, (void)usleep(200000); (void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH); } - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "speed %u, %d%c%d\n", gpsd_get_speed(session), 9 - stopbits, parity, stopbits); @@ -374,11 +374,11 @@ int gpsd_serial_open(struct gps_device_t *session) if (session->context->readonly || (session->sourcetype <= source_blockdev)) { mode = (mode_t) O_RDONLY; - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "opening read-only GPS data source type %d and at '%s'\n", (int)session->sourcetype, session->gpsdata.dev.path); } else { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "opening GPS data source type %d at '%s'\n", (int)session->sourcetype, session->gpsdata.dev.path); } @@ -395,17 +395,17 @@ int gpsd_serial_open(struct gps_device_t *session) if (connect(session->gpsdata.gps_fd, (struct sockaddr *) &addr, sizeof (addr)) == -1) { if (errno != EINPROGRESS && errno != EAGAIN) { (void)close(session->gpsdata.gps_fd); - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "bluetooth socket connect failed: %s\n", strerror(errno)); return -1; } - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "bluetooth socket connect in progress or again : %s\n", strerror(errno)); } (void)fcntl(session->gpsdata.gps_fd, F_SETFL, (int)mode | O_NONBLOCK); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "bluez device open success: %s %s\n", session->gpsdata.dev.path, strerror(errno)); } else @@ -414,18 +414,18 @@ int gpsd_serial_open(struct gps_device_t *session) if ((session->gpsdata.gps_fd = open(session->gpsdata.dev.path, (int)(mode | O_NONBLOCK | O_NOCTTY))) == -1) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "device open failed: %s - retrying read-only\n", strerror(errno)); if ((session->gpsdata.gps_fd = open(session->gpsdata.dev.path, O_RDONLY | O_NONBLOCK | O_NOCTTY)) == -1) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "read-only device open failed: %s\n", strerror(errno)); return -1; } - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "file device open success: %s\n", strerror(errno)); } @@ -455,7 +455,7 @@ int gpsd_serial_open(struct gps_device_t *session) * Don't touch devices already opened by another process. */ if (fusercount(session->gpsdata.dev.path) > 1) { - gpsd_report(session->context->debug, LOG_ERROR, + gpsd_report(session->context->errout.debug, LOG_ERROR, "%s already opened by another process\n", session->gpsdata.dev.path); (void)close(session->gpsdata.gps_fd); @@ -533,7 +533,7 @@ int gpsd_serial_open(struct gps_device_t *session) session->gpsdata.dev.stopbits = 1; } - gpsd_report(session->context->debug, LOG_SPIN, + gpsd_report(session->context->errout.debug, LOG_SPIN, "open(%s) -> %d in gpsd_serial_open()\n", session->gpsdata.dev.path, session->gpsdata.gps_fd); return session->gpsdata.gps_fd; @@ -551,9 +551,9 @@ ssize_t gpsd_serial_write(struct gps_device_t * session, ok = (status == (ssize_t) len); (void)tcdrain(session->gpsdata.gps_fd); /* extra guard prevents expensive hexdump calls */ - if (session->context->debug >= LOG_IO) { + if (session->context->errout.debug >= LOG_IO) { char scratchbuf[MAX_PACKET_LENGTH*2+1]; - gpsd_report(session->context->debug, LOG_IO, + gpsd_report(session->context->errout.debug, LOG_IO, "=> GPS: %s%s\n", gpsd_packetdump(scratchbuf, sizeof(scratchbuf), (char *)buf, len), ok ? "" : " FAILED"); @@ -664,7 +664,7 @@ void gpsd_close(struct gps_device_t *session) (void)tcsetattr(session->gpsdata.gps_fd, TCSANOW, &session->ttyset_old); } - gpsd_report(session->context->debug, LOG_SPIN, + gpsd_report(session->context->errout.debug, LOG_SPIN, "close(%d) in gpsd_close(%s)\n", session->gpsdata.gps_fd, session->gpsdata.dev.path); (void)close(session->gpsdata.gps_fd); diff --git a/shmexport.c b/shmexport.c index f8645941..4c6b7f96 100644 --- a/shmexport.c +++ b/shmexport.c @@ -37,7 +37,7 @@ bool shm_acquire(struct gps_context_t *context) shmid = shmget((key_t)GPSD_KEY, sizeof(struct gps_data_t), (int)(IPC_CREAT|0666)); if (shmid == -1) { - gpsd_report(context->debug, LOG_ERROR, + gpsd_report(context->errout.debug, LOG_ERROR, "shmget(%ld, %zd, 0666) failed: %s\n", (long int)GPSD_KEY, sizeof(struct gps_data_t), @@ -46,11 +46,11 @@ bool shm_acquire(struct gps_context_t *context) } context->shmexport = (char *)shmat(shmid, 0, 0); if ((int)(long)context->shmexport == -1) { - gpsd_report(context->debug, LOG_ERROR, "shmat failed: %s\n", strerror(errno)); + gpsd_report(context->errout.debug, LOG_ERROR, "shmat failed: %s\n", strerror(errno)); context->shmexport = NULL; return false; } - gpsd_report(context->debug, LOG_PROG, + gpsd_report(context->errout.debug, LOG_PROG, "shmat() succeeded, segment %d\n", shmid); return true; } @@ -22,7 +22,7 @@ gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *session, speed_t speed = gpsd_get_speed(session); if (speed < 38400) - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "speed less than 38,400 may cause data lag and loss of functionality\n"); } @@ -44,7 +44,7 @@ gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *session, * word is inverted. * */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "50B: gpsd_interpret_subframe_raw: " "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", words[0], words[1], words[2], words[3], words[4], @@ -55,7 +55,7 @@ gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *session, words[0] ^= 0x3fffffc0; /* invert */ } else if (preamble != 0x74) { /* strangely this is very common, so don't log it */ - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "50B: gpsd_interpret_subframe_raw: bad preamble 0x%x\n", preamble); return 0; @@ -72,7 +72,7 @@ gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *session, } parity = (uint32_t)isgps_parity((isgps30bits_t)words[i]); if (parity != (words[i] & 0x3f)) { - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "50B: gpsd_interpret_subframe_raw parity fail words[%d] 0x%x != 0x%x\n", i, parity, (words[i] & 0x1)); return 0; @@ -126,7 +126,7 @@ static void subframe_almanac(const struct gps_context_t *context, almp->af0 |= ((words[9] >> 2) & 0x000007); almp->af0 = (short)uint2int(almp->af0, 11); almp->d_af0 = pow(2.0,-20) * almp->af0; - gpsd_report(context->debug, LOG_PROG, + gpsd_report(context->errout.debug, LOG_PROG, "50B: SF:%d SV:%2u TSV:%2u data_id %d e:%g toa:%lu " "deltai:%.10e Omegad:%.5e svh:%u sqrtA:%.10g Omega0:%.10e " "omega:%.10e M0:%.11e af0:%.5e af1:%.5e\n", @@ -164,7 +164,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, /* FIXME!! I really doubt this is Big Endian compatible */ uint8_t preamble; struct subframe_t *subp = &session->gpsdata.subframe; - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "50B: gpsd_interpret_subframe: (%d) " "%06x %06x %06x %06x %06x %06x %06x %06x %06x %06x\n", tSVID, words[0], words[1], words[2], words[3], words[4], @@ -177,7 +177,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, words[0] ^= 0xffffff; } if (preamble != 0x74) { - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "50B: gpsd_interpret_subframe bad preamble: 0x%x header 0x%x\n", preamble, words[0]); return 0; @@ -190,7 +190,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->subframe_num = ((words[1] >> 2) & 0x07); subp->alert = (bool)((words[1] >> 6) & 0x01); subp->antispoof = (bool)((words[1] >> 6) & 0x01); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:%d SV:%2u TOW17:%7lu Alert:%u AS:%u IF:%d\n", subp->subframe_num, subp->tSVID, subp->l_TOW17, (unsigned)subp->alert, (unsigned)subp->antispoof, @@ -234,7 +234,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->sub1.d_af0 = pow(2.0, -31) * subp->sub1.af0; subp->sub1.IODC <<= 8; subp->sub1.IODC |= ((words[7] >> 16) & 0x00FF); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:1 SV:%2u WN:%4u IODC:%4u" " L2:%u ura:%u hlth:%u L2P:%u Tgd:%g toc:%lu af2:%.4g" " af1:%.6e af0:%.7e\n", @@ -279,7 +279,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->sub2.fit = ((words[9] >> 7) & 0x000001); subp->sub2.AODO = ((words[9] >> 2) & 0x00001F); subp->sub2.u_AODO = subp->sub2.AODO * 900; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:2 SV:%2u IODE:%3u Crs:%.6e deltan:%.6e " "M0:%.11e Cuc:%.6e e:%f Cus:%.6e sqrtA:%.11g " "toe:%lu FIT:%u AODO:%5u\n", @@ -323,7 +323,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->sub3.IDOT = (int16_t)((words[9] >> 2) & 0x003FFF); subp->sub3.IDOT = uint2int(subp->sub3.IDOT, 14); subp->sub3.d_IDOT = pow(2.0, -43) * subp->sub3.IDOT; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:3 SV:%2u IODE:%3u I IDOT:%.6g Cic:%.6e Omega0:%.11e " " Cis:%.7g i0:%.11e Crc:%.7g omega:%.11e Omegad:%.6e\n", subp->tSVID, subp->sub3.IODE, subp->sub3.d_IDOT, @@ -477,7 +477,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, } /*@-charint@*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:4-13 data_id %d ai:%u " "ERD1:%d ERD2:%d ERD3:%d ERD4:%d " "ERD5:%d ERD6:%d ERD7:%d ERD8:%d " @@ -556,7 +556,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->sub4_25.svhx[6] = ((words[9] >> 12) & 0x00003F); subp->sub4_25.svhx[7] = ((words[9] >> 6) & 0x00003F); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:4-25 data_id %d " "SV1:%u SV2:%u SV3:%u SV4:%u " "SV5:%u SV6:%u SV7:%u SV8:%u " @@ -663,7 +663,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->sub4_17.str[i++] = (words[9] >> 8) & 0xff; subp->sub4_17.str[i] = '\0'; /*@ +type @*/ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:4-17 system message: %.24s\n", subp->sub4_17.str); break; @@ -714,7 +714,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, /* leap second future */ subp->sub4_18.lsf = (int8_t)((words[9] >> 16) & 0x0000FF); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:4-18 a0:%.5g a1:%.5g a2:%.5g a3:%.5g " "b0:%.5g b1:%.5g b2:%.5g b3:%.5g " "A1:%.11e A0:%.11e tot:%.5g WNt:%u " @@ -758,7 +758,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, &subp->sub4.almanac); } else if ( -2 == sv ) { /* unknown or secret page */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:4-%d data_id %d\n", subp->pageid, subp->data_id); return 0; @@ -808,7 +808,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->sub5_25.sv[22] = ((words[7] >> 12) & 0x00003F); subp->sub5_25.sv[23] = ((words[7] >> 6) & 0x00003F); subp->sub5_25.sv[24] = ((words[7] >> 0) & 0x00003F); - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:5-25 SV:%2u ID:%u toa:%lu WNa:%u " "SV1:%u SV2:%u SV3:%u SV4:%u " "SV5:%u SV6:%u SV7:%u SV8:%u " @@ -832,7 +832,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, subp->sub5_25.sv[23], subp->sub5_25.sv[24]); } else { /* unknown page */ - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "50B: SF:5-%d data_id %d uknown page\n", subp->pageid, subp->data_id); return 0; diff --git a/test_packet.c b/test_packet.c index 5adadd47..f0e5b503 100644 --- a/test_packet.c +++ b/test_packet.c @@ -272,21 +272,21 @@ static struct map runontests[] = { static int packet_test(struct map *mp) { - struct gps_lexer_t packet; + struct gps_lexer_t lexer; int failure = 0; - lexer_init(&packet); - packet.debug = verbose; - /*@i@*/ memcpy(packet.inbufptr = packet.inbuffer, mp->test, mp->testlen); - packet.inbuflen = mp->testlen; + lexer_init(&lexer); + lexer.errout.debug = verbose; + /*@i@*/ memcpy(lexer.inbufptr = lexer.inbuffer, mp->test, mp->testlen); + lexer.inbuflen = mp->testlen; /*@ -compdef -uniondef -usedef -formatcode @*/ - packet_parse(&packet); - if (packet.type != mp->type) + packet_parse(&lexer); + if (lexer.type != mp->type) printf("%2zi: %s test FAILED (packet type %d wrong).\n", - mp - singletests + 1, mp->legend, packet.type); + mp - singletests + 1, mp->legend, lexer.type); else if (memcmp - (mp->test + mp->garbage_offset, packet.outbuffer, - packet.outbuflen)) { + (mp->test + mp->garbage_offset, lexer.outbuffer, + lexer.outbuflen)) { printf("%2zi: %s test FAILED (data garbled).\n", mp - singletests + 1, mp->legend); ++failure; @@ -299,18 +299,18 @@ static int packet_test(struct map *mp) static void runon_test(struct map *mp) { - struct gps_lexer_t packet; + struct gps_lexer_t lexer; int nullfd = open("/dev/null", O_RDONLY); ssize_t st; - lexer_init(&packet); - packet.debug = verbose; - /*@i@*/ memcpy(packet.inbufptr = packet.inbuffer, mp->test, mp->testlen); - packet.inbuflen = mp->testlen; + lexer_init(&lexer); + lexer.errout.debug = verbose; + /*@i@*/ memcpy(lexer.inbufptr = lexer.inbuffer, mp->test, mp->testlen); + lexer.inbuflen = mp->testlen; /*@ -compdef -uniondef -usedef -formatcode @*/ (void)fputs(mp->test, stdout); do { - st = packet_get(nullfd, &packet); + st = packet_get(nullfd, &lexer); //printf("packet_parse() returned %zd\n", st); } while (st > 0); /*@ +compdef +uniondef +usedef +formatcode @*/ @@ -222,7 +222,7 @@ void gpsd_time_init(struct gps_context_t *context, time_t starttime) context->rollovers = (int)((context->start_time-GPS_EPOCH) / GPS_ROLLOVER); if (context->start_time < GPS_EPOCH) - gpsd_report(context->debug, LOG_ERROR, + gpsd_report(context->errout.debug, LOG_ERROR, "system time looks bogus, dates may not be reliable.\n"); else { /* we've forced the UTC timezone, so this is actually UTC */ @@ -235,7 +235,7 @@ void gpsd_time_init(struct gps_context_t *context, time_t starttime) now->tm_year += 1900; context->century = now->tm_year - (now->tm_year % 100); (void)unix_to_iso8601((timestamp_t)context->start_time, scr, sizeof(scr)); - gpsd_report(context->debug, LOG_INF, + gpsd_report(context->errout.debug, LOG_INF, "startup at %s (%d)\n", scr, (int)context->start_time); } @@ -290,7 +290,7 @@ timestamp_t gpsd_utc_resolve(/*@in@*/struct gps_device_t *session) if (session->newdata.time < (timestamp_t)session->context->start_time) { char scr[128]; (void)unix_to_iso8601(session->newdata.time, scr, sizeof(scr)); - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "GPS week rollover makes time %s (%f) invalid\n", scr, session->newdata.time); } @@ -309,14 +309,14 @@ void gpsd_century_update(/*@in@*/struct gps_device_t *session, int century) * certainly it means that a century mark has passed while * gpsd was running, and we should trust the new ZDA year. */ - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "century rollover detected.\n"); session->context->century = century; } else if (session->context->start_time >= GPS_EPOCH && century < session->context->century) { /* * This looks like a GPS week-counter rollover. */ - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "ZDA year less than clock year, " "probable GPS week rollover lossage\n"); session->context->valid &=~ CENTURY_VALID; @@ -337,7 +337,7 @@ timestamp_t gpsd_gpstime_resolve(/*@in@*/struct gps_device_t *session, * to 13 bits. */ if ((int)week < (session->context->gps_week & 0x3ff)) { - gpsd_report(session->context->debug, LOG_INF, + gpsd_report(session->context->errout.debug, LOG_INF, "GPS week 10-bit rollover detected.\n"); ++session->context->rollovers; } |