Skip to content

Commit

Permalink
AP_Periph: solve a potential case where last_transmit_us can change i…
Browse files Browse the repository at this point in the history
…nside irqs
  • Loading branch information
bugobliterator authored and peterbarker committed Nov 2, 2023
1 parent fb26bbf commit ec2e92d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Tools/AP_Periph/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,9 @@ void AP_Periph_FW::processTx(void)
active if it has had a successful transmit in the
last 2 seconds
*/
const auto *stats = _ins.iface->get_statistics();
if (stats == nullptr || now_us - stats->last_transmit_us < 2000000UL) {
volatile const auto *stats = _ins.iface->get_statistics();
uint64_t last_transmit_us = stats->last_transmit_us;
if (stats == nullptr || AP_HAL::micros64() - last_transmit_us < 2000000UL) {
sent = false;
}
} else {
Expand Down

0 comments on commit ec2e92d

Please sign in to comment.