Error on AIS messages
My NMEA stream contains AIS messages in the following format:
!AIVDM,1,1,,A,ENkb9ONaR@@@@@@@@@@@@@@@@@@;kaD09EE>`00003vP000,4*2C
When I try to parse this message I get a ParseError.
Any way to enable parsing AIS messages?
Hi, unfortunately we don't have support for AIS messages. If you are able to help contribute code, or even just provide references and samples, it would be appreciated!
I doubt I'll be able to contribute much in the way of code... I'm much more of a hack than an experienced programmer. :-)
I can definitely provide some sample messages and see what else I can find in the way of resources. I'm on the road and need to be on the boat to get the samples, so it will be about two weeks, but I will definitely post here.
THANK YOU for pynmea2!!!
Here are the details on the data structure: http://catb.org/gpsd/AIVDM.html
try this github
https://github.com/schwehr/libais
@Knio how would one structure the fact that ais messages can be more than one line? Keep track of the count and re-parse? I'm not sure one can assume the next line would be the next part of the message, but I haven't seen any examples otherwise.
>>> foo = pynmea2.parse("!AIVDM,2,1,6,B,56:fS:D0000000000008v0<QD4r0`T4v3400000t0`D147?ps1P00000,0*3")
>>> foo.is_complete
False
>>> foo.parse("!AIVDM,2,2,6,B,000000000000008,2*29")
>>> foo.is_complete
True
That's just getting the whole binary blob; I'm not exactly sure how to make it magically re-split when it comes time to .render() it again. It seems there are assumptions than the output is a single line again.
(Disclaimer: I have zero knowledge of AIS, but maybe I don't get too far)
I would let pynmea take care of the "transport" of the binary data in chunks, as it arrives. Then I would have an "upper stage" to which feed those blobs, and let it join and interpret the data as a whole.
For rendering, I would split the binary data in chunks and then encode each chunk in its own message. But this, again, using a first stage to split, and then pynmea (if it can) to encode them.