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 /sirf.c | |
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.
Diffstat (limited to 'sirf.c')
-rw-r--r-- | sirf.c | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -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; } } |