Code Monkey home page Code Monkey logo

aisparser's Introduction

AIS Parser SDK v1.10
Copyright 2006-2014 by Brian C. Lane <[email protected]>
All Rights Reserved
See LICENSE for licensing information


This is the first public release of the AIS Parser SDK. I have re-licensed it under the BSD license. See LICENSE for details. This code will now be available at https://github.com/bcl/aisparser/


'C' Version:
AIS Parser SDK source is in ./c/src/
HTML documentation is in ./c/docs/html/
Example programs are in ./c/examples/


Python Version:
The Python version is created using SWIG (www.swig.org), there are modules
for OSX, Linux and Windows. The SWIG .i file is included so you can rebuild
it yourself if needed.

Linux Python is in ./python/linux/
OSX Python is in ./python/osx/
Win32 Python is in ./python/win32/

I have removed the pre-compiled Python versions because they were out of date. You can rebuild them on your system by running the buildit script in their respective directories.

Win32 DLL built using Visual Studio 6 is in ./dll/aisparser
Visual Basic 6 example is in ./dll/examples
This version does not include a pre-compiled DLL. I no longer support Windows as a development environment so you will need to build your own.


AIS Parser SDK source
---------------------
The core parser consists of 12 files, 6 .c files and their associated .h files:

nmea.c/nmea.h - functions for processing NMEA 0183 sentences.
sixbit.c/sixbit.h - functions for processing packed 6-bit strings
vdm_parser.c/vdm_parser.h - functions for processing AIVDM sentences
imo.c/imo.h - functions for parsing IMO binary messages
seaway.c/seaway.h - functions for parsing St. Lawrence Seaway binary messages
access.c/access.h - helper functions for python and Visual Basic


St. Lawrence Seaway
-------------------
The parser code for St. Lawrence seaway binary messages is in the seaway.c file. The
seawayX_X messages have been tested against the examples in the Seaway documentation.
the pawssX_X messages have not been tested.

If someone has access to live Seaway messages that I could use in testing, I would
appreciate it if you would forward them to me at [email protected]

The St. Lawrence Seaway message specification is in ./c/docs/StLawrence.pdf


IMO Binary Messages
-------------------
The parser code for IMO binary messages is in the imo.c and imo.h files. The imoX_X messages have not yet been tested against real data.

If someone has access to live IMO Binary messages that I could use in testing, I would
appreciate it if you would forward them to me at [email protected]

The IMO Binary Message specification is in ./c/docs/IMO-236.pdf


HTML Documentation
------------------
The documentation is integrated with the code and extracted using Doxygen.
The HTML documentation index file is in ./c/docs/html/index.html
It can be regenerated using the Doxygen config file at ./c/docs/doxygen.conf


Examples
--------
The best place to start is the example code. I have included ais_json which
parses messages with position information and outputs a JSON (JavaScript)
data structure for use with the Google Maps demo webpage. There is also a
simple XML version and a text output version.

Parsing St. Lawrence Seaway and IMO binary messages are more complicated than the other messages. You must first parse the mssage 8 or 6, and then pass its data payload to the appropriate seaway/imo parser function to extract all of the information.


Python
------
The Python module is created using the SWIG project, it is a wrapper
around the SDK's 'c' source. Structures are implemented as classes in
Python, and all of the SDK's functions are exposed via the Python interface.

Check the ./python/example/ directory for examples of how to use the Python
module. There is a wxPython GUI application that will read a log file and display the details of the messages. There is also last_ais.py which I use to generate my dynamic
email signature, capturing the latest ship info from my local receiver.

The runme.py example in the swig directory can also be used. It has an example of parsing a Seaway 1.3 message. In python the struct arrays are not properly understood by the SWIG wrapper, so the helper function that matches the message must be used to first extract the array element before Python can operate on it.

Package can be directly pip installed with recent setuptools:

    python setup.py build_ext --inplace
    pip install -U .


Windows DLL
-----------
There is a Windows DLL, including source, in ./dll/aisparser
It was compiled using Visual Studio 6, and does not work with .NET or any of the new Visual tools that I am aware of. There is an example VB6 application in the ./dll/examples directory.

The Visual Basic example form code show how to use all of the normal parsing functions. I have attempted to add parsing of the IMO and St. Lawrence Seaway messages to it, including adding helper functions (which are also used by python), but I have been unable to convince Visual Basic to correctly recognize the data structures. So, for now, parsing all of the normal AIS messages works fine in VB6, but IMO and Seaway parsing doesn't work.


