summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdevtools/ais.py13
-rw-r--r--driver_aivdm.c12
-rw-r--r--gpsdecode.c2
-rw-r--r--www/AIVDM.txt12
4 files changed, 30 insertions, 9 deletions
diff --git a/devtools/ais.py b/devtools/ais.py
index 6f63a097..0f67beac 100755
--- a/devtools/ais.py
+++ b/devtools/ais.py
@@ -758,8 +758,17 @@ def aivdm_unpack(data, offset, values, instructions):
value = data.sbits(offset, inst.width)
elif inst.type == 'string':
value = ''
- for i in range(inst.width/6):
- value += "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^- !\"#$%&`()*+,-./0123456789:;<=>?"[data.ubits(offset + 6*i, 6)]
+ # The try/catch error here is in case we run off the end
+ # of a variable-length string field, as in messages 12 and 14
+ try:
+ for i in range(inst.width/6):
+ newchar = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^- !\"#$%&`()*+,-./0123456789:;<=>?"[data.ubits(offset + 6*i, 6)]
+ if newchar == '@':
+ break
+ else:
+ value += newchar
+ except IndexError:
+ pass
value = value.replace("@", " ").rstrip()
elif inst.type == 'raw':
value = BitVector(data.bits[offset/8:], len(data)-offset)
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] == '@')
diff --git a/gpsdecode.c b/gpsdecode.c
index 113e65c7..d566f5a8 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -365,6 +365,8 @@ static void decode(FILE *fpin, FILE *fpout)
rtcm3_dump(&rtcm3, stdout);
}
else if (lexer.type == AIVDM_PACKET) {
+ if (verbose >=1 )
+ (void)fputs((char *)lexer.outbuffer, stdout);
/*@ -uniondef */
if (aivdm_decode((char *)lexer.outbuffer, lexer.outbuflen, &aivdm, &ais)) {
if (!json)
diff --git a/www/AIVDM.txt b/www/AIVDM.txt
index d1ef3957..79969a82 100644
--- a/www/AIVDM.txt
+++ b/www/AIVDM.txt
@@ -1,6 +1,6 @@
= AIVDM/AIVDO protocol decoding =
Eric S. Raymond <esr@thyrsus.com>
-v1.16, Nov 2009
+v1.17, Nov 2009
This document is mastered in asciidoc format. If you are reading it in HTML,
you can find the original at http://gpsd.berlios.de/AIVDM.txt[]
@@ -299,9 +299,11 @@ brackets, pipe bar, tilde and DEL cannot be encoded.
-----------------------------------------------------------------------------
According to the standard, trailing unused characters in six-bit
-fields will be represented by "@" (six-bit zero). It is common to
-space-fill the fields instead, so a decoder should strip trailing
-spaces well as at-signs.
+fields will be represented by "@" (six-bit zero). The terminating "@"
+should not be considered part of the text, and any non-"@" characters
+adter it should be discarded. It is common to space-fill the fields
+instead, so a decoder should strip trailing spaces well as at-signs
+and garbage after them.
== AIVDM/AIVDO Payload Interpretation ==
@@ -1548,3 +1550,5 @@ corrected it because it confused someone working on a Python decoder.
Version 1.16 incorporated various minor fixes and corrections from
Neal Arundale. One 'standard' fieldname changed, in message type 21:
type -> aid_type.
+
+Version 1.17 clatfies the role of @ as a terminator in 6-bit text.