mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 03:43:33 +08:00
gps: check for allocation failure & avoid busy loop
This commit is contained in:
@@ -712,7 +712,6 @@ GPS::task_main()
|
|||||||
|
|
||||||
if (_helper != nullptr) {
|
if (_helper != nullptr) {
|
||||||
delete (_helper);
|
delete (_helper);
|
||||||
/* set to zero to ensure parser is not used while not instantiated */
|
|
||||||
_helper = nullptr;
|
_helper = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -742,7 +741,7 @@ GPS::task_main()
|
|||||||
* MTK driver is not well tested, so we really only trust the UBX
|
* MTK driver is not well tested, so we really only trust the UBX
|
||||||
* driver for an advance publication
|
* driver for an advance publication
|
||||||
*/
|
*/
|
||||||
if (_helper->configure(_baudrate, GPSHelper::OutputMode::GPS) == 0) {
|
if (_helper && _helper->configure(_baudrate, GPSHelper::OutputMode::GPS) == 0) {
|
||||||
|
|
||||||
/* reset report */
|
/* reset report */
|
||||||
memset(&_report_gps_pos, 0, sizeof(_report_gps_pos));
|
memset(&_report_gps_pos, 0, sizeof(_report_gps_pos));
|
||||||
@@ -840,11 +839,15 @@ GPS::task_main()
|
|||||||
|
|
||||||
case GPS_DRIVER_MODE_ASHTECH:
|
case GPS_DRIVER_MODE_ASHTECH:
|
||||||
_mode = GPS_DRIVER_MODE_UBX;
|
_mode = GPS_DRIVER_MODE_UBX;
|
||||||
|
usleep(500000); // tried all possible drivers. Wait a bit before next round
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
usleep(500000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user