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 : 1 #2

Open
BPi0 opened this issue Oct 25, 2019 · 1 comment
Open

*** Error : 1 #2

BPi0 opened this issue Oct 25, 2019 · 1 comment

Comments

@BPi0
Copy link

BPi0 commented Oct 25, 2019

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)

}
}

@BPi0
Copy link
Author

BPi0 commented Oct 29, 2019

Counter-order.

I discovered that the problem relies on the length of the NMEA string token PSONCMS, which is longer than 5, and the buffer size of the parser which is 77 by default.
My messages are:
"$PSONCMS,0.6847,-0.0103,0.0100,-0.7287,-0.0653,-0.2873,9.8066,0.0012,-0.0026,-0.0021,-0.2983,-0.3619,-1.2700,32.673\r\n";
"$GPGGA,004206.70,0000.0000,S,00000.0000,W,0,00,0.0,0.0,M,0.0,M
55\r\n"
"$XSVEL,+000.0000,+000.0000,+000.0000*4D\r\n"

First, I tried to increase the buffer to 150 with
static const uint8_t kSentenceMaxSize = 150;
This worked in parsing the sentence in which I truncated the PSONCMS with PSONC, and recalculating the checksum of the message.

But then I don't know how to bypass the problem of parsing both strings of 5 and 7 letters together. The only way I tried is to truncate the string and re-check sum before feeding it to the parser, but is atoo consuming already when reading up to 25 hz (and i would like to increase it..). Unluckily the PSONCMS is very long to be parsed and fails the tasks, reading incomplete strings of the other GPGGA and XSVEL sentences. I work with an Arduino 2560 with 115200 Baudrate

What do you suggest?
Can be the code modified easily to support longer message identifiers? Or do you suggest a way to make the code lighter?
Thank you

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

1 participant