Delphi
------
Thanks to Chris Krohn for allowing me to include his Delphi port of the parser. This does not include the St. Lawrence Seaway parser code. It can be found in ./contrib/AISParser.pas


If you have any comments, questions, problems, etc. Please contact me and I'll get back to you as soon as I can. I appreciate feedback of any kind.

email - [email protected]

aisparser's People

Contributors

bcl avatar dependabot[bot] avatar electricpocket avatar schwehr 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aisparser's Issues

[Java] Messages without channel code not supported

The current version of the Vdm.add(String) method does not allow messages with no channel code set. If such message is being parsed, it throws a StringIndexOutOfBoundsException.

Is this an issue in the Vdm class or should a valid message always contain a channel code?

Any interest in updated Visual Studio project files?

I've been compiling Python versions using various Visual Studio versions for a few years now and have a set of project files for VS2022 Community Edition - do you have any interest in a pull request providing these new files (and with pre-compiled Python 3.10.4 .pyd if desired)?

Just checking before going through the effort, otherwise I can just push them to a fork.

Setup a fuzzer

Testing Message2

Taking a quick look at adding a test for Message2 and getting some suspicious results. Couple of surprising things that I see:

  • Messages 1, 2, and 3 are the same except for the message id (or effectively they can be represented 100% the same with a tiny bit of larger code side on the message state)
  • longitude and latitude in message and position are confusing at it seems that are confusing names as they are signed 1/10000 degree position and longs
  • rot, cog, looks like the raw values not the turn rate
  • Is there a reason not to break out the submessage?

This is also an example of junit4 with test discovery and a touch of cleanup. I did a by hand conversion of tabs to 4 spaces as tabs cause endless tool troubles for me. Would be maybe best to pick a formatter tool and setting and use that?

Thoughts?

package com.aisparser;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests for {@link Message2}. */
@RunWith(JUnit4.class)
public class Message2Test  {

    // Verifies decode of Msg 2 for a ship in a turn.
    @Test
    public void testParse() {
        Message2 msg = new Message2();

        try {
            Vdm vdm_message = new Vdm();
            int result = vdm_message.add("!AIVDM,1,1,,B,284;UGTdP4301>3L;B@Wk3TnU@A1,0*7C\r\n");
            assertEquals("vdm add failed", 0, result);
            msg.parse(vdm_message.sixbit());
        } catch (Exception e) {
            fail(e.getMessage());
        }

        // From libais:
        //     2, 0, 541255006, 4, -78, -271.591522217, false, 0.40000000596,
        //     0, 41.947201666666665, -62.606396666666669, 114, 27, 1, 1, false);

        assertEquals("msgid",  2, msg.msgid());
        assertEquals("repeat", 0, msg.repeat());
        assertEquals("userid", 541255006, msg.userid());
        assertEquals("nav_status", 4, msg.nav_status());
        assertEquals("rot", 178, msg.rot()); // TODO: Expected -78
        assertEquals("sog", 4, msg.sog());
        assertEquals("pos_acc", 0, msg.pos_acc());
        assertEquals("longitude", 25168321, msg.longitude()); // 41.947201666666665
        assertEquals("latitude", -37563838, msg.latitude()); // -62.606396666666669
        assertEquals("cog", 1996, msg.cog());
        assertEquals("true_heading", 114, msg.true_heading());
        assertEquals("utc_sec", 27, msg.utc_sec());
        assertEquals("regional", 4, msg.regional());
        assertEquals("spare", 1, msg.spare());
        assertEquals("raim", 0, msg.raim());
        assertEquals("sync_state", 2, msg.sync_state());
        assertEquals("slot_timeout", 4, msg.slot_timeout());
        assertEquals("sub_message", 1089, msg.sub_message());
    }
}

Build error on OSX 10.9.x

Any pointers about how to fix this?

house@New-MacBook-Pro:~/Documents/Software/AIS/aisparser-master/python/osx$ sudo ./buildit
Password:
aisparser_wrap.c:149:11: fatal error: 'Python.h' file not found

include <Python.h>

     ^

1 error generated.
ld: file not found: aisparser_wrap.o

Userid should be returned as string, not long

Some userId's is in the form '00000008'. While they are returned as long or int, they will be returned as "8", which will be wrong as mmsi numbers shall be nine digits. A fix is to return it as string type, not long.

