schwehr / libais

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

Handle Type 24 short messages #150

Open kgmonteith opened 8 years ago

kgmonteith commented 8 years ago

Per Eric Raymond's AIVDM guide, Type 24 Part A messages in the wild often omit the trailing spare bits. This results in an AIS_ERR_BAD_BIT_COUNT thrown from Ais24. It would be nice if the library could handle the (admittedly non-spec) short Type 24 messages.

Sample captured message: !AIVDM,1,1,,A,H5NbKPQ8Dh5@UHUAW8000000000,0*0A

Sample output:

>>> ais.decode('H5NbKPQ8Dh5@UHUAW8000000000',0)
Traceback (most recent call last):
  File "", line 1, in 
_ais.DecodeError: Ais24: AIS_ERR_BAD_BIT_COUNT
>>> ais.decode('H5NbKPQ8Dh5@UHUAW80000000000',0)
{u'mmsi': 367696770L, u'repeat_indicator': 0L, u'id': 24L, u'name': u'RELATIVITY2@@@@@@@@@', u'part_num': 0L}
gnilre commented 7 years ago

I would also like to see these messages handled, as they comprise almost all type 24 messages I receive.