yellowfeather / aisparser Goto Github PK
View Code? Open in Web Editor NEWC# decoder for Automatic Identification System (AIS) for tracking ships and decoding maritime information
License: MIT License
C# decoder for Automatic Identification System (AIS) for tracking ships and decoding maritime information
License: MIT License
By the spec I'm looking at - 02/2014, "-5" - bits162-165 are PositionFixType? (Only 2 spare bits, not 6).
I'm fairly new to AIS though, so I might be wrong!
GroupAssignmentCommand does not appear to be implemented.
This message:
"!AIVDM,1,1,,B,GM3NJTo9MWGe<6::LQCW3CiE9fl,2*4C"
threw the error:
AisParser.AisMessageException: 'Unrecognised message type: GroupAssignmentCommand'
I'll see if I can get some time to write some code to handle it, but it's not very important....would be more for sake of completeness. Per https://gpsd.gitlab.io/gpsd/AIVDM.html#_type_23_group_assignment_command:
"This message is intended to be broadcast by a competent authority (an AIS network-control base station) to set operational parameters for all mobile stations in an AIS coverage region. Length is 160 bits.
This message contains no navigational information, and is unlikely to be of interest unless you are implementing or studying an AIS base station network."
Great project! We have added the base support for encoding a class to a binary AIS message as well in our fork and wondering if you're interested in pulling in these updates?
https://github.com/darren1713/AisParser/tree/DotNetStandard
There is a few notes for universal use:
Expand the testing framework to include encoding
Add the encoding function for text (not exactly sure about the exact character transformation required)
Add encode function for remaining message types after text field encoding
Hi!
I have long been looking for an AIS parser I can integrate into our NMEA parser. This library helped me find around the basic stuff and so I started integrating it into https://github.com/dotnet/iot/, where I'm a maintainer. That project is officially supported by the .NET foundation and provides interfacing APIs for all kinds of iot devices and sensors.
You can find the PR I created at dotnet/iot#1939. You are welcome to provide any suggestions/improvements.
I believe the Math.Pow should be:
public int ReadInt(int startIndex, int length)
{
var bitValue = Substring(startIndex, length);
var result = Convert.ToInt32(bitValue.Substring(1), 2);
if (bitValue.StartsWith("1"))
result = (int) (result - Math.Pow(2, bitValue.Length - 1 ));
return result;
}
Also, in conjunction, ReadRateOfTurn needs to return
return rateOfTurn == -128 ? null : new int?(rateOfTurn);
Hello,
I can parse the AIS message below using an online decoder successfully:
!AIVDM,2,1,9,B,56SvJh800000CLm0000d<O?3340000000000000k0000012<0;4jkl<t<<Di,0*0E"
However, when using this library, I am unable to parse the same message.
Hi, I've got <1 day experience with your library, but it's looking good so far!
I quickly catapulted a project together today for our system [we get raw AIS bytes, so I'm side-stepping the NMEA sentence parsing] and noticed that it seems possible to chuck invalid messages at it - e.g. a Message type 5 with only 2 bytes.
With many (all?) of the AIS message types being defined as a fixed numbers of bits, I was wondering if AisParser should throw if the Payload is too short (or too long) for the message type indicated by the first byte?
I've only been reading AIS spec for a couple of weeks, so apologies if I've over-simplified, but just looking to ensure catching rogue/corner cases in our code too.
'For discussion', not a criticism ;)
Hello.
"!AIVDM,2,1,6,A,56T6Bb82;pLA<t;N20Lht84j0qD8U8622222216:@@<55QW0=Rl
45Dp888,0*48"
<- I can decode this strings with online AIS decoder well, but when I put it in your library, it returns null.
using System;
using System.Windows.Forms;
using MissionPlanner;
using MissionPlanner.Utilities;
using System.Collections.Generic;
using System.Linq;
using MissionPlanner.Controls;
using AisParser;
using System.Text.RegularExpressions;
namespace AISParserSanityTestPlugins
{
public class AISParserSanityTestPlugins : MissionPlanner.Plugin.Plugin
{
AisParser.Parser parser;
public override string Name
{
get { return "AIS Parser Sanity Test Plugins"; }
}
public override string Version
{
get { return "0.30"; }
}
public override string Author
{
get { return "Open Source Community"; }
}
public override bool Init()
{
return true;
}
public override bool Loaded() //Loaded called after the plugin dll successfully loaded(different from loop())
{
parser = new AisParser.Parser();
loopratehz = 12.0f;
return true;
}
public override bool Loop()
{
string test_string = "!AIVDM,2,1,6,A,56T6Bb82;pL`A<t;N20Lht84j0qD8U8622222216:@@<55QW0=Rl`45Dp888,0*48";
try
{
var aisMessage = parser.Parse(test_string);
//Console.WriteLine("MMSI Number : " + aisMessage.Mmsi); //Error. Mmsi is null.
//Console.WriteLine("MMSI Number : " + aisMessage.mmsi); //Error. there is no member mmsi.
//Console.WriteLine("Ship Name : " + aisMessage.ShipName); //Error. no member. "ShipName" even though web AIS parser get ship name on this string.
//Console.WriteLine(aisMessage); //Print blank Texts.
//Console.WriteLine("ShipType : " + aisMessage.ShipType); //no member. "ShipType"
Console.WriteLine("Latitude : " + aisMessage.Latitude); //no member. "Latitude"
}
catch (Exception e)
{
Console.WriteLine("Error with this string : " + test_string);
Console.WriteLine("Error code : " + e);
Console.WriteLine("Stack Trace : " + e.StackTrace);
}
loopratehz = 20.0f;
return true;
}
public override bool Exit()
{
return true;
}
}
}
this code is mission planner plugin.
you can test this by install mission planner and put this *.cs file to plugins folder.
I can decode almost all message, but sometimes static and voyage related data? message doesn't read well.
Part A shouldn't be looking for 'Spare' - the Part A message ends with ShipName @ 160 bits.
[Apologies for not submitting a pull request, but I'm no expert on Git, so you might not thank me for trying lol. I think in this case it's just a one-line deletion]
Environment : Windows 10, laptop, Visual studio community 2017
dotnet version : 8.0.100-preview.1.23115.2(latest)
I downloaded this library and tried to compile as dll. because my plugin need this code.
but, it couldn't be compiled.
this is the error message :
MSB3644: The reference assemblies for framework ".NETFramework,Version=v5.0" were not found
so, I tried to install .net SDK 5.0, but found it is not supported version and it is for visual studio 2019.(I'm using visual studio 2017.)
Hi. I'm working through our shim between AisParser and our database and have noticed some inconsistency.
I'd got the impression (probably from looking at one particular parameter yesterday) that you weren't intercepting the "not available" values when parsing the bits. However I've just spotted that you do set null values in (for example) ReadRateOfTurn and ReadTrueHeading. Whereas you don't in (for example) ReadSpeedOverGround and ReadCourseOverGround.
It's debatable whether the 'not available' value (e.g. 511) should be passed back as-is, or intercepted-and-nulled - we had a long conversation ourselves this morning about which is best in later processing.
Our reasoning (in the context of our particular project): we have a wrapper around AisParser to convert a message into a 'dynamic data record' and/or a 'static/voyage data record'. The calling code doesn't know about the individual message types, it just gets the record(s) back.
So if the 'not available' values are nulled by AisParser, then that calling code can't differentiate between "the parameter has a 'not available' value in the message" compared with "the message [type] doesn't include that parameter". e.g. Rate Of Turn in a Position Report (1) vs. a StandardClassB (18).
It's not a killer for us at present, but if our customer needs us to process stuff differently in the future then it could be - so just thought I'd raise it with you for possible consideration/discussion! Cheers.
Hi,
I think this is wrong:
AisParser/src/AisParser/Messages/InterrogationMessage.cs
Lines 17 to 18 in 0ca20f0
it must be:
public InterrogationMessage()
: base(AisMessageType.Interrogation)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.