Hello,
I have a problem with reading NMEA data in a Qt program on an embedded system with Linux.
Here are some info about the used software:
Linux: Version 3.10.44
QT: Version 4.8.1
Gpsd: Version 3.11
The program uses the routines out of library libgps.
After gps_open, I use a notifier to trigger an event whenever new data are available in ‘gpsdata.gps_fd’.
After this , I set ‘gps_stream(&gpsdata, WATCH_ENABLE|WATCH_NMEA,NULL)
When the event is triggered, I do the following code (this are only the important lines)
Int r= gps_read(&gps_data);
QString lines = QString(gps_data(&gpsdata)
Then the string in ‘lines‘ is splitted on ‘\n’ and displayed in a textfield.
My observations are:
On each new NMEA (or JSON) line that is written by GPSD into the client, the notifier triggers an event. (This is correct)
When I check variable r (result of gps_read), it shows the correct number of characters for the NMEA string (This is correct)
The error comes when I execute the next line ‘QString lines = QString(gps_data(&gpsdata)’.
This list of strings is up to 8194 characters long and contains up to 150 Strings.
Only the first string is the actual NMEA string, the other strings are older NMEA strings or parts of NMEA strings.
In my opinion, the error is the following:
When I execute the gps_data function, the content of the buffer must be reduced by the size of the NMEA string (either delete the line or set the buffer pointers accordingly).
It seems to me that this clearing of the buffer is not done.
8194 Characters seems to me is the max size of the Buffer.
When a new string is written to the Buffer, the start Pointer is set correctly to the begin of the NMEA string. The end Pointer is not set correctly and always, the whole buffer is read.
What I don’t understand is, that the same routine runs on my Ubuntu PC (GPSD version 3.4.)
Can you please help me to solve the problem or give me an idea what else I can check.
Best regards
Uli Betzenbichler
_____________________________________
Ulrich Betzenbichler
Senior System Engineer
CSR Technology GmbH
Marie-Curie-Str. 1
85055 Ingolstadt, Germany
Direct: +49 (0)841 9378041
Fax.: +49 (0841) 9378-010