Java parser doesn't check for matching channel when parsing multi-part message

In the C code it checks for the message sequence, order, and channel number: https://github.com/bcl/aisparser/blob/master/c/src/vdm_parse.c#L458 but in the Java parser it accepts whatever the current channel is: https://github.com/bcl/aisparser/blob/master/java/src/main/java/com/aisparser/Vdm.java#L115

(I no longer have a java development setup so am unable to fix this).

This shouldn't be a problem as long as the parser is fed messages that are from the same channel, and in order.

NMEA Data Parsing with ais_text.exe

I can't figure out how I'm supposed to run the AIS text parser c example. I'm operating on Windows 10, but am running through cygwin. I built with make ais_text, which produced ais_text.exe and tried to run ais_text.exe with a text file containing NMEA input from https://en.wikipedia.org/wiki/NMEA_0183, but it just hangs. I also tried putting single lines from that text file in the command line, but I am hitting a dead end. The text file for reference contains

$GPGGA,092750.000,5321.6802,N,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*76
$GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A
$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70
$GPGSV,3,2,11,02,39,223,19,13,28,070,17,26,23,252,,04,14,186,14*79
$GPGSV,3,3,11,29,09,301,24,16,09,020,,36,,,*76
$GPRMC,092750.000,A,5321.6802,N,00630.3372,W,0.02,31.66,280511,,,A*43
$GPGGA,092751.000,5321.6802,N,00630.3371,W,1,8,1.03,61.7,M,55.3,M,,*75
$GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A
$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70
$GPGSV,3,2,11,02,39,223,16,13,28,070,17,26,23,252,,04,14,186,15*77
$GPGSV,3,3,11,29,09,301,24,16,09,020,,36,,,*76
$GPRMC,092751.000,A,5321.6802,N,00630.3371,W,0.06,31.66,280511,,,A*45

Any help would be great!

Type 5 message parsing

Hi,

thanks for your work and effort in building this great decoder!

I'm start to working with it and I have no problem with normal message types (1,2,3,4) but I don't know how to work with type 5 sentences. Is it possible to do it with this parser? do you have any example?

I'm just interested in the name, mmsi and shiptype variables so if is not possible to decode type 5 messages is it possible to get these values somehow?

All the best

Java: Test Message 17 - GNSS broadcast

https://github.com/schwehr/libais/blob/master/src/test/ais17_test.cc:

!AIVDM,1,1,,A,A6WWW6gP00a3PDlEKLrarOwUr8Mg,0*03
0, 444196634, 3, -54.6133, 35.0333, 1, 19, 3513, 277, 6, 1

https://github.com/schwehr/libais/blob/master/test/data/typeexamples.json

!AIVDM,1,1,,B,AwoiGRg:tOw>>9n5f9u>rOvwkraEe6ON,0*34,d-106,S1812,t111948.00,T48.3410012,r003669945,1325416791,1325416731
{"repeat": 3, "spare2": 24, "mmsi": 1065113482, "lon": -90.54833221435547, "scaled": true, "lat": -0.6650000214576721, "spare": 3, "device": "stdin", "type": 17, "class": "AIS"}

https://github.com/schwehr/libais/blob/master/test/data/test.aivdm

# 17 - "A" GNSS broadcast
!AIVDM,1,1,1,A,A;wUJKU>io;WlWuwH`W1PpnuN<isf;5iHtOM1S6q?vsvNrNGOqLcr5mfD6t,2*51,d-127,S1378,t024436.00,T36.76385108,r09SCHA1,1272422678
!AIVDM,1,1,,A,AsjEC:5Ssb2MfUi:@nwgwutp7aOnwmuCodH,2*08,d-122,S0385,r05SANA1,1272423558
!AIVDM,1,1,4,A,AqsNwaiHSwMr97rvcWw5gmknSer?<NwNLGMjKk5pj`acJgCKFh,4*3E,d-126,S9999,r09SMIL1,1272423996
!AIVDM,1,1,,B,A1g:mCPP09M8bVD7wG4r<1vP0030oJrNF03U,0*4A,d-127,S0599,t031915.00,T15.99084234,r07RTRU1,1272424758
!AIVDM,1,1,,A,Asgw4Gg:94e7evilw4kKvvwHbA8i@V:QEEP,2*62,d-127,S0388,t032710.00,T10.35675633,r09NALP1,1272425231
!AIVDM,1,1,,A,Anoh<2JjqhIpsjRuq@,4*0B,d-126,S0110,t033202.00,T02.94217068,r09SGBY1,1272425523
!AIVDM,1,1,,A,A8jGvr7dswqara4nBkbNiwgsin7RM4cWDgpwS0,4*1B,d-129,S0247,t070306.00,T06.59691166,r07STYB1,1272425771

