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

error parsing ais message type 5 #15

Closed
handerpeder opened this issue Mar 14, 2019 · 2 comments
Closed

error parsing ais message type 5 #15

handerpeder opened this issue Mar 14, 2019 · 2 comments

Comments

@handerpeder
Copy link

handerpeder commented Mar 14, 2019

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
@bcl
Copy link
Owner

bcl commented Mar 17, 2019

Error 2 means you don't have enough bits for the message. Looking at your example data I see a couple of things that are going to cause problems:

  • The messages are out of order (see the sequence #) and are incomplete.
  • The 1,1 message should be complete, but it is too short for a message 5
  • You need to reset the ais struct on errors or when it is finished assembling a message
  • Check the return code of assemble_vdm

I do note that assemble_vdm doesn't give an error 5 when you feed it the out of sequence sentences so I'll look into that.

handerpeder added a commit to anteoas/ais2geojson that referenced this issue Mar 18, 2019
not working at the moment. either I'm missing something or it's an
issue with our parser lib [1]

[1]: bcl/aisparser#15
@bcl
Copy link
Owner

bcl commented Mar 19, 2019

Fixed by #19

@bcl bcl closed this as completed Mar 19, 2019
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

2 participants