Is really important the second part/sentence in a type 5 AIS AIVDM message?

661 Views Asked by At

I have an AIS antenna receiving AIVDM sentences since 1 year ago.

Now I'm starting decoding the sentences using https://github.com/bcl/aisparser and found that type 5 messages has two aivdm sentences that not always come consecutively and usually loss (at least in my case) the second sentence, making the decodification quite more complicated.

I've tried to interchange second part sentences to see what happens and if its really important.

For example, if you try these sentences in https://www.maritec.co.za/tools/aisvdmvdodecoding/:

!AIVDM,2,1,0,A,58wt8Ui`g??r21`7S=:22058<v05Htp000000015>8OA;0sk,0*7B
!AIVDM,2,2,0,A,eQ8823mDm3kP00000000000,2*5D
!AIVDM,2,1,6,A,58wt8Ui`g??r21`7S=:22058<v05Htp000000015>8OA;0sk,0*7B
!AIVDM,2,2,6,A,:062paRLOaD,2*79

you'll notice that the only change is that the second pair (the "wrong" one with an "adapted" second part) has a wrong 'destination' so, it really matters to take all the decoding job if you are not interested in the 'destination' field?

All the best

1

There are 1 best solutions below

1
On

Indeed, it can be tricky to match the corresponding two parts of type 5 messages, but you could rely on this library to do it for you: https://github.com/schwehr/libais

import ais
q = ais.nmea_queue.NmeaQueue()
while True:
    msg = next(your_message_iterator)
    q.put(msg)
    if q.qsize():
        d = q.get().get('decoded', None) 
        # Then do whatever you need with d (store it, print it,...)

With this setting, the result of q.get_size() can be 0 if you are the first part of a type 5 message (or an invalid AIS sequence), or 1 if you added a single-sentence message, or a second-sentence that matches an already present first-sentence.

Note: To answer your question, you can get the detail of which information is encoded on which bit in the paragraph "Type 5: Static and Voyage Related Data" on https://gpsd.gitlab.io/gpsd/AIVDM.html. This will help you to understand which data is lost if the second message is invalid.