Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Dec 21, 2023
1 parent e87abce commit f958b77
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub enum Alert {
}

/// CAN abstraction
pub struct CanDriver<'d>(PeripheralRef<'d, CAN>, EnumSet<Alert>);
pub struct CanDriver<'d>(PeripheralRef<'d, CAN>, EnumSet<Alert>, bool);

impl<'d> CanDriver<'d> {
pub fn new(
Expand Down Expand Up @@ -430,7 +430,7 @@ impl<'d> CanDriver<'d> {

esp!(unsafe { twai_driver_install(&general_config, &timing_config, &filter_config) })?;

Ok(Self(can, config.alerts))
Ok(Self(can, config.alerts, config.tx_queue_len > 0))
}

pub fn start(&mut self) -> Result<(), EspError> {
Expand Down Expand Up @@ -640,7 +640,12 @@ where

match res {
Ok(()) => return Ok(()),
Err(e) if e.code() != ESP_ERR_TIMEOUT => return Err(e),
Err(e)
if e.code() != ESP_ERR_TIMEOUT
&& (e.code() != ESP_FAIL || self.driver.borrow().2) =>
{
return Err(e)
}
_ => (),
}

Expand Down

0 comments on commit f958b77

Please sign in to comment.