Code Monkey home page Code Monkey logo

Comments (4)

bcl avatar bcl commented on August 29, 2024

It shouldn't be any different than the other messages. Exactly what problem are you having?

from aisparser.

lanas1234 avatar lanas1234 commented on August 29, 2024

Thanks for the answer!

I'm using the following code:

#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[] )
{
    ais_state     ais;
    char          buf[256]; 
    aismsg_5  msg_5;
    char   name[21]; 
    long   userid = 0;
    unsigned char  ship_type;

    /* Clear out the structures */
    memset( &ais, 0, sizeof( ais_state ) );

    /* Process incoming packets from stdin */
   
    if (argc<2) printf("\nTHERE'S NO INPUT!!");
    else{ 
		strcpy(buf, argv[1]);
        printf("UNO\n");
        if (assemble_vdm( &ais, buf ) == 0)
        {
			printf("DOS\n");
			/* Get the 6 bit message id */
            ais.msgid = (unsigned char) get_6bit( &ais.six_state, 6 );
            printf("Message type %u\n",ais.msgid);
            /* process message with appropriate parser */
            switch( ais.msgid ) {
                case 5:
                    if( parse_ais_5( &ais, &msg_5 ) == 0 )
                    {   
			printf("Type 5 detected \n");				
                        userid = msg_5.userid;
                        strcpy(name,msg_5.name);
                        ship_type=msg_5.ship_type;
                    }
                    break;            
                                   
            }  /* switch msgid */
            
            printf( "%d\n", ais.msgid );//Message ID
            printf( "%ld\n", userid );//MMSI
            printf( "%s\n", name);//NAME
            printf( "%u",ship_type);//SHIP_TYPE
            
        }  /* if */

	}/* if argc */
    return 0;
}

and typing in the command line one part or two part sentences I get:
lousado:~/AISdecode/aisparser> ./ais_text ' '!' AIVDM,2,1,1,A,55?MbV02;H;s<HtKR20EHE:0@T4@Dn2222222216L961O5Gf0NSQEp6ClRp8,0*1C '
UNO

lousado:~/AISdecode/aisparser> ./ais_text ' '!' AIVDM,2,1,1,A,55?MbV02;H;s<HtKR20EHE:0@T4@Dn2222222216L961O5Gf0NSQEp6ClRp8,01C '!'AIVDM,2,2,1,A,88888888880,225'
UNO

which means that the code is stopping at if (assemble_vdm( &ais, buf ) == 0) any clue of what is happening?

I guess that the problem is that the type 5 needs two sentences so the short question would be, how do these two sentences need to be joined?
All the best

from aisparser.

bcl avatar bcl commented on August 29, 2024

The parser joins them, you feed incoming text into assemble_vdm and when it has a complete message it will return 0, you can then call parse_ais_5 on the ais structure to extract all the fields from it. The problem is you aren't looping on the input. See https://github.com/bcl/aisparser/blob/master/c/examples/text/main.c for an example of reading from stdin -- it doesn't include message 5 support though, you'll have to add a case statement for that.

from aisparser.

lanas1234 avatar lanas1234 commented on August 29, 2024

Thanks for the answer!

My approach is a little different because I'm not interested in the 'Destination' field so I'm gonna 'cheat' my type 5 messages as they were a just one sentence (takinkg the first sentence and using a 'template' second sentence as I explain here)
I'm also not interested in a continuous stdin loop because I want to use as a function/answer to a matlab script.
Anyway I think I've figured out, thanks for your indications
All the best

from aisparser.

Related Issues (20)

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.