From b55294920bf38b632e868893445b4e6a8a20dfb3 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 3 Feb 2016 01:58:10 -0200 Subject: [PATCH] AP_Compass: AK8963: remove logging on fail to get semaphore This is the only driver doing this, using the system_initializing() from scheduler to log selectively. Remove the check together with removal of unused wrapper methods to semaphore. --- libraries/AP_Compass/AP_Compass_AK8963.cpp | 35 ++-------------------- libraries/AP_Compass/AP_Compass_AK8963.h | 3 -- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass_AK8963.cpp b/libraries/AP_Compass/AP_Compass_AK8963.cpp index d73d9e9148..3fa15ec6fc 100644 --- a/libraries/AP_Compass/AP_Compass_AK8963.cpp +++ b/libraries/AP_Compass/AP_Compass_AK8963.cpp @@ -236,7 +236,7 @@ void AP_Compass_AK8963::_update() goto end; } - if (!_sem_take_nonblocking()) { + if (!_bus_sem->take_nonblocking()) { goto end; } @@ -287,7 +287,7 @@ void AP_Compass_AK8963::_update() _last_update_timestamp = AP_HAL::micros(); fail: - _sem_give(); + _bus_sem->give(); end: return; } @@ -335,37 +335,6 @@ bool AP_Compass_AK8963::_calibrate() return true; } -bool AP_Compass_AK8963::_sem_take_blocking() -{ - return _bus_sem->take(10); -} - -bool AP_Compass_AK8963::_sem_give() -{ - return _bus_sem->give(); -} - -bool AP_Compass_AK8963::_sem_take_nonblocking() -{ - static int _sem_failure_count = 0; - - if (_bus_sem->take_nonblocking()) { - _sem_failure_count = 0; - return true; - } - - if (!hal.scheduler->system_initializing() ) { - _sem_failure_count++; - if (_sem_failure_count > 100) { - AP_HAL::panic("PANIC: failed to take _bus->sem " - "100 times in a row, in " - "AP_Compass_AK8963"); - } - } - - return false; -} - void AP_Compass_AK8963::_dump_registers() { #if AK8963_DEBUG diff --git a/libraries/AP_Compass/AP_Compass_AK8963.h b/libraries/AP_Compass/AP_Compass_AK8963.h index f345ac90f5..d7a5187b82 100644 --- a/libraries/AP_Compass/AP_Compass_AK8963.h +++ b/libraries/AP_Compass/AP_Compass_AK8963.h @@ -68,9 +68,6 @@ private: void _update(); void _dump_registers(); - bool _sem_take_blocking(); - bool _sem_take_nonblocking(); - bool _sem_give(); float _magnetometer_ASA[3] {0, 0, 0}; uint8_t _compass_instance;