tbsalling / aismessages

AISmessages is a Java-based light-weight, zero-dependency, and ultra-efficient message decoder for maritime navigation and safety messages compliant with ITU 1371 (NMEA armoured AIS messages). A live demo of AISmessages is available on http://ais.tbsalling.dk.
https://github.com/tbsalling/aismessages/wiki
Other
156 stars 66 forks source link

Does it support message 24 ? #43

Closed qinqi closed 2 years ago

qinqi commented 2 years ago

Does it support message 24 ? !AIVDM,1,1,,A,H6:cCs@MDTL4pMUD4q@tpOS33R0,0*07

tbsalling commented 2 years ago

Yes, it does.

!AIVDM,1,1,,A,H6:cCs@MDTL4pMUD4q@tpOS33R0,0*07 translates into bit string 011000000110001010101011010011111011010000011101010100100100011100000100111000011101100101010100000100111001010000111100111000011111100011000011000011100010000000

According to ITU 1371-5 §3.22 the length of a type 24 message must be 160 or 168 bits. As you can see from the bit string your example is of bit length 162. Therefore the message is not compliant with the ITU 1371-5 spec.

A unit test like this:

@Test
    public void canDecode() {
        AISMessage aisMessage = AISMessage.create(NMEAMessage.fromString("!AIVDM,1,1,,A,H6:cCs@MDTL4pMUD4q@tpOS33R0,0*07"));
        System.out.println(aisMessage.toString());
    }

correctly fails with:

dk.tbsalling.aismessages.nmea.exceptions.InvalidMessage: Message of type ClassBCSStaticDataReport should be exactly 158, 160 or 168 bits long; not 162. Assumed sourceMmsi: 413848557.

It is sometimes seen that transmitters do not comply with the spec - so if you know how to interprete this invalid message we can add it to the code - or you can submit a pull request.