Giter Site home page Giter Site logo

ais-protocol-decoding's Introduction

AIS Decoder

The automatic identification system (AIS) is an automatic Tracking system used on ships and by vessel traffic services (VTS). When satellites are used to detect AIS signatures, the term Satellite-AIS (S-AIS) is used. AIS information supplements marine radar, which continues to be the primary method of collision avoidance for water transport.

Build Status

Ideal Node Version : 8.16.2

Tests : run npm test

AIS MESSAGES

  1. Position[0] format: !AIVDM, identifies this as an AIVDM packet (AIS format).
  2. Position[1] message_count: Messages counter (number of messages), sometimes the ais messages will be split over several messages.
  3. Position[2] message_id:
  4. Position[3] sequence_id: Sequential message, the current message number
  5. Position[4] channel: vhf channel A/B
  6. Position[5] payload: the ais data itself
  7. Position[6] size: number of bits required to fill the data

<format>,<message count>,<message id>,<sequence id>,<channel A/B>,<data>,<fill bits>

Important notes:

  • Ais payload is represented in a 6bits encoded string

API

  • 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 messages
  • private decode(input: Array<any>, session: any): void - decode the raw ais messages
  • private validateRawMessage(input: string): boolean - validate if the raw messages

Command Line:

  • node dist/bin/parse <ais message> for example: node ./dist/bin/parse "!AIVDM,1,1,,A,13u?etPv2;0n:dDPwUM1U1Cb069D,0*24"

Running example:

  • npm run example

Example:

// new Decoder(Array<AIS_Messages>, safeMode<Boolean>)
import { Decoder } from '../lib/index';
const aisMessages:Array<string> = [
  '!AIVDM,1,1,,A,400TcdiuiT7VDR>3nIfr6>i00000,0*78',
  '!AIVDM,2,1,0,A,58wt8Ui`g??r21`7S=:22058<v05Htp000000015>8OA;0sk,0*7B',
  '!AIVDM,2,2,0,A,eQ8823mDm3kP00000000000,2*5D',
  '!AIVDM,2,1,0,A,58wt8Ui`g??r21`7S=:22058<v05Htp000000015>8OA;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:

Bugs & PR's

  • If you find any bug please feel free to open an issue. PR are always welcome.

ais-protocol-decoding's People

Contributors

danchann avatar dependabot[bot] avatar doron2402 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ais-protocol-decoding's Issues

Bug in index.ts when parsing message 24

Hi Doron

I think I've found a bug in the src/lib/index.ts when receiving a message 24A. You have

case 24:
    report = parseStaticDataReport(
    this.bitarray, aisType, repeat,
    (session.sequence_id === 1 ? MESSAGE_PART.A : MESSAGE_PART.B),
    mmsi)
    break

but the session object for a 24A with a message of e.g. "!AIVDO,1,1,,B,H3P<........,2*46" won't necessarily have a session object defined at this point as the code relies on messageCounter>1 to define it and here that is 1. This results in it decoding part B by mistake in this case as the identity to 1 fails for an empty object. The message I've quoted is from messages recorded live so, even it isn't following the standard does exist 'in the wild'.

The fix that works for me is

case 24:
    report = parseStaticDataReport(
    this.bitarray, aisType, repeat,
    ((Object.keys(session).length === 0 || session.sequence_id === 1) ? MESSAGE_PART.A : MESSAGE_PART.B),
    mmsi)
    break

where there's a check to make sure the session has been defined (multipart message) or hasn't been (single message).

Thanks for the plugin !

Neill

Extended messages

Hello, really love the plugin, but it seems it does not recognise extended messages i.e(message 1 / type 14), is it possible to implement this?

unable to run npm install

Hi i am trying to use an ais-decoder for a firebase app i am making, but firebase deploy wont finish, it says there was a problem deploying, i am sure this plugin is the reason.

could there be a problem with the build script.

Great stuff btw, i am getting it to work on local deploy, and it is working perfectly.

here is some of the error message:

Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "npm_install had stderr output:\nnode-pre-gyp WARN Using request for node-pre-gyp https download \nnode-pre-gyp WARN Using request for node-pre-gyp https download \nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 2\nnpm ERR! [email protected] build: rm -rf ./dist && tsc\nnpm ERR! Exit status 2\nnpm ERR! \nnpm ERR! Failed at the [email protected] build script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!

i am running node -v 8.16.1 and npm -v 6.4.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.