Skip to content

Help parsing serial GPS data #30

@chriskinal

Description

@chriskinal

I am trying to parse CSV data from a GPS. I have tried the row by row paring code below but I get no output. If I stream ( << ) the output directly in I see it is parsed when the code does cp.print but since the "file" never ends it seems I can't access the output. Here is a sample "row" from the GPS.

$KSXT,20190909084745.00,116.23662400,40.07897925,68.3830,299.22,-67.03,190.28,0.022,,1,3,46,28,,,,-0.004,-0.021,-0.020,,*27\r\n

#include <Arduino.h>
#include <CSV_Parser.h>
HardwareSerial* SerialGPS = &Serial7; // Main postion receiver (GGA & VTG)
constexpr int buffer_size = 256;
uint8_t GPSrxbuffer[buffer_size]; // Extra GPS1 serial rx buffer
uint8_t GPStxbuffer[buffer_size]; // Extra GPS1 serial tx buffer

CSV_Parser cp(/format/ "sssssssssssssssssssssss", /has_header/ false);

char feedRowParser() {
String input;
if ( SerialGPS->available() )
{
input = SerialGPS->readStringUntil('\n');
Serial.print("Read a row: ");
Serial.println(input.c_str());
}
return input.c_str();
}

bool rowParserFinished() {
Serial.println(SerialGPS->available());
return SerialGPS->available() == 0;
}

void setup() {
Serial.begin(115200);
SerialGPS->begin(460800);
SerialGPS->addMemoryForRead(GPSrxbuffer, buffer_size);
SerialGPS->addMemoryForWrite(GPStxbuffer, buffer_size);
delay(5000);
}

void loop() {
cp.parseRow();
cp.print();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions