Dear forum,
I have the following problem: I try to read GPS data (a so called nmea-string)from a GPS-mouse via a virtual serial port into my application and to show this data in a QPlainTextEdit-widget. I do this using the following very simple function (connection to the serial port is allready opened):
void DialogPreferences::readData()
{
QByteArray rawData
= serial
->readAll
();
// read data from serial port ui->plainTextEdit->insertPlainText(rawData) // show data in QPlainTextEdit
qDebug() << rawData; // show same data in the console
}
void DialogPreferences::readData()
{
QByteArray rawData = serial->readAll(); // read data from serial port
ui->plainTextEdit->insertPlainText(rawData) // show data in QPlainTextEdit
qDebug() << rawData; // show same data in the console
}
To copy to clipboard, switch view to plain text mode
The serial port is connected to the QPlainTextEdit widget via
connect(serial, SIGNAL(readyRead()), this, SLOT(readData()));
connect(serial, SIGNAL(readyRead()), this, SLOT(readData()));
To copy to clipboard, switch view to plain text mode
Output in the QPlainTextEdit-Widget:
$GPGGA,141559.000,5858.4209,N,00956.6503,E,2,8,1.7 5,29.4,M,41.2,M,0000,0000*64
$GPGLL,5858.4209,N,00956.6503,E,141559.000,A,D*54
$GPGSA,A,3,14,08,32,03,11,04,19,01,,,,,1.97,1.75,0 .91*04
$GPRMC,141559.000,A,5858.4209,N,00956.6503,E,0.36, 235.13,071015,,,D*62
This works as it should. But if I try to display the same data with qDebug() in the console, I get the following result:
"GPGGA,141559.000"
",5858.4209,N,0095"
"6.6503,E,2,8,1"
".75,29.4,M,41.2"
",M,0000,0000*64"
"\r\n$GPGLL,5858.42"
"09,N,00956.6503,"
"E,141559.000,"
"A,D*54\r\n$GPGSA,"
"A,3,14,08,32,03,"
"11,04,19,01,,,"
",,1.97,1.75,0.9"
"1*04\r\n$GPRMC,14"
"1559.000,A,5858"
".4209,N,00956."
"6503,E,0.36,235"
".13,071015,,,D*"
"62\r\n$GPVTG,235."
In the raw data the lines are seperated by a combination of \r\n. But obvisouly the array is splitted on, for me, arbitrary places, and I have no idea why! I need the line exact as shown in the QPlainText widget for further analysis, any suggenstions, how I can reach that?
Thanks in advance for your help!
vittorio
Bookmarks