diff options
-rwxr-xr-x | devtools/ais.py | 17 | ||||
-rw-r--r-- | www/AIVDM.txt | 14 |
2 files changed, 23 insertions, 8 deletions
diff --git a/devtools/ais.py b/devtools/ais.py index 3f2cbc49..b11d944c 100755 --- a/devtools/ais.py +++ b/devtools/ais.py @@ -169,7 +169,7 @@ type4 = ( bitfield("lat", 27, "signed", 0x3412140, "Latitude", formatter=cnb_latlon_format), bitfield("epfd", 4, "unsigned", None, "Type of EPFD", - validator=lambda n: n >= 0 and n <= 8, + validator=lambda n: n >= 0 and n <= 8 or n == 15, formatter=epfd_type_legends), spare(10), bitfield("raim", 1, "unsigned", None, "RAIM flag "), @@ -285,14 +285,14 @@ type5 = ( bitfield("callsign", 42, 'string', None, "Call Sign"), bitfield("shipname", 120, 'string', None, "Vessel Name"), bitfield("shiptype", 8, 'unsigned', None, "Ship Type", - validator=lambda n: n >= 0 and n <= 99, + #validator=lambda n: n >= 0 and n <= 99, formatter=ship_type_legends), bitfield("to_bow", 9, 'unsigned', 0, "Dimension to Bow"), bitfield("to_stern", 9, 'unsigned', 0, "Dimension to Stern"), bitfield("to_port", 6, 'unsigned', 0, "Dimension to Port"), bitfield("to_starbord", 6, 'unsigned', 0, "Dimension to Starboard"), bitfield("epfd", 4, 'unsigned', 0, "Position Fix Type", - validator=lambda n: n >= 0 and n <= 8, + validator=lambda n: n >= 0 and n <= 8 or n == 15, formatter=epfd_type_legends), bitfield("month", 4, 'unsigned', 0, "ETA month"), bitfield("day", 5, 'unsigned', 0, "ETA day"), @@ -469,14 +469,14 @@ type19 = ( bitfield("regional", 4, 'unsigned', None, "Regional reserved"), bitfield("shipname", 120, 'string', None, "Vessel Name"), bitfield("shiptype", 8, 'unsigned', None, "Ship Type", - validator=lambda n: n >= 0 and n <= 99, + #validator=lambda n: n >= 0 and n <= 99, formatter=ship_type_legends), bitfield("to_bow", 9, 'unsigned', 0, "Dimension to Bow"), bitfield("to_stern", 9, 'unsigned', 0, "Dimension to Stern"), bitfield("to_port", 6, 'unsigned', 0, "Dimension to Port"), bitfield("to_starbord", 6, 'unsigned', 0, "Dimension to Starboard"), bitfield("epfd", 4, 'unsigned', 0, "Position Fix Type", - validator=lambda n: n >= 0 and n <= 8, + validator=lambda n: n >= 0 and n <= 8 or n == 15, formatter=epfd_type_legends), bitfield("assigned", 1, 'unsigned', None, "Assigned"), bitfield("raim", 1, 'unsigned', None, "RAIM flag"), @@ -552,7 +552,7 @@ type21 = ( bitfield("to_port", 6, 'unsigned', 0, "Dimension to Port"), bitfield("to_starboard", 6, 'unsigned', 0, "Dimension to Starboard"), bitfield("epfd", 4, 'unsigned', 0, "Position Fix Type", - validator=lambda n: n >= 0 and n <= 8, + validator=lambda n: n >= 0 and n <= 8 or n == 15, formatter=epfd_type_legends), bitfield("second", 6, 'unsigned', 0, "UTC Second"), bitfield("off_position", 1, 'unsigned', 0, "Off-Position Indicator"), @@ -618,7 +618,7 @@ type23 = ( validator=lambda n: n >= 0 and n <= 31, formatter=station_type_legends), bitfield("shiptype", 8, 'unsigned', 0, "Ship Type", - validator=lambda n: n >= 0 and n <= 99, + #validator=lambda n: n >= 0 and n <= 99, formatter=ship_type_legends), spare(22), bitfield("txrx", 2, 'unsigned', 0, "Tx/Rx mode"), @@ -851,6 +851,9 @@ def parse_ais_messages(source, scaled=False, skiperr=False, verbose=0): cooked[i][1] = "n/a" elif inst.formatter: if type(inst.formatter) == type(()): + # Assumes 0 is the legend for the "undefined" value + if value >= len(inst.formatter): + value = 0 cooked[i][1] = inst.formatter[value] elif type(formatter) == type(lambda x: x): cooked[i][1] = inst.formatter(value) diff --git a/www/AIVDM.txt b/www/AIVDM.txt index 1ffd472b..4380c7d5 100644 --- a/www/AIVDM.txt +++ b/www/AIVDM.txt @@ -643,6 +643,11 @@ The standard uses "EPFD" to designate any Electronic Position Fixing Device. |8 |Galileo |=================================== +Note: though values 9-15 are marked "not used" in <<IALA>>, the EPFD +type value 15 (all field bits 1) is not uncommon in the wild; it +appears some receivers emit it as the Undefined value. Decoders should +be prepared to accept this. + === Type 5: Ship static and voyage related data === Message has a total of 424 bits, occupying two AIVDM sentences. @@ -772,6 +777,13 @@ the dimensions to port and starboard, the special value 63 indicates |99 |Other Type, no additional information |============================================================== +Note that garbage values greater than 99 are supposed to be unused, +but are not uncommon in the wild; AIS transponers seem prone to put +garbage in this field when it's not explicitly set. Decoders should +treat these like value 0 rather than throwing an exception until and +unless the controlled vocabulary is extended to include the unknown +values. + === Type 6: Addressed Binary Message === Message type 6 is an addressed point-to-point message with unspecified @@ -1808,4 +1820,4 @@ Version 1.21 describes JSON-AIS more completely. It adds descriptions for AIS messages type 25 and 26, not yet observed in the wild. Version 1.22 describes the problem with message length checks. - +Notes on EPFD value 15 and shiptype values > 99 are added. |