schwehr / libais

C++ decoder for Automatic Identification System for tracking ships and decoding maritime information
Other
215 stars 94 forks source link

AIS Weather message decode causes exception #211

Closed andyvan-trabus closed 2 years ago

andyvan-trabus commented 2 years ago

None of these messages decode using libais. They decode without error in pyais and gpsdecode, and in online decoders at maritec, ais.tbsalling.dk.

 "!SAVDM,1,1,7,B,85Mr6<1KmhB:VgtfPV9lIf4M31PR000P,0*71",    # DAC 367, FID 23
 "!SAVDM,1,1,3,A,85Mr6<1Kn15CGvG@C4r<o000,0*34",            # DAC 367, FID 24
 "!SAVDM,1,1,2,B,85Mr6<1KnA5Af1PR000P,0*21",                # DAC 367, FID 25
 "!AIVDM,1,1,,B,8>k1oFAKpB95?AruFRl7mre0<N00,0*6A",         # DAC 367, FID 33

Exception: _ais.DecodeError: ais.decode: unknown message - !

Test Code

import traceback

import ais
from pyais import decode_msg

TEST_MESSAGES = ["!SAVDM,1,1,7,B,85Mr6<1KmhB:VgtfPV9lIf4M31PR000P,0*71",    # DAC 367, FID 23
                 "!SAVDM,1,1,3,A,85Mr6<1Kn15CGvG@C4r<o000,0*34",            # DAC 367, FID 24
                 "!SAVDM,1,1,2,B,85Mr6<1KnA5Af1PR000P,0*21",                # DAC 367, FID 25
                 "!AIVDM,1,1,,B,8>k1oFAKpB95?AruFRl7mre0<N00,0*6A"]         # DAC 367, FID 33

for index, msg in enumerate(TEST_MESSAGES):
    try:
        output = ais.decode(msg)
        print("{}: libais: '{}'".format(index, output))
    except Exception:
        print("Exception parsing message {} using libais".format(index))
        traceback.print_exc()

    try:
        output = decode_msg(msg)
        print("{}: pyais: '{}'".format(index, output))
    except Exception:
        print("Exception parsing message {} using pyais".format(index))
        traceback.print_exc()
andyvan-trabus commented 2 years ago

Note: If you use the decode_ais routine from issue # 204, they still don't decode.

schwehr commented 2 years ago

Took a quick look at #204. ais.decode is the thinnest of python support that I could come up with. Most folks who have used this code wrote their own. AIS logging is so different between organizations.

So, what happens when you do this?

ais.decode('85Mr6<1KmhB:VgtfPV9lIf4M31PR000P', 0)

But, looking at https://github.com/schwehr/libais/blob/master/src/libais/ais8.cpp, I don't see 8_367_23, 8_367_24, 8_367_25. If I remember correctly the 367 messages were evolving over time back 10 years ago and difficult to deal with different messages with that were going over VHF. If things have settled down with the spec, let's get a copy of it and work through adding the decoders for those. Should be pretty close to things like Ais8_1_24::Ais8_1_24 and similar.

andyvan-trabus commented 2 years ago

We can close this issue. Support for these messages has been added.

Note: This specific test case doesn't pass; all but the last one fail with AIS_ERR_BAD_BIT_COUNT.