summaryrefslogtreecommitdiff
path: root/driver_aivdm.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-11-30 01:37:49 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-11-30 01:37:49 +0000
commita25d9a2036f3e43276353ca81586d0e4e4f6d4ec (patch)
treee8885cc6ff9aaad5e8039ec66a091b833c80ea36 /driver_aivdm.c
parentf431ff9d1b054bfbcddd801c926ec2f9e6e730fa (diff)
downloadgpsd-a25d9a2036f3e43276353ca81586d0e4e4f6d4ec.tar.gz
Document that a trailing @ should terminate a packed-six-bit AIS string.
Ensure that both decoders do this.
Diffstat (limited to 'driver_aivdm.c')
-rw-r--r--driver_aivdm.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/driver_aivdm.c b/driver_aivdm.c
index c09f9eb2..674566f4 100644
--- a/driver_aivdm.c
+++ b/driver_aivdm.c
@@ -36,11 +36,17 @@ static void from_sixbit(char *bitvec, uint start, int count, char *to)
const char sixchr[64] = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^- !\"#$%&`()*+,-./0123456789:;<=>?";
#endif /* S_SPLINT_S */
int i;
+ char newchar;
/* six-bit to ASCII */
- for (i = 0; i < count-1; i++)
- to[i] = sixchr[ubits(bitvec, start + 6*i, 6U)];
- to[count-1] = '\0';
+ for (i = 0; i < count-1; i++) {
+ newchar = sixchr[ubits(bitvec, start + 6*i, 6U)];
+ if (newchar == '@')
+ break;
+ else
+ to[i] = newchar;
+ }
+ to[i] = '\0';
/* trim spaces on right end */
for (i = count-2; i >= 0; i--)
if (to[i] == ' ' || to[i] == '@')