summaryrefslogtreecommitdiff
path: root/italk.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-07-19 04:05:21 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-07-19 04:05:21 +0000
commitb41c646ac0d930b4f42f7de7c3d8d7c2cdd77103 (patch)
tree82dc8132a362871d6d3ebfc19c32d15ade61dbda /italk.c
parentb4b794cfe23199343338964f0b894d7b5c1dac00 (diff)
downloadgpsd-b41c646ac0d930b4f42f7de7c3d8d7c2cdd77103.tar.gz
Use gpsd_hexdump().
Diffstat (limited to 'italk.c')
-rw-r--r--italk.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/italk.c b/italk.c
index ce46e213..bf60aa91 100644
--- a/italk.c
+++ b/italk.c
@@ -18,20 +18,14 @@
/*@ +charint -usedef -compdef @*/
static bool italk_write(int fd, unsigned char *msg, size_t msglen) {
- size_t i, len;
- unsigned char buf[MAX_PACKET_LENGTH*3+1];
bool ok;
/* CONSTRUCT THE MESSAGE */
/* we may need to dump the message */
- buf[0] = '\0';
- for (i = 0; i < msglen; i++)
- (void)snprintf((char*)buf+strlen((char *)buf),sizeof((char*)buf)-strlen((char*)buf),
- " %02x", msg[i]);
- len = (size_t)strlen((char *)buf);
- gpsd_report(4, "writing italk control type %02x:%s\n", msg[0], buf);
- ok = (write(fd, buf, len) == (ssize_t)len);
+ gpsd_report(4, "writing italk control type %02x:%s\n",
+ msg[0], gpsd_hexdump(msg, msglen));
+ ok = (write(fd, msg, msglen) == (ssize_t)msglen);
(void)tcdrain(fd);
return(ok);
}
@@ -40,35 +34,21 @@ static bool italk_write(int fd, unsigned char *msg, size_t msglen) {
/*@ +charint @*/
static gps_mask_t italk_parse(struct gps_device_t *session, unsigned char *buf, size_t len)
{
- unsigned char buf2[MAX_PACKET_LENGTH*3+2];
- size_t i;
-
if (len == 0)
return 0;
/* we may need to dump the raw packet */
- buf2[0] = '\0';
- for (i = 0; i < len; i++)
- (void)snprintf((char*)buf2+strlen((char*)buf2),
- sizeof(buf2)-strlen((char*)buf2),
- "%02x", (unsigned int)buf[i]);
- strcat((char*)buf2, "\n");
- gpsd_report(5, "raw italk packet type 0x%02x length %d: %s\n", buf[0], len, buf2);
+ gpsd_report(5, "raw italk packet type 0x%02x length %d: %s\n", buf[0], len, gpsd_hexdump(buf, len));
(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
- "ITALK%d",(int)buf2[0]);
+ "ITALK%d",(int)buf[0]);
- switch (getub(buf2, 0))
+ switch (getub(buf, 0))
{
/* DISPATCH ON FIRST BYTE OF PAYLOAD */
default:
- buf[0] = '\0';
- for (i = 0; i < len; i++)
- (void)snprintf((char*)buf+strlen((char*)buf),
- sizeof(buf)-strlen((char*)buf),
- "%02x", (unsigned int)buf2[i]);
- gpsd_report(3, "unknown Italk packet id %d length %d: %s\n", buf2[0], len, buf);
+ gpsd_report(3, "unknown iTalk packet id %d length %d: %s\n", buf[0], len, gpsd_hexdump(buf, len));
return 0;
}
}