summaryrefslogtreecommitdiff
path: root/drivers.c
diff options
context:
space:
mode:
authorJon Schlueter <jschlueter@redhat.com>2016-01-05 02:04:47 -0500
committerJon Schlueter <jschlueter@redhat.com>2016-01-05 02:10:40 -0500
commitdb69281bbd3c60b38b4fa489944492a7a8a739d6 (patch)
tree807ac46483d0add24964f0147e35becaeb3b7cc1 /drivers.c
parent08bb7332fbd7d7f925972d2f3d43fed60da61f65 (diff)
downloadgpsd-db69281bbd3c60b38b4fa489944492a7a8a739d6.tar.gz
[aivdm] Refactor in aivdm_decode for pad
make the pad local variable actually be number of bits of padding instead of the ASCII value of the number of bits of padding directly. No logic change
Diffstat (limited to 'drivers.c')
-rw-r--r--drivers.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers.c b/drivers.c
index de5ce78c..dce33c4b 100644
--- a/drivers.c
+++ b/drivers.c
@@ -1185,7 +1185,7 @@ static bool aivdm_decode(const char *buf, size_t buflen,
unsigned char *field[NMEA_MAX*2];
unsigned char fieldcopy[NMEA_MAX*2+1];
unsigned char *data, *cp;
- unsigned char pad;
+ int pad;
struct aivdm_context_t *ais_context;
int i;
@@ -1211,7 +1211,11 @@ static bool aivdm_decode(const char *buf, size_t buflen,
field[nfields++] = (unsigned char *)buf;
for (cp = fieldcopy;
cp < fieldcopy + buflen; cp++)
- if (*cp == (unsigned char)',') {
+ {
+ if (
+ (*cp == (unsigned char)',') ||
+ (*cp == (unsigned char)'*')
+ ) {
*cp = '\0';
field[nfields++] = cp + 1;
}
@@ -1264,7 +1268,10 @@ static bool aivdm_decode(const char *buf, size_t buflen,
nfrags = atoi((char *)field[1]); /* number of fragments to expect */
ifrag = atoi((char *)field[2]); /* fragment id */
data = field[5];
- pad = field[6][0]; /* number of padding bits */
+
+ pad = 0;
+ if(isdigit(field[6][0]))
+ pad = field[6][0] - '0'; /* number of padding bits ASCII encoded*/
gpsd_log(&session->context->errout, LOG_PROG,
"nfrags=%d, ifrag=%d, decoded_frags=%d, data=%s\n",
nfrags, ifrag, ais_context->decoded_frags, data);
@@ -1311,8 +1318,7 @@ static bool aivdm_decode(const char *buf, size_t buflen,
}
}
}
- if (isdigit(pad))
- ais_context->bitlen -= (pad - '0'); /* ASCII assumption */
+ ais_context->bitlen -= pad;
/* time to pass buffered-up data to where it's actually processed? */
if (ifrag == nfrags) {