Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't parse certain AIS message. #86

Open
ghost opened this issue Jun 5, 2023 · 1 comment
Open

Can't parse certain AIS message. #86

ghost opened this issue Jun 5, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 5, 2023

Hello.

"!AIVDM,2,1,6,A,56T6Bb82;pLA<t;N20Lht84j0qD8U8622222216:@@<55QW0=Rl45Dp888,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.

@ghost
Copy link
Author

ghost commented Jun 5, 2023

When I reviewed the text example, I came across the following link:

https://github.com/yellowfeather/AisParser/blob/master/test/AisParserTests/MessagesTests/StaticAndVoyageRelatedDataMessageTests.cs

Although it may appear empty, the information is actually stored and utilized when the remaining part of the message is received. Therefore, there is no loss of data in this case, I guess

but I'm not sure it is true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants