Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DroneCAN: backport of lockup fix #28219

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libraries/AP_DroneCAN/AP_DroneCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ void AP_DroneCAN::loop(void)
continue;
}

// ensure that the DroneCAN thread cannot completely saturate
// the CPU, preventing low priority threads from running
hal.scheduler->delay_microseconds(100);

canard_iface.process(1);

safety_state_send();
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_HAL_ChibiOS/UARTDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,9 @@ void UARTDriver::write_pending_bytes_DMA(uint32_t n)
STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE);
dmaStreamEnable(txdma);
uint32_t timeout_us = ((1000000UL * (tx_len+2) * 10) / _baudrate) + 500;
// prevent very long timeouts at low baudrates which could cause another thread
// using begin() to block
timeout_us = MIN(timeout_us, 100000UL);
chSysUnlock();
// wait for the completion or timeout handlers to signal that we are done
eventmask_t mask = chEvtWaitAnyTimeout(EVT_TRANSMIT_DMA_COMPLETE, chTimeUS2I(timeout_us));
Expand Down
Loading