https://git.savannah.gnu.org/cgit/gpsd.git/tree/test/sample.aivdm#n683

# Type 17:
# From AISHub. This is only a regression test to check that the C and Python
# decoders do the same thing, not yet checked against other
# decoders. 
!AIVDM,2,1,5,A,A02VqLPA4I6C07h5Ed1h<OrsuBTTwS?r:C?w`?la<gno1RTRwSP9:BcurA8a,0*3A
!AIVDM,2,2,5,A,:Oko02TSwu8<:Jbb,0*11
#	Message Type             : 17
#	Repeat Indicator         : 0
#	MMSI                     : 2734450
#	Longitude                : 17478
#	Latitude                 : 35992
#	DGNSS data               : 376:7c0556c07031febbf52924fe33fa2933ffa0fd2932fdb7062922fe3809292afde9122929fcf7002923ffd20c29aaaa
#
# This one was found in the wild.  It has a negative latitude.
!AIVDM,1,1,1,A,A;wUJKU>io;WlWuwH`W1PpnuN<isf;5iHtOM1S6q?vsvNrNGOqLcr5mfD6t,2*51,d-127,S1378,t024436.00,T36.76385108,r09SCHA1,1272422678
#	Message Type             : 17
#	Repeat Indicator         : 0
#	MMSI                     : 804870766
#	Longitude                : 80669
#	Latitude                 : -26818
#	DGNSS data               : 272:7f7f6289c1838dbd78cc7bb8b17163c7dd0631b93feefe7ba7977f972be85d6e506f

Bad variable name

For c++ dev :
int true; //!< 9 bits : True Heading
this name is very bad. true is defined in c++.
trueHeading must be better

char virtual; //!< 1 bit : Virtual/Pseudo AtoN Flag
same problem with virtual, it's c++ keyword

Setup Continuous Integration (CI)

Having Travis-CI will ensure that pull requests actually work.

For Java, I'm starting by working on a maven config in #17.

Will need separate setups for python and C++.

[C++] C project fail to compile on C++ compiler

Due to "virtual" field in aismsg_21 structure, and "true" fields in structures in aismsg_1, 2, 3, 18 and 19 C variant fail to compile.
These words are declared as keywords in C++ and cannot be used as a variable name or structure field.

Changes proposal:

  • change fields "true" to "heading" among the project (or to "true_heading", as they declared in Java variant),
  • change field "virtual" to "pseudo"

AIS TYPE 5 Error

Dear all,

I have been having troubles to parse AIS TYPE 5 messages (they come in 2 parts).

For the Following Messages:
!AIVDM,2,1,9,A,5:U8vcP2<qeM11QB220lE8<u=Dj0MD584pV22216Hh9;C1Pe0Jlm@D1H,074
!AIVDM,2,2,9,A,888888888888880,2
2D

!AIVDM,2,1,1,B,5:UF2F021k4I118F220ME9E0622222222222221@<PR<75Nn0B4m@D1H,053
!AIVDM,2,2,1,B,888888888888880,2
26
AIVDM sample.docx

The first message comes as a type 5 message with error =1 which is expected. However, the second message comes with type 10 even though it is a type 5 continuation of the first one.

Anybody has experienced similar issue?

Best regards,

Rodrigo

EDIT: Apprently the asterisc symbol before the checksum is being changed when I update the comment.
I will attach a word file instead.

Java: Implement message 27

Other tests:

Some samples (good and bad):

2013:

