Browse Source

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

This also replaces tabs with spaces
QGC4.4
Beat Küng 9 years ago
parent
commit
f2011b3005
  1. 18
      src/GPS/GPSProvider.cc

18
src/GPS/GPSProvider.cc

@ -64,19 +64,31 @@ void GPSProvider::run() @@ -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;
}
}

Loading…
Cancel
Save