2017-05-30, 11:59 PM
(2017-05-30, 10:48 PM)abarrow Wrote: I don't suppose you could share your Arduino code? At least I wouldn't have to start from scratch!
Here are the 2 arduino functions which did the work..
Quote:String parseNmea(String nmeaBad)I was actually just having a look at node-red function but couldn't get it to work, javascript makes my head hurt :
{
//Serial.print(nmeaBad);
nmeaGood=nmeaBad.substring(1, nmeaBad.indexOf("*")); //cut of the leading "$" and the bad checksum
int CheckSum=(checkSum(nmeaGood)); //create a good checksum
nmeaGood="$"+nmeaGood+ "*" + String(CheckSum, HEX) + "\r\n"; // make the good nmea string
// Serial.println(nmeaGood);
return nmeaGood;
}
//---create a nmea checksum
char checkSum(String theseChars) {
char check = 0;
// iterate over the string, XOR each byte with the total sum:
for (int c = 0; c < theseChars.length(); c++) {
check = char(check ^ theseChars.charAt©);
}
// return the result
return check;
Still failing at sending an nmea sentence to kplex from node red as well. Oh well. :