/** * Parse a string and store the results in the nmeaINFO structure * * @param parser a pointer to the parser * @param s the string * @param len the length of the string * @param info a pointer to the nmeaINFO structure * @return the number of packets that were parsed */ int nmea_parse(nmeaPARSER * parser, const char * s, int len, nmeaINFO * info) { int sentences_count = 0; int charIndex = 0; assert(parser); assert(s); assert(info); for (charIndex = 0; charIndex < len; charIndex++) { bool sentence_read_successfully = nmea_parse_sentence_character(parser, &s[charIndex]); if (sentence_read_successfully) { enum nmeaPACKTYPE sentence_type = nmea_parse_get_sentence_type(&parser->buffer.buffer[1], parser->buffer.length - 1); switch (sentence_type) { case GPGGA: if (nmea_parse_GPGGA(parser->buffer.buffer, parser->buffer.length, parser->sentence_parser.has_checksum, &parser->sentence.gpgga)) { sentences_count++; nmea_GPGGA2info(&parser->sentence.gpgga, info); } break; case GPGSA: if (nmea_parse_GPGSA(parser->buffer.buffer, parser->buffer.length, parser->sentence_parser.has_checksum, &parser->sentence.gpgsa)) { sentences_count++; nmea_GPGSA2info(&parser->sentence.gpgsa, info); } break; case GPGSV: if (nmea_parse_GPGSV(parser->buffer.buffer, parser->buffer.length, parser->sentence_parser.has_checksum, &parser->sentence.gpgsv)) { sentences_count++; nmea_GPGSV2info(&parser->sentence.gpgsv, info); } break; case GPRMC: if (nmea_parse_GPRMC(parser->buffer.buffer, parser->buffer.length, parser->sentence_parser.has_checksum, &parser->sentence.gprmc)) { sentences_count++; nmea_GPRMC2info(&parser->sentence.gprmc, info); } break; case GPVTG: if (nmea_parse_GPVTG(parser->buffer.buffer, parser->buffer.length, parser->sentence_parser.has_checksum, &parser->sentence.gpvtg)) { sentences_count++; nmea_GPVTG2info(&parser->sentence.gpvtg, info); } break; case GPNON: default: break; } } } return sentences_count; }
/** * \brief Analysis of buffer and put results to information structure * @return Number of packets wos parsed */ int nmea_parse( nmeaPARSER *parser, const char *buff, int buff_sz, nmeaINFO *info ) { int ptype, nread = 0; void *pack = 0; NMEA_ASSERT(parser && parser->buffer); // Analyze buffer and take info into parser nmea_parser_push(parser, buff, buff_sz); while(GPNON != (ptype = nmea_parser_pop(parser, &pack))) { nread++; switch(ptype) // ADD: call function to add info parsed here { case GPGGA: nmea_GPGGA2info((nmeaGPGGA *)pack, info); break; case GPGSA: nmea_GPGSA2info((nmeaGPGSA *)pack, info); break; case GPGSV: nmea_GPGSV2info((nmeaGPGSV *)pack, info); break; case GPRMC: nmea_GPRMC2info((nmeaGPRMC *)pack, info); break; case GPVTG: nmea_GPVTG2info((nmeaGPVTG *)pack, info); break; case HCHDG: nmea_HCHDG2info((nmeaHCHDG *)pack, info); break; case HCHDT: nmea_HCHDT2info((nmeaHCHDT *)pack, info); break; case TIROT: nmea_TIROT2info((nmeaTIROT *)pack, info); break; case YXXDR: nmea_YXXDR2info((nmeaYXXDR *)pack, info); break; }; free(pack); } return nread; }
/** * \brief Analysis of buffer and put results to information structure * @return Number of packets wos parsed */ int nmea_parse( nmeaPARSER *parser, const char *buff, int buff_sz, nmeaINFO *info ) { int ptype, nread = 0; void *pack = 0; //char c; //debugga NMEA_ASSERT(parser && parser->buffer); nmea_parser_push(parser, buff, buff_sz); while(GPNON != (ptype = nmea_parser_pop(parser, &pack))) { nread++; //KAY #ifndef BRIDGE_USB_GSM //USBWriteStr("POP: "); #endif switch(ptype) { case GPGGA: nmea_GPGGA2info((nmeaGPGGA *)pack, info); break; case GPGSA: nmea_GPGSA2info((nmeaGPGSA *)pack, info); break; case GPGSV: nmea_GPGSV2info((nmeaGPGSV *)pack, info); break; case GPRMC: nmea_GPRMC2info((nmeaGPRMC *)pack, info); break; case GPVTG: nmea_GPVTG2info((nmeaGPVTG *)pack, info); break; }; free(pack); } //KAY #ifndef BRIDGE_USB_GSM //USBWriteStr("nread: "); //int2char(&c,nread,1,10); //USBWriteChar(c); //USBWriteStr("\r\n"); #endif return nread; }
/** * \brief Analysis of buffer and put results to information structure * @return Number of packets wos parsed */ int nmea_parse( nmeaPARSER *parser, const char *buff, int buff_sz, nmeaINFO *info ) { int ptype, nread = 0; void *pack = 0; NMEA_ASSERT(parser && parser->buffer); nmea_parser_push(parser, buff, buff_sz); while(GPNON != (ptype = nmea_parser_pop(parser, &pack))) { nread++; switch(ptype) { case GPGGA: nmea_GPGGA2info((nmeaGPGGA *)pack, info); break; case GPGSA: nmea_GPGSA2info((nmeaGPGSA *)pack, info); break; case GPGSV: nmea_GPGSV2info((nmeaGPGSV *)pack, info); break; case GPRMC: nmea_GPRMC2info((nmeaGPRMC *)pack, info); break; case GPVTG: nmea_GPVTG2info((nmeaGPVTG *)pack, info); break; default: break; }; free(pack); } return nread; }