Ais Decoder (TypeScript, Node 12.17.0)
npm install ais-decoder-ts

format: !AIVDM, identifies this as an AIVDM packet (AIS format).message_count: Messages counter (number of messages), sometimes the ais messages will be split over several messages.message_id:sequence_id: Sequential message, the current message numberchannel: vhf channel A/Bpayload: the ais data itselfsize: number of bits required to fill the data
### Important notes:
- Ais payload is represented in a 6bits encoded string
constructor(AIS_Messages, safeMode)AIS_Messages: Array of ais messages.safeMode: set to false by default. when true the module will never throw an error (silent mode).getResults() - return a collection of the parse messagesprivate decode(input: Array, session: any): void - decode the raw ais messagesprivate validateRawMessage(input: string): boolean - validate if the raw messagesnode dist/bin/parse for example: node ./dist/bin/parse "!AIVDM,1,1,,A,13u?etPv2;0n:dDPwUM1U1Cb069D,0*24"npm run examplejavascript
// new Decoder(Array, safeMode)
import { Decoder } from '../lib/index';
const aisMessages:Array = [
'!AIVDM,1,1,,A,400TcdiuiT7VDR>3nIfr6>i00000,0*78',
'!AIVDM,2,1,0,A,58wt8Ui g??r217S=:220588OA;0sk,0*7B',
'!AIVDM,2,2,0,A,eQ8823mDm3kP00000000000,2*5D',
'!AIVDM,2,1,0,A,58wt8Ui g??r217S=:220588OA;0sk,0*7B ',
'!AIVDM,2,2,0,A,eQ8823mDm3kP00000000000,2*5D',
];
const safeMode = false;
const aisDecoder_ex2 = new Decoder(aisMessages, safeMode);// results will hold a collection of the parsed ais messages
const results = aisDecoder_ex2.getResults();
`` ### References:
- Gov:
- https://www.navcen.uscg.gov/?pageName=AISMessagesA
- Gpsd:
- https://gpsd.gitlab.io/gpsd/AIVDM.html [recommended]
- OpenCPN:
- https://github.com/OpenCPN/OpenCPN [file: AIS_Bitstring.cpp]
- http://fossies.org/linux/misc/gpsd-3.11.tar.gz/gpsd-3.11/test/sample.aivdm
- online AIS decoder:
- http://www.maritec.co.za/tools/aisvdmvdodecoding/
- http://www.maritec.co.za/aisvdmvdodecoding1.php
- Wikipedia:
- https://en.wikipedia.org/wiki/Automatic_identification_system
- OpenCPN
- Github: https://github.com/OpenCPN/OpenCPN/blob/45504f35c005ed1ffcd117c67797279da42d53ae/src/AIS_Decoder.cpp