!AIVDM,1,1,,A,KwsMwN0w5h,4*03,d-129,S1156,t034030.00,T30.84481429,r09SMRQ1,1368243629
!AIVDM,1,1,,A,KtMjBpWoDpWCWkRNNP,4*2E,r17MGUS1,1368243671
!AIVDM,1,1,,B,KjAOlWd,2*57,d-115,S0354,t034409.00,T09.44666483,r08SFRE1,1368243854
!AIVDM,1,1,,B,KihWOHjGDVi:60,4*51,r17MGUS2,1368243889
!AIVDM,1,1,,A,KDWw7mMc6B7Ia:<L?v0,2*27,r17MBAR2,1368244345
!AIVDM,1,1,,B,K51=OneVrDwL,0*48,r17MPEL1,1368244601
!AIVDM,1,1,,A,KmV54wGvfn`,2*7B,d-126,S1277,t035734.00,T34.06044244,r05RMSQ1,1368244662
!AIVDM,1,1,,B,KwwdCTs:vrmlFP,4*43,d-120,S1842,t040049.00,T49.12425726,r09SIGN1,1368244850
!AIVDM,1,1,,A,Kw`w1WFcfUKukofwD>wvwu=W,0*45,d-129,S0276,t040507.00,T07.35916518,r09SERE1,1368245110
!AIVDM,1,1,,B,K?LGMMUgg>BaUa@sWKoC,0*25,d-116,S1282,t042834.00,T34.20640534,r05XDCJ1,1368246514
!AIVDM,1,1,,B,KlbRLGDq,0*0C,d-123,S9999,r08TPHI1,1368246834
!AIVDM,1,1,,A,Kp>EkOrj,0*5A,d-122,S1278,t043434.00,T34.09039024,r07RISL1,1368246869
!AIVDM,1,1,,B,KntIBkIn5BV5Wrg3@RqUg6VU4o0,2*5B,r17MSGI1,1368247063
!AIVDM,1,1,,B,KOIg9e88,0*53,d-123,S1323,t044235.00,T35.28790247,r09SSAG1,1368247356

2014:

AIVDM,1,1,,A,K3Jj8f8LdHB<M0:4,0*75,b003669955,1405211802
!AIVDM,1,1,,A,K3Jj8f8LdHB<M0:4,0*75,b003669953,1405211802
!AIVDM,1,1,,A,KhOewGL,2*51,r17MKET3,1405211881
!AIVDM,1,1,,B,KO;fwOwupvL,2*0E,d-116,S0410,t003810.00,T10.93594672,r05SOIN1,1405211891
!AIVDM,1,1,,B,K3Jj8f8LdHB<M0<D,0*00,b003669953,1405211982
!AIVDM,1,1,,B,K3Jj8f8LdHB<M0<D,0*00,b003669955,1405211982
!AIVDM,1,1,,B,K3Jj8f8LdHB<M0<D,0*00,b2003669956,1405211982
!AIVDM,1,1,,A,KiE<@Emd0lW:RmN;u2psrcv<4tGkCh,4*56,r17MLAR1,1405212061
!AIVDM,1,1,,A,K3Jj8f8LdHB<M0>H,0*0D,b003669953,1405212162
!AIVDM,1,1,,A,K3Jj8f8LdHB<M0>H,0*0D,b003669955,1405212162

