0

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

Lanas
  • 23
  • 5

1 Answers1

0

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.

Nicolas
  • 193
  • 1
  • 10
  • Thanks for your answer. I'm using aisparser to decode (with more effort) type 5 messages too. The point is that in my 1 year database of aivdm sentences I have more than 10 times type 5 messages first part sentences than the second part, this implies that if I follow the usual decoding "protocol" I lose a lot of information because most of the type 5 messages don't receive the second part so the decodification is not done. Anybody know why is this happening? Relaying on your info and others i'm missing 'eta' and 'destination' fields, that are not important to me. – Lanas Jul 15 '19 at 12:17