diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2014-08-27 16:42:04 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-08-27 16:42:04 -0400 |
commit | 995976ab06a8f688343b8fec87e1305e2d5ee80e (patch) | |
tree | 104bf6b57b68676529409f4374cc5881b07b1e7b /driver_garmin.c | |
parent | 6203e5b8fcac9d78ea54b7b3c53cb8d084e8a219 (diff) | |
download | gpsd-995976ab06a8f688343b8fec87e1305e2d5ee80e.tar.gz |
The big leap. Most instances of gpsd_report are replaced...
...with calls to gps_notify(), which indirects to its output method
through a slot in an errout structure. Usually the errout structure
lives inside the session context, but because struct errout_t is its
own thing this does not have to be the case. One large clique of
gpsd_notify() calls, in packet.c and isgps.c, looks at a struct
errout_t copy in a lexer control block
This change is not complete. Remnant gpsd_report calls need to be changed,
and gpsmon needs to be tweaked so that the struct_error_t in its context
is a non-defaukt hook updating the cuses display rather than simply
dumping to stderr. Also the report label functionality needs to be added.
All regression tests pass.
Diffstat (limited to 'driver_garmin.c')
-rw-r--r-- | driver_garmin.c | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/driver_garmin.c b/driver_garmin.c index 792dbaa3..27200b49 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->errout.debug, LOG_DATA, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, "Garmin: ACK\n"); + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: ACK\n"); break; case NAK: - gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin: NAK\n"); + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: Appl, Command Data: %s\n", msg); break; case GARMIN_PKTID_PRODUCT_RQST: - gpsd_report(session->context->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, LOG_INF, "Garmin: Product ID: %d, SoftVer: %d.%02d\n", prod_id, maj_ver, min_ver); - gpsd_report(session->context->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, LOG_INF, "Garmin: Product Desc: %s\n", &buf[4]); mask |= DEVICEID_SET; - gpsd_report(session->context->errout.debug, LOG_DATA, + gpsd_notify(&session->context->errout, LOG_DATA, "Garmin: PRODUCT_DATA: subtype=%s\n", session->subtype); break; case GARMIN_PKTID_PVT_DATA: - gpsd_report(session->context->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, LOG_INF, "Garmin: ERROR: Latitude overrange\n"); } else if (-90.0 > session->newdata.latitude) { session->newdata.latitude = -90.0; - gpsd_report(session->context->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, LOG_INF, "Garmin: ERROR: Longitude overrange\n"); } else if (-180.0 > session->newdata.longitude) { session->newdata.longitude = -180.0; - gpsd_report(session->context->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: Appl, mode %d, status %d\n", session->newdata.mode, session->gpsdata.status); - gpsd_report(session->context->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, LOG_INF, "Garmin: UTC Time: %lf\n", session->newdata.time); - gpsd_report(session->context->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_DATA, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_DATA, + gpsd_notify(&session->context->errout, LOG_DATA, "Garmin: PVT RMD Data Sz: %d\n", pkt_len); - gpsd_report(session->context->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_DATA, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, LOG_INF, "Garmin: Appl, Product Capability, sz: %d\n", pkt_len); for (i = 0; i < pkt_len; i += 3) { - gpsd_report(session->context->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, LOG_INF, "Garmin: %c%03d\n", buf[i], get_uint16((uint8_t *) & buf[i + 1])); } break; default: - gpsd_report(session->context->errout.debug, LOG_WARN, + gpsd_notify(&session->context->errout, LOG_WARN, "Garmin: Unknown packet id: %#02x, Sz: %#02x\n", pkt_id, pkt_len); break; } - gpsd_report(session->context->errout.debug, LOG_DATA, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, "Garmin: PrintUSBPacket()\n"); + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: PrintUSBPacket()\n"); // gem if (DLE == pkt->mPacketType) { - gpsd_report(session->context->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_WARN, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: Transport, Start Session resp, unit: 0x%x\n", mode); break; default: - gpsd_report(session->context->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: Private, Set Mode: %d\n", prod_id); break; case PRIV_PKTID_INFO_REQ: - gpsd_report(session->context->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: Private, ID: Info Resp\n"); - gpsd_report(session->context->errout.debug, LOG_INF, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: Private, Packet: ID: %d, Sz: %d\n", pkt->mPacketId, mDataSize); break; } break; default: - gpsd_report(session->context->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: SendPacket(), wrote %zd bytes\n", theBytesReturned); @@ -945,7 +945,7 @@ static bool garmin_usb_detect(struct gps_device_t *session UNUSED) return false; if (!gpsd_set_raw(session)) { - gpsd_report(session->context->errout.debug, LOG_ERROR, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_ERROR, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, "Garmin: Get Product Data\n"); + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW, "Garmin: garmin_ser_parse()\n"); + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, LOG_RAW + 1, "Garmin: serial too short: %zd\n", len); return 0; } /* debug */ for (i = 0; i < (int)len; i++) { - gpsd_report(session->context->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, LOG_RAW + 1, "Garmin: Char: %#02x\n", buf[i]); } if ('\x10' != buf[0]) { Send_NAK(); - gpsd_report(session->context->errout.debug, LOG_RAW + 1, "Garmin: buf[0] not DLE\n"); + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, "Garmin: Bad pkt_id %#02x\n", pkt_id); + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, "Garmin: Final DLE not DLE\n"); + gpsd_notify(&session->context->errout, LOG_RAW + 1, "Garmin: Final DLE not DLE\n"); return 0; } /* get final ETX */ if (len < n + i) { Send_NAK(); - gpsd_report(session->context->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW + 1, + gpsd_notify(&session->context->errout, LOG_RAW + 1, "Garmin: Char: %#02x\n", data_buf[i]); } - gpsd_report(session->context->errout.debug, LOG_DATA, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_DATA, "Garmin: garmin_ser_parse( )\n"); + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: => GPS: turn off binary %02x %02x %02x... \n", switcher[0], switcher[1], switcher[2]); } else { - gpsd_report(session->context->errout.debug, LOG_ERROR, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_DATA, "Garmin: GetPacket()\n"); + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_ERROR, + gpsd_notify(&session->context->errout, LOG_ERROR, "Garmin: GetPacket() read error=%d, errno=%d\n", theBytesReturned, errno); continue; } - gpsd_report(session->context->errout.debug, LOG_RAW, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_ERROR, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_ERROR, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_RAW+1, "Garmin: p[%d] = %x\n", x, session->driver.garmin.Buffer[x]); + // gpsd_notify(&session->context->errout, LOG_RAW+1, "Garmin: p[%d] = %x\n", x, session->driver.garmin.Buffer[x]); // } if (10 <= cnt) { - gpsd_report(session->context->errout.debug, LOG_ERROR, + gpsd_notify(&session->context->errout, LOG_ERROR, "Garmin: GetPacket() packet too long or too slow!\n"); return -1; } - gpsd_report(session->context->errout.debug, LOG_RAW, + gpsd_notify(&session->context->errout, 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->errout.debug, LOG_PROG, "Garmin: garmin_usb_parse()\n"); + gpsd_notify(&session->context->errout, LOG_PROG, "Garmin: garmin_usb_parse()\n"); return PrintUSBPacket(session, (Packet_t *) session->driver.garmin.Buffer); } |