summaryrefslogtreecommitdiff
path: root/driver_ubx.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-03-19 12:08:54 -0700
committerGary E. Miller <gem@rellim.com>2015-03-19 12:08:54 -0700
commiteca0af2bcc50178e12b2481b1db307f28c5d2740 (patch)
treeaf6d9775103995450f3f39a3135676cb5c284ed2 /driver_ubx.c
parent425e77152bd0bd69dec5d0ba12379f18ff5273bf (diff)
downloadgpsd-eca0af2bcc50178e12b2481b1db307f28c5d2740.tar.gz
UBX-MON-VER now prints all info to LOG_INF.
Now outputs the extended version info. subtype is a bit short, just fit in there what we can.
Diffstat (limited to 'driver_ubx.c')
-rw-r--r--driver_ubx.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/driver_ubx.c b/driver_ubx.c
index f7e2905d..13eeca8c 100644
--- a/driver_ubx.c
+++ b/driver_ubx.c
@@ -81,22 +81,48 @@ static void ubx_mode(struct gps_device_t *session, int mode);
/**
* Receiver/Software Version
+ * UBX-MON-VER
+ *
+ * sadly more info than fits in session->swtype for now.
+ * so squish the data hard, max is maybe 100?
*/
static void
ubx_msg_mon_ver(struct gps_device_t *session, unsigned char *buf,
size_t data_len)
{
+ unsigned int n = 0; /* extended info counter */
+ char obuf[128]; /* temp version string buffer */
+
+ if ( 44 > data_len ) {
+ /* incomplete message */
+ return;
+ }
/* save SW and HW Version as subtype */
- (void)snprintf(session->subtype, sizeof(session->subtype),
- "SW: %.30s, HW: %.10s",
+ (void)snprintf(obuf, sizeof(obuf),
+ "SW %.30s,HW %.10s",
(char *)&buf[UBX_MESSAGE_DATA_OFFSET + 0],
(char *)&buf[UBX_MESSAGE_DATA_OFFSET + 30]);
+
+ /* get n number of Extended info strings. what is max n? */
+ for ( n = 0; ; n++ ) {
+ unsigned int start_of_str = UBX_MESSAGE_DATA_OFFSET + 40 + (30 * n);
+
+ if ( (start_of_str + 2 ) > data_len ) {
+ /* last one can be shorter than 30 */
+ /* no more data */
+ break;
+ }
+ (void)strlcat(obuf, ",", sizeof(obuf));
+ (void)strlcat(obuf, (char *)&buf[start_of_str], sizeof(obuf));
+ }
+ /* save what we can */
+ (void)strlcpy(session->subtype, obuf, sizeof(session->subtype));
+
/* output SW and HW Version at LOG_INFO */
gpsd_log(&session->context->errout, LOG_INF,
- "UBX_MON_VER: %.40s, %d\n",
- session->subtype, (int)(data_len -UBX_MESSAGE_DATA_OFFSET));
-
+ "UBX_MON_VER: %.*s\n",
+ (int)sizeof(obuf), obuf);
}
/**