!AIVDM,1,1,,B,K3Jj8f8LdHB<M0=t,0*31,b003669953,1405216662
!AIVDM,1,1,,A,KjisW189gCtvN`wwWn79voUC,0*4A,d-126,S1898,t015850.00,T50.63288807,r14RHAL1,1405216732
!AIVDM,1,1,,A,K3Jj8f8LdHB<M0=t,0*32,b003669953,1405216842
!AIVDM,1,1,,A,K3Jj8f8LdHB<M0=t,0*32,b003669954,1405216842
!AIVDM,1,1,,B,K3Jj8f8LdHB<M0Al,0*55,b003669954,1405217022
!AIVDM,1,1,,B,K3Jj8f8LdHB<M0Al,0*55,b003669953,1405217022
!AIVDM,1,1,,A,Kq@wig0bK9t,2*73,d-118,S0956,t020625.00,T25.50939899,r07SMAY1,1405217186
!AIVDM,1,1,,A,K3Jj8f8LdHB<M0:8,0*79,b003669954,1405217201

2015:

\n:417909,s:b003669977,c:1442708522*1E\!SAVDM,1,1,,B,K815>P8LTHR:WP5l,0*78
\n:459432,s:b2003669980,c:1442708523*2A\!SAVDM,1,1,,B,K815>P8LTHR:WP5l,0*78
\n:348631,s:b003669979,c:1442708522*19\!SAVDM,1,1,,B,K815>P8LTHR:WP5l,0*78
\n:1142,s:b003669978,c:1442708522*15\!SAVDM,1,1,,B,K815>P8LTHR:WP5l,0*78

\n:460684,s:b003669952,c:1442716940*14\!SAVDM,1,1,,B,K3KC:08<fDB6wT1t,0*71
\n:731686,s:b003669953,c:1442716940*10\!SAVDM,1,1,,B,K3KC:08<fDB6wT1t,0*71
\n:257837,s:b003669978,c:1442716983*17\!SAVDM,1,1,,A,K815>P8<T9B:i5DL,0*60
\n:723537,s:b2003669980,c:1442716982*28\!SAVDM,1,1,,A,K815>P8<T9B:i5DL,0*60
\n:738928,s:b003669953,c:1442717120*1D\!SAVDM,1,1,,A,K3KC:08<fE27141t,0*24

\n:357716,s:b003669978,c:1442720224*19\!SAVDM,1,1,,A,K815>P8<Sv2;KTDP,0*06
\n:769673,s:b003669977,c:1442720224*1D\!SAVDM,1,1,,A,K815>P8<Sv2;KTDP,0*06
\n:986557,s:b2003669981,c:1442720222*2A\!SAVDM,1,1,,A,K815>P8<Sv2;KTDP,0*06
\g:1-2-153450,n:314303,s:r09RWIL1,c:1442720243*7F\!AIVDM,1,1,,B,K2WEMOCvsE9:slWhL`9svD5NkRVGw0,4*28
\n:827066,s:b2003669980,c:1442720402*22\!SAVDM,1,1,,B,K815>P8<SuR;MUD@,0*71
\n:992605,s:b2003669981,c:1442720402*2F\!SAVDM,1,1,,B,K815>P8<SuR;MUD@,0*71
\n:774758,s:b003669977,c:1442720404*1D\!SAVDM,1,1,,B,K815>P8<SuR;MUD@,0*71

\n:65286,s:b2003669980,c:1442723823*1C\!SAVDM,1,1,,A,K815>P8<Si2;o2ET,0*5E
\n:77232,s:b003669952,c:1442723959*21\!SAVDM,1,1,,A,K3KC:08<fkj8`6P4,0*2F
\g:1-2-5332,n:10829,s:r08NHNT1,c:1442723966*58\!AIVDM,1,1,,B,Kvilb3p=mOHjgCMmuPNk,0*05
\n:80577,s:b2003669981,c:1442724003*12\!SAVDM,1,1,,B,K815>P8<Shj;p1mp,0*14
\n:69937,s:b2003669980,c:1442724003*1C\!SAVDM,1,1,,B,K815>P8<Shj;p1mp,0*14

\n:205542,s:b003669954,c:1442791640*1E\!SAVDM,1,1,,A,K3KC:08LeNj:d0CL,0*12
\n:747212,s:b2003669980,c:1442791683*2B\!SAVDM,1,1,,B,K815>P9LShj;r08<,0*7F
\n:914805,s:b2003669981,c:1442791683*2E\!SAVDM,1,1,,B,K815>P9LShj;r08<,0*7F
\n:4975,s:r17MPBR1,c:1442791714*0D\!AIVDM,1,1,,A,Kvwuji3O7mVKJT`DUrQBnSkdWh,4*26
\n:515555,s:b003669953,c:1442791820*11\!SAVDM,1,1,,B,K3KC:08LeNj:d0;h,0*4D
\n:999575,s:b003669952,c:1442791820*1A\!SAVDM,1,1,,B,K3KC:08LeNj:d0;h,0*4D

2017:

\n:363179,s:b003669953,c:1485302726*10\!SAVDM,1,1,,A,K8VSqb9LdTB8WP8t,0*2D
\n:729930,s:b003669955,c:1485302726*19\!SAVDM,1,1,,A,K8VSqb9LdTB8WP8t,0*2D
\n:473,s:rACE0AD6,c:1485302761*4B\!ANVDM,1,1,,B,K5N7L8d<baRpo0FP,0*61
\n:96783,s:b2003669956,c:1485302906*11\!SAVDM,1,1,,B,K8VSqb9LdTB8WP8t,0*2E
\n:711,s:rACE0AD6,c:1485302940*41\!ANVDM,1,1,,A,K5N7L8d<baRpo0FP,0*62
\n:549969,s:b003669950,c:1485303086*18\!SAVDM,1,1,,A,K8VSqb9LdTB8WP:H,0*13
\n:313479,s:b003669889,c:1485303086*18\!SAVDM,1,1,,A,K8VSqb9LdTB8WP:H,0*13
\n:101382,s:b2003669956,c:1485303086*2B\!SAVDM,1,1,,A,K8VSqb9LdTB8WP:H,0*13
\n:953,s:rACE0AD6,c:1485303120*46\!ANVDM,1,1,,B,K5N7L8d<baRpo0FP,0*61

