diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2008-12-27 09:15:40 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2008-12-27 09:15:40 +0000 |
commit | e6b2b986ff8c91f2ec1f8dbc05a62f5bf9fcd91b (patch) | |
tree | a0b4e270d5b7fdf0c2e9aa2551c29bce51dc088a | |
parent | d4bee24389232b37dd0ae816789806f8fe1f34fa (diff) | |
download | gpsd-e6b2b986ff8c91f2ec1f8dbc05a62f5bf9fcd91b.tar.gz |
Add a wrapper function around gpsd_hexdump to avoid hexdumping buffers...
...and copying ascii strings around when they're not going to be printed.
This saves quite a lot of CPU. I processed a 50MB ubx binary file. With
no "-D" options, this saved nearly 2.2M calls to gpsd_hexdump and the
processing time for this file went from 84 seconds to 35 seconds.
-rw-r--r-- | bits.c | 3 | ||||
-rw-r--r-- | driver_proto.c | 4 | ||||
-rw-r--r-- | drivers.c | 11 | ||||
-rw-r--r-- | evermore.c | 18 | ||||
-rw-r--r-- | garmin.c | 24 | ||||
-rw-r--r-- | garmin_txt.c | 7 | ||||
-rw-r--r-- | gpsd.c | 3 | ||||
-rw-r--r-- | gpsd.h-tail | 1 | ||||
-rw-r--r-- | hex.c | 19 | ||||
-rw-r--r-- | italk.c | 5 | ||||
-rw-r--r-- | navcom.c | 5 | ||||
-rw-r--r-- | packet.c | 26 | ||||
-rw-r--r-- | serial.c | 3 | ||||
-rw-r--r-- | sirf.c | 33 | ||||
-rw-r--r-- | tsip.c | 6 | ||||
-rw-r--r-- | ubx.c | 12 |
16 files changed, 117 insertions, 63 deletions
@@ -31,7 +31,8 @@ unsigned long long ubits(char buf[], unsigned int start, unsigned int width) fld |= (unsigned char)buf[i]; } #ifdef DEBUG - printf("Extracting %d:%d from %s: segment 0x%llx = %lld\n", start, width, gpsd_hexdump(buf, 12), fld, fld); + printf("Extracting %d:%d from %s: segment 0x%llx = %lld\n", start, width, + gpsd_hexdump(buf, 12), fld, fld); #endif /* DEBUG */ end = (start + width) % BITS_PER_BYTE; diff --git a/driver_proto.c b/driver_proto.c index 9d49938e..6e277e26 100644 --- a/driver_proto.c +++ b/driver_proto.c @@ -192,7 +192,7 @@ static bool proto_write(int fd, unsigned char *msg, size_t msglen) /* we may need to dump the message */ gpsd_report(LOG_IO, "writing proto control type %02x:%s\n", - msg[0], gpsd_hexdump(msg, msglen)); + msg[0], gpsd_hexdump_wrapper(msg, msglen, LOG_IO)); ok = (write(fd, msg, msglen) == (ssize_t)msglen); (void)tcdrain(fd); return(ok); @@ -232,7 +232,7 @@ gps_mask_t proto_dispatch(struct gps_device_t *session, unsigned char *buf, size default: /* XXX This gets noisy in a hurry. Change once your driver works */ gpsd_report(LOG_WARN, "unknown packet id %d length %d: %s\n", - type, len, gpsd_hexdump(buf, len)); + type, len, gpsd_hexdump_wrapper(buf, len, LOG_WARN)); return 0; } } @@ -775,9 +775,9 @@ static gps_mask_t rtcm104v2_analyze(struct gps_device_t *session) { rtcm2_unpack(&session->gpsdata.rtcm2, (char *)session->packet.isgps.buf); gpsd_report(LOG_RAW, "RTCM 2.x packet type 0x%02x length %d words: %s\n", - session->gpsdata.rtcm2.type, - session->gpsdata.rtcm2.length+2, - gpsd_hexdump(session->packet.isgps.buf, (session->gpsdata.rtcm2.length+2)*sizeof(isgps30bits_t))); + session->gpsdata.rtcm2.type, session->gpsdata.rtcm2.length+2, + gpsd_hexdump_wrapper(session->packet.isgps.buf, + (session->gpsdata.rtcm2.length+2)*sizeof(isgps30bits_t), LOG_RAW)); return RTCM2_SET; } @@ -818,9 +818,8 @@ static gps_mask_t rtcm104v3_analyze(struct gps_device_t *session) uint type = getbeuw(session->packet.inbuffer, 3) >> 4; gpsd_report(LOG_RAW, "RTCM 3.x packet type %d length %d words: %s\n", - type, length, - gpsd_hexdump(session->packet.inbuffer, - (size_t)(session->gpsdata.rtcm3.length))); + type, length, gpsd_hexdump_wrapper(session->packet.inbuffer, + (size_t)(session->gpsdata.rtcm3.length), LOG_RAW)); return RTCM3_SET; } @@ -169,7 +169,7 @@ static bool evermore_write(struct gps_device_t *session, unsigned char *msg, siz /* we may need to dump the message */ gpsd_report(LOG_IO, "writing EverMore control type 0x%02x: %s\n", msg[0], - gpsd_hexdump(stuffed, len)); + gpsd_hexdump_wrapper(stuffed, len, LOG_IO)); #ifdef ALLOW_RECONFIGURE return (gpsd_write(session, stuffed, len) == (ssize_t)len); #else @@ -196,7 +196,8 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size if (*cp == 0x10) cp++; datalen = (size_t)*cp++; - gpsd_report(LOG_RAW, "raw EverMore packet type 0x%02x, length %d: %s\n", *cp, len, gpsd_hexdump(buf, len)); + gpsd_report(LOG_RAW, "raw EverMore packet type 0x%02x, length %d: %s\n", + *cp, len, gpsd_hexdump_wrapper(buf, len, LOG_RAW)); datalen -= 2; @@ -207,7 +208,8 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size } /*@ -usedef -compdef @*/ - gpsd_report(LOG_RAW, "EverMore packet type 0x%02x, length %d: %s\n", buf2[0], datalen, gpsd_hexdump(buf2, datalen)); + gpsd_report(LOG_RAW, "EverMore packet type 0x%02x, length %d: %s\n", + buf2[0], datalen, gpsd_hexdump_wrapper(buf2, datalen, LOG_RAW)); /*@ +usedef +compdef @*/ (void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag), @@ -337,11 +339,13 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size return TIME_SET; case 0x20: /* LogConfig Info, could be used as a probe for EverMore GPS */ - gpsd_report(LOG_IO, "LogConfig EverMore packet, length %d: %s\n", datalen, gpsd_hexdump(buf2, datalen)); + gpsd_report(LOG_IO, "LogConfig EverMore packet, length %d: %s\n", + datalen, gpsd_hexdump_wrapper(buf2, datalen, LOG_IO)); return ONLINE_SET; case 0x22: /* LogData */ - gpsd_report(LOG_IO, "LogData EverMore packet, length %d: %s\n", datalen, gpsd_hexdump(buf2, datalen)); + gpsd_report(LOG_IO, "LogData EverMore packet, length %d: %s\n", + datalen, gpsd_hexdump_wrapper(buf2, datalen, LOG_IO)); return ONLINE_SET; case 0x38: /* ACK */ @@ -349,7 +353,9 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size return ONLINE_SET; default: - gpsd_report(LOG_WARN, "unknown EverMore packet id 0x%02x, length %d: %s\n", buf2[0], datalen, gpsd_hexdump(buf2, datalen)); + gpsd_report(LOG_WARN, + "unknown EverMore packet id 0x%02x, length %d: %s\n", buf2[0], + datalen, gpsd_hexdump_wrapper(buf2, datalen, LOG_IO)); return 0; } } @@ -503,12 +503,13 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id } break; default: - gpsd_report(LOG_WARN, "Unknown packet id: %#02x, Sz: %#02x, pkt:%s\n" - , pkt_id, pkt_len, gpsd_hexdump(buf, (size_t)pkt_len)); + gpsd_report(LOG_WARN, "Unknown packet id: %#02x, Sz: %#02x, pkt:%s\n", + pkt_id, pkt_len, + gpsd_hexdump_wrapper(buf, (size_t)pkt_len, LOG_WARN)); break; } - gpsd_report(LOG_IO, "PrintSERPacket(, %#02x, %#02x, ) = %#02x\n" - , pkt_id, pkt_len, mask); + gpsd_report(LOG_IO, "PrintSERPacket(, %#02x, %#02x, ) = %#02x\n", + pkt_id, pkt_len, mask); return mask; } @@ -638,8 +639,9 @@ static void Build_Send_USB_Packet( struct gps_device_t *session, } #if 0 - gpsd_report(LOG_IO, "SendPacket(), writing %d bytes: %s\n" - , theBytesToWrite, gpsd_hexdump(thePacket, theBytesToWrite)); + gpsd_report(LOG_IO, "SendPacket(), writing %d bytes: %s\n", + theBytesToWrite, + gpsd_hexdump_wrapper(thePacket, theBytesToWrite, LOG_IO)); #endif (void)PrintUSBPacket ( session, thePacket); @@ -705,8 +707,9 @@ static void Build_Send_SER_Packet( struct gps_device_t *session, *buffer++ = (uint8_t)ETX; #if 1 - gpsd_report(LOG_IO, "SendPacket(), writing %d bytes: %s\n" - , theBytesToWrite, gpsd_hexdump(thePacket, (size_t)theBytesToWrite)); + gpsd_report(LOG_IO, "SendPacket(), writing %d bytes: %s\n", + theBytesToWrite, + gpsd_hexdump_wrapper(thePacket, (size_t)theBytesToWrite, LOG_IO)); #endif (void)PrintSERPacket ( session, (unsigned char)buffer0[1], @@ -1075,8 +1078,9 @@ static int GetPacket (struct gps_device_t *session ) } gpsd_report(LOG_RAW, "got %d bytes\n", theBytesReturned); #if 1 - gpsd_report(LOG_IO, "getPacket(), got %d bytes: %s\n" - , theBytesReturned, gpsd_hexdump(thePacket, theBytesReturned)); + gpsd_report(LOG_IO, "getPacket(), got %d bytes: %s\n", + theBytesReturned, + gpsd_hexdump_wrapper(thePacket, theBytesReturned, LOG_IO)); #endif session->driver.garmin.BufferLen += theBytesReturned; diff --git a/garmin_txt.c b/garmin_txt.c index 19f552af..ecd13aac 100644 --- a/garmin_txt.c +++ b/garmin_txt.c @@ -268,8 +268,11 @@ gps_mask_t garmintxt_parse(struct gps_device_t *session) gps_mask_t mask = 0; - gpsd_report(LOG_PROG, "Garmin Simple Text packet, len %d\n", session->packet.outbuflen); - gpsd_report(LOG_RAW, "%s\n", gpsd_hexdump(session->packet.outbuffer, session->packet.outbuflen)); + gpsd_report(LOG_PROG, "Garmin Simple Text packet, len %d\n", + session->packet.outbuflen); + gpsd_report(LOG_RAW, "%s\n", + gpsd_hexdump_wrapper(session->packet.outbuffer, + session->packet.outbuflen, LOG_RAW)); if (session->packet.outbuflen < 56) { gpsd_report(LOG_WARN, "Message too short, rejected.\n"); @@ -86,6 +86,7 @@ static fd_set all_fds; static int maxfd; static int debuglevel; +extern int gpsd_hexdump_level; static bool in_background = false; static bool listen_global = false; static bool nowait = true; @@ -1278,6 +1279,7 @@ int main(int argc, char *argv[]) (void)setlocale(LC_NUMERIC, "C"); #endif debuglevel = 0; + gpsd_hexdump_level = 0; while ((option = getopt(argc, argv, "F:D:S:bGhNnP:V" #ifdef RTCM104_SERVICE "R:" @@ -1286,6 +1288,7 @@ int main(int argc, char *argv[]) switch (option) { case 'D': debuglevel = (int) strtol(optarg, 0, 0); + gpsd_hexdump_level = debuglevel; break; case 'F': control_socket = optarg; diff --git a/gpsd.h-tail b/gpsd.h-tail index a9a61f4c..7c0dfd03 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -391,6 +391,7 @@ extern void gpsd_close(struct gps_device_t *); extern void gpsd_zero_satellites(/*@out@*/struct gps_data_t *sp)/*@modifies sp@*/; extern void gpsd_interpret_subframe(struct gps_device_t *, unsigned int[]); extern /*@ observer @*/ char *gpsd_hexdump(const void *, size_t); +extern /*@ observer @*/ char *gpsd_hexdump_wrapper(const void *, size_t, int); extern int gpsd_hexpack(char *, char *, int); extern int hex2bin(char *); extern void ntpd_link_activate(struct gps_device_t *session); @@ -8,6 +8,25 @@ #include "gpsd_config.h" #include "gpsd.h" +int gpsd_hexdump_level = -1; +/* + * A wrapper around gpsd_hexdump to prevent wasting cpu time by hexdumping + * buffers and copying strings that will never be printed. only messages at + * level "N" and lower will be printed. By way of example, without any -D + * options, gpsd probably won't ever call the real gpsd_hexdump. At -D2, + * LOG_PROG (and higher) won't get to call the real gpsd_hexdump. For high + * speed, chatty protocols, this can save a lot of CPU. + */ +char *gpsd_hexdump_wrapper(const void *binbuf, size_t binbuflen, + int msg_debug_level) +{ +#ifndef SQUELCH_ENABLE + if (msg_debug_level <= gpsd_hexdump_level) + return gpsd_hexdump(binbuf, binbuflen); +#endif /* SQUELCH_ENABLE */ + return ""; +} + char /*@ observer @*/ *gpsd_hexdump(const void *binbuf, size_t binbuflen) { static char hexbuf[MAX_PACKET_LENGTH*2+1]; @@ -170,7 +170,7 @@ static bool italk_write(int fd, unsigned char *msg, size_t msglen) { /* we may need to dump the message */ gpsd_report(LOG_IO, "writing italk control type %02x:%s\n", - msg[0], gpsd_hexdump(msg, msglen)); + msg[0], gpsd_hexdump_wrapper(msg, msglen, LOG_IO)); #ifdef ALLOW_RECONFIGURE ok = (write(fd, msg, msglen) == (ssize_t)msglen); (void)tcdrain(fd); @@ -192,7 +192,8 @@ static gps_mask_t italk_parse(struct gps_device_t *session, unsigned char *buf, type = (uint)getub(buf, 4); /* we may need to dump the raw packet */ - gpsd_report(LOG_RAW, "raw italk packet type 0x%02x length %d: %s\n", type, len, gpsd_hexdump(buf, len)); + gpsd_report(LOG_RAW, "raw italk packet type 0x%02x length %d: %s\n", + type, len, gpsd_hexdump_wrapper(buf, len, LOG_RAW)); switch (type) { @@ -83,7 +83,8 @@ static u_int8_t checksum(unsigned char *buf, size_t len) static bool navcom_send_cmd(struct gps_device_t *session, unsigned char *cmd, size_t len) { - gpsd_report(LOG_RAW, "Navcom: command dump: %s\n", gpsd_hexdump(cmd, len)); + gpsd_report(LOG_RAW, "Navcom: command dump: %s\n", + gpsd_hexdump_wrapper(cmd, len, LOG_RAW)); return (gpsd_write(session, cmd, len) == (ssize_t)len); } @@ -1160,7 +1161,7 @@ gps_mask_t navcom_parse(struct gps_device_t *session, unsigned char *buf, size_t /*@ -usedef -compdef @*/ gpsd_report(LOG_RAW, "Navcom: packet type 0x%02x, length %d: %s\n", - cmd_id, msg_len, gpsd_hexdump(buf, len)); + cmd_id, msg_len, gpsd_hexdump_wrapper(buf, len, LOG_RAW)); /*@ +usedef +compdef @*/ (void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag), @@ -524,7 +524,8 @@ static void nextstate(struct gps_packet_t *lexer, gpsd_report(LOG_INF, "Navcom packet type 0x%hx bad checksum 0x%hx, expecting 0x%hx\n", lexer->inbuffer[3], csum, c); gpsd_report(LOG_RAW, "Navcom packet dump: %s\n", - gpsd_hexdump(lexer->inbuffer, lexer->inbuflen)); + gpsd_hexdump_wrapper(lexer->inbuffer, lexer->inbuflen, + LOG_RAW)); lexer->state = GROUND_STATE; break; } @@ -826,8 +827,8 @@ static void packet_accept(struct gps_packet_t *lexer, int packet_type) lexer->type = packet_type; #ifdef STATE_DEBUG gpsd_report(LOG_RAW+1, "Packet type %d accepted %d = %s\n", - packet_type, packetlen, - gpsd_hexdump(lexer->outbuffer, lexer->outbuflen)); + packet_type, packetlen, + gpsd_hexdump_wrapper(lexer->outbuffer, lexer->outbuflen, LOG_RAW)); #endif /* STATE_DEBUG */ } else { gpsd_report(LOG_ERROR, "Rejected too long packet type %d len %d\n", @@ -846,8 +847,8 @@ static void packet_discard(struct gps_packet_t *lexer) lexer->inbuflen = remaining; #ifdef STATE_DEBUG gpsd_report(LOG_RAW+1, "Packet discard of %d, chars remaining is %d = %s\n", - discard, remaining, - gpsd_hexdump(lexer->inbuffer, lexer->inbuflen)); + discard, remaining, + gpsd_hexdump_wrapper(lexer->inbuffer, lexer->inbuflen, LOG_RAW)); #endif /* STATE_DEBUG */ } @@ -858,8 +859,8 @@ static void character_discard(struct gps_packet_t *lexer) lexer->inbufptr = lexer->inbuffer; #ifdef STATE_DEBUG gpsd_report(LOG_RAW+1, "Character discarded, buffer %d chars = %s\n", - lexer->inbuflen, - gpsd_hexdump(lexer->inbuffer, lexer->inbuflen)); + lexer->inbuflen, + gpsd_hexdump_wrapper(lexer->inbuffer, lexer->inbuflen, LOG_RAW)); #endif /* STATE_DEBUG */ } @@ -986,7 +987,7 @@ void packet_parse(struct gps_packet_t *lexer) } /* Debug gpsd_report(LOG_IO, "Garmin n= %#02x\n %s\n", n, - gpsd_hexdump(lexer->inbuffer, packetlen)); + gpsd_hexdump_wrapper(lexer->inbuffer, packetlen, LOG_IO)); */ packet_accept(lexer, GARMIN_PACKET); packet_discard(lexer); @@ -1296,11 +1297,10 @@ ssize_t packet_get(int fd, struct gps_packet_t *lexer) } } else { #ifdef STATE_DEBUG - gpsd_report(LOG_RAW+1, "Read %d chars to buffer offset %d (total %d): %s\n", - recvd, - lexer->inbuflen, - lexer->inbuflen+recvd, - gpsd_hexdump(lexer->inbufptr, (size_t)recvd)); + gpsd_report(LOG_RAW+1, + "Read %d chars to buffer offset %d (total %d): %s\n", + recvd, lexer->inbuflen, lexer->inbuflen+recvd, + gpsd_hexdump_wrapper(lexer->inbufptr, (size_t)recvd, LOG_RAW+1)); #endif /* STATE_DEBUG */ lexer->inbuflen += recvd; } @@ -277,7 +277,8 @@ ssize_t gpsd_write(struct gps_device_t *session, void const *buf, size_t len) ok = (status == (ssize_t)len); (void)tcdrain(session->gpsdata.gps_fd); /* no test here now, always print as hex */ - gpsd_report(LOG_IO, "=> GPS: %s%s\n", gpsd_hexdump(buf, len), ok?"":" FAILED"); + gpsd_report(LOG_IO, "=> GPS: %s%s\n", + gpsd_hexdump_wrapper(buf, len, LOG_IO), ok?"":" FAILED"); return status; } @@ -117,7 +117,8 @@ bool sirf_write(int fd, unsigned char *msg) { msg[len + 4] = (unsigned char)((crc & 0xff00) >> 8); msg[len + 5] = (unsigned char)( crc & 0x00ff); - gpsd_report(LOG_IO, "Writing SiRF control type %02x:%s\n", msg[4], gpsd_hexdump(msg, len+8)); + gpsd_report(LOG_IO, "Writing SiRF control type %02x:%s\n", msg[4], + gpsd_hexdump_wrapper(msg, len+8, LOG_IO)); ok = (write(fd, msg, len+8) == (ssize_t)(len+8)); (void)tcdrain(fd); return(ok); @@ -647,8 +648,8 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l buf += 4; len -= 8; - gpsd_report(LOG_RAW, "Raw SiRF packet type 0x%02x length %d: %s\n", buf[0],len, - gpsd_hexdump(buf, len)); + gpsd_report(LOG_RAW, "Raw SiRF packet type 0x%02x length %d: %s\n", + buf[0],len, gpsd_hexdump_wrapper(buf, len, LOG_RAW)); (void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag), "MID%d",(int)buf[0]); @@ -706,15 +707,18 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l return 0; case 0x0e: /* Almanac Data */ - gpsd_report(LOG_PROG, "ALM 0x0e: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "ALM 0x0e: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0x0f: /* Ephemeris Data */ - gpsd_report(LOG_PROG, "EPH 0x0f: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "EPH 0x0f: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0x11: /* Differential Corrections */ - gpsd_report(LOG_PROG, "DIFF 0x11: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "DIFF 0x11: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0x12: /* OK To Send */ @@ -771,19 +775,23 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l return 0; case 0x1c: /* Navigation Library Measurement Data */ - gpsd_report(LOG_PROG, "NLMD 0x1c: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "NLMD 0x1c: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0x1d: /* Navigation Library DGPS Data */ - gpsd_report(LOG_PROG, "NLDG 0x1d: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "NLDG 0x1d: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0x1e: /* Navigation Library SV State Data */ - gpsd_report(LOG_PROG, "NLSV 0x1e: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "NLSV 0x1e: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0x1f: /* Navigation Library Initialization Data */ - gpsd_report(LOG_PROG, "NLID 0x1f: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "NLID 0x1f: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0x29: /* Geodetic Navigation Information */ @@ -820,7 +828,8 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l return sirf_msg_ublox(session, buf, len); case 0x80: /* Initialize Data Source */ - gpsd_report(LOG_PROG, "INIT 0x80: %s\n", gpsd_hexdump(buf, len)); + gpsd_report(LOG_PROG, "INIT 0x80: %s\n", + gpsd_hexdump_wrapper(buf, len, LOG_PROG)); return 0; case 0xe1: /* Development statistics messages */ @@ -831,7 +840,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l default: gpsd_report(LOG_WARN, "Unknown SiRF packet id %d length %d: %s\n", - buf[0], len, gpsd_hexdump(buf, len)); + buf[0], len, gpsd_hexdump_wrapper(buf, len, LOG_WARN)); return 0; } } @@ -24,7 +24,8 @@ static int tsip_write(int fd, unsigned int id, unsigned char *buf, size_t len) #ifdef ALLOW_RECONFIGURE char buf2[BUFSIZ]; - gpsd_report(LOG_IO, "Sent TSIP packet id 0x%02x: %s\n",id,gpsd_hexdump(buf,len)); + gpsd_report(LOG_IO, "Sent TSIP packet id 0x%02x: %s\n", id, + gpsd_hexdump_wrapper(buf, len, LOG_IO)); /*@ +charint @*/ buf2[0] = '\x10'; @@ -48,7 +49,8 @@ static int tsip_write(int fd, unsigned int id, unsigned char *buf, size_t len) return 0; #else - gpsd_report(LOG_IO, "Not sending TSIP packet id 0x%02x: %s\n",id,gpsd_hexdump(buf,len)); + gpsd_report(LOG_IO, "Not sending TSIP packet id 0x%02x: %s\n", id, + gpsd_hexdump_wrapper(buf,len,LOG_IO)); return -1; #endif /* ALLOW_RECONFIGURE */ } @@ -425,8 +425,9 @@ gps_mask_t ubx_parse(struct gps_device_t *session, unsigned char *buf, size_t le break; default: - gpsd_report(LOG_WARN, "UBX: unknown packet id 0x%04hx (length %d) %s\n", - msgid, len, gpsd_hexdump(buf, len)); + gpsd_report(LOG_WARN, + "UBX: unknown packet id 0x%04hx (length %d) %s\n", + msgid, len, gpsd_hexdump_wrapper(buf, len, LOG_WARN)); } if (mask) @@ -500,8 +501,11 @@ bool ubx_write(int fd, unsigned char msg_class, unsigned char msg_id, unsigned c head_tail[6] = CK_A; head_tail[7] = CK_B; - gpsd_report(LOG_IO, "=> GPS: UBX class: %02x, id: %02x, len: %d, data:%s, crc: %02x%02x\n", - msg_class, msg_id, data_len, gpsd_hexdump(msg, data_len), CK_A, CK_B); + gpsd_report(LOG_IO, + "=> GPS: UBX class: %02x, id: %02x, len: %d, data:%s, crc: %02x%02x\n", + msg_class, msg_id, data_len, + gpsd_hexdump_wrapper(msg, data_len, LOG_IO), + CK_A, CK_B); count = write(fd, head_tail, 6); (void)tcdrain(fd); |