mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 11:06:04 +08:00
sensors app: logic fixed and cleanup
- do not exit sensors app if sensor init failed - do not spam console if we fail over first/second gyro Signed-off-by: tumbili <roman@px4.io>
This commit is contained in:
@@ -2096,12 +2096,7 @@ Sensors::task_main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
warnx("sensor initialization failed");
|
PX4_ERR("sensor initialization failed");
|
||||||
_sensors_task = -1;
|
|
||||||
|
|
||||||
DevMgr::releaseHandle(_h_adc);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sensor_combined_s raw = {};
|
struct sensor_combined_s raw = {};
|
||||||
@@ -2225,17 +2220,19 @@ Sensors::task_main()
|
|||||||
/* Work out if main gyro timed out and fail over to alternate gyro.
|
/* Work out if main gyro timed out and fail over to alternate gyro.
|
||||||
* However, don't do this if the secondary is not available. */
|
* However, don't do this if the secondary is not available. */
|
||||||
if (hrt_elapsed_time(&raw.gyro_timestamp[0]) > 20 * 1000 && _gyro_sub[1] >= 0) {
|
if (hrt_elapsed_time(&raw.gyro_timestamp[0]) > 20 * 1000 && _gyro_sub[1] >= 0) {
|
||||||
warnx("gyro has timed out");
|
if (fds[0].fd == _gyro_sub[0]) {
|
||||||
|
PX4_WARN("gyro0 has timed out");
|
||||||
|
}
|
||||||
|
|
||||||
/* If the secondary failed as well, go to the tertiary, also only if available. */
|
/* If the secondary failed as well, go to the tertiary, also only if available. */
|
||||||
if (hrt_elapsed_time(&raw.gyro_timestamp[1]) > 20 * 1000 && _gyro_sub[2] >= 0) {
|
if (hrt_elapsed_time(&raw.gyro_timestamp[1]) > 20 * 1000 && _gyro_sub[2] >= 0 && (fds[0].fd != _gyro_sub[2])) {
|
||||||
fds[0].fd = _gyro_sub[2];
|
fds[0].fd = _gyro_sub[2];
|
||||||
|
|
||||||
if (!_hil_enabled) {
|
if (!_hil_enabled) {
|
||||||
warnx("failing over to third gyro");
|
warnx("failing over to third gyro");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (_gyro_sub[1] >= 0) {
|
} else if (_gyro_sub[1] >= 0 && (fds[0].fd != _gyro_sub[1])) {
|
||||||
fds[0].fd = _gyro_sub[1];
|
fds[0].fd = _gyro_sub[1];
|
||||||
|
|
||||||
if (!_hil_enabled) {
|
if (!_hil_enabled) {
|
||||||
|
|||||||
Reference in New Issue
Block a user