\n:118781,s:b003669955,c:1485312804*17\!SAVDM,1,1,,A,K8VSqb9LdTB8WP;T,0*0E
\n:13454,s:rACE0AD6,c:1485312842*43\!ANVDM,1,1,,B,K5N7L8d<baRpo0FP,0*61
\n:3368,s:r17MEGE1,c:1485312863*00\!AIVDM,1,1,,B,Kj=EBBNqu:K?woNi8pT,2*59
\n:13682,s:rACE0AD6,c:1485313021*46\!ANVDM,1,1,,A,K5N7L8d<baRpo0FP,0*62
\n:2293,s:r17MMET1,c:1485313098*12\!AIVDM,1,1,,B,KwwUde@j:P8,2*40
\n:3399,s:r17MDIL1,c:1485313145*04\!AIVDM,1,1,,B,Kkwv7wtewuuGGSKM:gG5ER5lG0,4*65
\n:435161,s:b2003669956,c:1485313164*2A\!SAVDM,1,1,,A,K8VSqb9LdTB8WP;T,0*0E
\g:1-2-145120,n:294019,s:r08NFTK1,c:1485313181*6F\!AIVDM,1,1,,B,Ksi5TGQo,0*6C

\n:275715,s:b003669955,c:1485316944*13\!SAVDM,1,1,,B,K8VSqb9LdTB8WP9l,0*37
\n:948945,s:b003669952,c:1485316944*1A\!SAVDM,1,1,,B,K8VSqb9LdTB8WP9l,0*37
\n:278168,s:b003669955,c:1485317009*13\!SAVDM,1,1,,B,K8;OfB8<c8ip`7jd,0*03
\n:56827,s:r17MSEW1,c:1485317110*3E\!AIVDM,1,1,,A,KtQ`G2qQh@R3<CgeEnSaIC?qlOmqd4Bq,0*48
\n:845553,s:b003669953,c:1485317124*13\!SAVDM,1,1,,A,K8VSqb9LdTB8WP9l,0*34
\n:884202,s:b003669954,c:1485317124*1A\!SAVDM,1,1,,A,K8VSqb9LdTB8WP9l,0*34

error parsing ais message type 5

I'm having an issue parsing incoming messages with ais message type 5. Parsing these message works with AisLib.

Please advise.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "portable.h"
#include "nmea.h"
#include "sixbit.h"
#include "vdm_parse.h"


int main( int argc, char *argv[] )
{
  int i = 0;
    ais_state ais;
    aismsg_5 msg_5;

    memset( &ais, 0, sizeof( ais_state ) );
    char *msg[] =
      {
       "!BSVDM,2,2,4,A,54SkDki@000,2*06",
       "!BSVDM,2,2,1,A,50E@0000000,2*3C",
       "!BSVDM,2,2,7,A,5`5QAhH8880,2*52",
       "!BSVDM,2,2,3,A,5H888888880,2*43",
       "!BSVDM,2,2,3,B,54SkDki@000,2*02",
       "!BSVDM,2,2,9,B,50E@0000000,2*37",
       "!BSVDM,2,2,2,A,5P@Ah000000,2*03",
       "!BSVDM,2,2,6,A,5`5QAhH8880,2*53",
       "!BSVDM,2,2,8,B,5H888888880,2*4B",
       "!BSVDM,2,2,2,B,5R1`0j8<M`0,2*79",
       "!BSVDM,1,1,,A,53mFl:400000hoG3;@0pE1ADp000,0*39"
    };

    for(i = 0; i < (sizeof(msg) / sizeof(const char*)) ; i++) {
      if(assemble_vdm( &ais, msg[i]) == 0) {
        ais.msgid = (unsigned char) get_6bit( &ais.six_state, 6 );
        printf("msgid: %d, parse result: %d\n", ais.msgid, parse_ais_5(&ais, &msg_5));
      }
    }

    return 0;
}

Output:

msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2
msgid: 5, parse result: 2

Flush out test coverage for Message 1

