AP_DroneCAN: reimplement with BinarySemaphore

This commit is contained in:
Andrew Tridgell 2023-12-30 08:32:31 +11:00
parent e22e07fbbd
commit 036ae93cbb
2 changed files with 4 additions and 5 deletions

View File

@ -406,10 +406,9 @@ void CanardInterface::process(uint32_t duration_ms) {
WITH_SEMAPHORE(_sem_tx);
canardCleanupStaleTransfers(&canard, AP_HAL::micros64());
}
uint64_t now = AP_HAL::micros64();
const uint64_t now = AP_HAL::micros64();
if (now < deadline) {
_event_handle.wait(MIN(UINT16_MAX - 2U, deadline - now));
hal.scheduler->delay_microseconds(50);
IGNORE_RETURN(sem_handle.wait(deadline - now));
} else {
break;
}
@ -436,7 +435,7 @@ bool CanardInterface::add_interface(AP_HAL::CANIface *can_iface)
AP::can().log_text(AP_CANManager::LOG_ERROR, LOG_TAG, "DroneCANIfaceMgr: Can't alloc uavcan::iface\n");
return false;
}
if (!can_iface->set_event_handle(&_event_handle)) {
if (!can_iface->set_event_handle(&sem_handle)) {
AP::can().log_text(AP_CANManager::LOG_ERROR, LOG_TAG, "DroneCANIfaceMgr: Setting event handle failed\n");
return false;
}

View File

@ -72,7 +72,7 @@ private:
static CanardInterface test_iface;
#endif
uint8_t num_ifaces;
HAL_EventHandle _event_handle;
HAL_BinarySemaphore sem_handle;
bool initialized;
HAL_Semaphore _sem_tx;
HAL_Semaphore _sem_rx;