Skip to content

Commit

Permalink
CAN: handle higher packet rate
Browse files Browse the repository at this point in the history
don't get stuck in rx at very high packet rates
  • Loading branch information
tridge committed Oct 24, 2023
1 parent 16933e4 commit 34cfcb9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion RemoteIDModule/CANDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void CANDriver::init(uint32_t bitrate, uint32_t acceptance_code, uint32_t accept

static const twai_general_config_t g_config = {.mode = TWAI_MODE_NORMAL, .tx_io = PIN_CAN_TX, .rx_io = PIN_CAN_RX, \
.clkout_io = TWAI_IO_UNUSED, .bus_off_io = TWAI_IO_UNUSED, \
.tx_queue_len = 5, .rx_queue_len = 5, \
.tx_queue_len = 5, .rx_queue_len = 50, \
.alerts_enabled = TWAI_ALERT_NONE, .clkout_divider = 0, \
.intr_flags = ESP_INTR_FLAG_LEVEL2
};
Expand Down
3 changes: 2 additions & 1 deletion RemoteIDModule/DroneCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ void DroneCAN::processTx(void)
void DroneCAN::processRx(void)
{
CANFrame rxmsg;
while (can_driver.receive(rxmsg)) {
uint8_t count = 60;
while (count-- && can_driver.receive(rxmsg)) {
CanardCANFrame rx_frame {};
uint64_t timestamp = micros64();
rx_frame.data_len = CANFrame::dlcToDataLength(rxmsg.dlc);
Expand Down

0 comments on commit 34cfcb9

Please sign in to comment.