Commit f2011b30 authored by Beat Küng's avatar Beat Küng

GPSProvider: retry a few times before giving up when we get an error from the driver

This also replaces tabs with spaces
parent 795d48d2
......@@ -64,19 +64,31 @@ void GPSProvider::run()
/* reset report */
memset(&_reportGpsPos, 0, sizeof(_reportGpsPos));
int helperRet;
while ((helperRet = gpsHelper->receive(TIMEOUT_5HZ)) > 0 && !_requestStop) {
//In rare cases it can happen that we get an error from the driver (eg. checksum failure) due to
//bus errors or buggy firmware. In this case we want to try multiple times before giving up.
int numTries = 0;
while (!_requestStop && numTries < 3) {
int helperRet = gpsHelper->receive(TIMEOUT_5HZ);
if (helperRet > 0) {
numTries = 0;
if (helperRet & 1) {
publishGPSPosition();
numTries = 0;
}
if (_pReportSatInfo && (helperRet & 2)) {
publishGPSSatellite();
numTries = 0;
}
} else {
++numTries;
}
}
if (_serial->error() != QSerialPort::NoError) {
if (_serial->error() != QSerialPort::NoError && _serial->error() != QSerialPort::TimeoutError) {
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment