KimBP / AIS

An Arduino library able to decode AIS messages
Other
30 stars 9 forks source link

Type of message #4

Closed DavidReboreda closed 4 years ago

DavidReboreda commented 6 years ago

Hi! could you answer me a question please!!

All information explain that the class B only can send the messages type 18, 19 or 24 and another ones. But never 1, 2 or 3. Could you explain me why this AIVDM sentencie is type 1? !AIVDM,1,1,,A,13atNB000LNqjw0@6tPSCjb>0H45,0*5E

KimBP commented 6 years ago

I'll recommend reading http://catb.org/gpsd/AIVDM.html which is also mentioned in the REAME file. But basically the process is first to decode the message content. Your example starts with Ascii '1', '3' and 'a'. See how they are converted in http://catb.org/gpsd/AIVDM.html#_aivdm_aivdo_payload_armoring. Basically each character becomes a 6 bit value (See e.g. http://www.asciitable.com/ for conversion from 'character' to value')

Take the ascii value of the character and subtract 48. '1' => 49 => 49-48 => 1 => 000001 '3' => 51 => 51-48 => 3 => 000011 If, after subtracting, the number is higher than 48, subtract additional 8. 'a' => 97 => 97-48 => 49 => 49 - 8 => 41 => 101001

All 6 bit numbers are concatenated to one long stream of bits. In you example the resulting bitstream (first 18 bits) thus become: 000001000011101001 You now start picking out the bits. 6 first bits denotes the message. In this case it is 000001 => Message 1 A message 1-3 is described by http://catb.org/gpsd/AIVDM.html#_types_1_2_and_3_position_report_class_a We now know how to interpret the remaining bits Bit 6 and 7 describes repeat indicator: 00 Bit 8-37 describes the MMSI etc.

Sorry if I've forgotten some details