-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi,
I continuously receive :
*** Error : 1 sequences, and sometimes *** Error : 3.
It only parsed once a sentence in all the tests is did.
Why?
Could be due to the rate of com?
Regards.
PS I checked also the led example and gives the same error.
Connections:
Instrument sending NMEA sentences on Serial3. PC on Serial.
Type of sentences:
$PSONCMS,-0.9888,0.0072,-0.0056,-0.1491,-0.1582,-0.1052,9.8084,0.0001,-0.0016,-0.0004,0.2222,-0.1642,-1.1150,31.9*71
$GPGGA,003906.33,0000.0000,S,00000.0000,W,0,00,100.0,-17.0,M,0.0,M,,*44
$XSVEL,+000.0000,+000.0000,+000.0000*4D
CODE:
// LIBRARIES
#include <NMEAParser.h>
//INITIALISE LIBRARIES
NMEAParser<3> NMEAin; //Number of NMEA Parsers Handlers & NAME of the Parser
//INITIALISE VARIABLES
float GPS_Vx;
float GPS_Vy;
float GPS_Vz;
int incomingByte = 0; // for incoming Serial Data Bytes
char incomingChar; // for Bytes to String Data
//char incomingStr[50];
/* SETUP NMEA PARSER /
void errorHandler()
{
Serial.print("** Error : ");
Serial.println(NMEAin.error());
}
void unknownCommand()
{
Serial.print("*** Unkown command : ");
char buf[20];
NMEAin.getType(buf);
Serial.println(buf);
}
//SENTENCES HANDLERS
void PSONCMS_Handler()
{
Serial.print("Got PSONCMS with ");
Serial.print(NMEAin.argCount());
Serial.println(" arguments");
}
void GPGGA_Handler()
{
Serial.print("Got GPGGA with ");
Serial.print(NMEAin.argCount());
Serial.println(" arguments");
}
void XSVEL_Handler()
{
Serial.print("Got XSVEL with ");
Serial.print(NMEAin.argCount());
Serial.println(" arguments");
float GPS_Vx;
if (NMEAin.getArg(0,GPS_Vx)) Serial.println(GPS_Vx);
//if (NMEAin.getArg(1,GPS_Vy)) Serial.println(GPS_Vy);
//if (NMEAin.getArg(2,GPS_Vz)) Serial.println(GPS_Vz);
}
/* ----------------- */
void setup() {
// Turn on serial monitor and set baud rate
Serial3.begin(115200); // GNSS-IMU [Serial3]
Serial.begin(115200); // PC [Serial0] | MAIN-ARDUINO [Serial1]
Serial.write("COM On");
NMEAin.setErrorHandler(errorHandler);
NMEAin.addHandler("PSON-", PSONCMS_Handler);
NMEAin.addHandler("GPGGA", GPGGA_Handler);
NMEAin.addHandler("XSVEL", XSVEL_Handler);
//NMEAin.setDefaultHandler(unknownCommand);
}
void loop() {
while (Serial3.available()) {
String incomingStr = Serial3.readStringUntil('\n');//READ UNTIL NEW LINE
Serial.println(incomingStr); //PRINT
for (uint8_t i = 0; i < (incomingStr.length()); i++) {
NMEAin << incomingStr[i];
}
//NMEAin << Serial3.read(); //FORWARD INCOMING CHAR TO PARSER DIRECTLY (Alternative still not working)
}
}