Looking at coverage for message1, the throw is the only line not covered. Need a message 1 that has a bad length. I know I've seen plenty in my logs, but need to either find one or make one up. And searching through many TB of logs isn't currently easy at the moment, crafting one would be easier. I'm currently having trouble with maven not doing a good job of showing me assert messages from junit, so it might take a bit.

if (six_state.bit_length() != 168)
    throw new AISMessageException("Message 1 wrong length"); // Untested line

And I realize that just hitting every line isn't enough, but it's a start.

Java: Test Message 16 - assigned mode command

https://github.com/schwehr/libais/blob/master/src/test/ais16_test.cc:

TEST(Ais16Test, DecodeAnything) {
  // !SAVDO,1,1,,B,@03OwnQ9RgLP3h0000000000,0*32,b003669978,1426173689
  std::unique_ptr<Ais16> msg = Init(
      "!SAVDO,1,1,,B,@03OwnQ9RgLP3h0000000000,0*32");

  Validate(
      msg.get(), 0, 3669978, 0,
      308461000, 60, 0,  // Destination A.
      0, 0, 00,  // Destination B.
      -1);
}

TEST(Ais16Test, BitsLeftOver) {
  std::unique_ptr<Ais16> msg(new Ais16("@fffffhfffffffff", 4));
  EXPECT_TRUE(msg->had_error());
  EXPECT_EQ(AIS_ERR_BAD_BIT_COUNT, msg->get_error());
}

TEST(Ais16Test, InvalidButCommon168Bits) {
  // !AIVDM,1,1,,B,@bQBNdhP010Fh<LMb;:GLOvJP4@d,0*7F
  std::unique_ptr<Ais16> msg(new Ais16("@bQBNdhP010Fh<LMb;:GLOvJP4@d", 0));
  Validate(msg.get(), 2, 705994419, 0, 134218757, 2819, 113, 916638301, 3199,
           922, -1);
}

https://github.com/schwehr/libais/blob/master/test/data/typeexamples.json

!AIVDM,1,1,,A,@TFtghNJ4G5?C7mV,0*3D,d-109,S1632,t010843.00,T43.5188,r003669945,1325984926,1325984896
{"repeat": 2, "increment2": 0, "offset2": 0, "increment1": 982, "mmsi": 292499393, "spare2": 6, "mmsi2": 0, "scaled": true, "spare": 3, "device": "stdin", "type": 16, "class": "AIS", "mmsi1": 646208595, "offset1": 3377}

https://github.com/schwehr/libais/blob/master/test/data/test.aivdm

# 16 - "@" Assigned mode command
!AIVDM,1,1,,A,@pCdoqggJc1KHfk`lIowv;WB,0*3C,d-113,S1457,t044938.00,T38.85972309,r01SPTW1,1272430182
!AIVDM,1,1,,B,@;IoLG5SKikg2E6fBW:?sTKV,0*36,r17PJUN1,1272433312
!AIVDM,1,1,,A,@m6t?hGwsbFuG59:M0,4*04,d-124,S2090,t074655.00,T55.73818711,r07RTRU1,1272440816
!AIVDM,1,1,,B,@h3OwhiGOl583h0000000500,0*30,b003669956,1272442253
!AIVDM,1,1,,B,@h3OwhiGOl583h0000000500,0*30,b003669954,1272442372
!AIVDM,1,1,,B,@h3OwhiGOl583h0000000500,0*30,b003669956,1272442494
!AIVDM,1,1,,B,@h3OwhiGOl583h0000000500,0*30,b003669952,1272442614
!AIVDM,1,1,,B,@lI`<5vWhhn2=4NA;Qo6G@,4*62,r17PANC1,1272446831
!AIVDM,1,1,,A,@u9D<59lD97uMwtAOWp,2*68,d-127,S1746,t100546.00,T46.57176849,r09NGMI1,1272449149

https://git.savannah.gnu.org/cgit/gpsd.git/tree/test/sample.aivdm#n667

# From AISHub. These are only a regression test to check that the C and Python
# decoders do the same thing, not yet checked against other
# decoders. 
#
# This is the 96-bit version addressing just one destination MMSI.
!AIVDM,1,1,,A,@01uEO@mMk7P<P00,0*18
#       Message Type             : 16
#       Repeat Indicator         : 0
#       MMSI                     : 2053501
#       Interrogated MMSI 1      : 224251000
#       First slot offset        : 200
#       First slot increment     : 0
#
# FIX-ME: Need an example of the 144-bit variant of type 16 with two MMSIs, g.

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.