Skip to content

Commit

Permalink
ISOTPConfig: Add option to override max_dlen
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm committed Aug 15, 2024
1 parent 5010f8d commit 02ec2c9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/isotp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ pub struct IsoTPConfig {
pub fd: bool,
/// Extended address
pub ext_address: Option<u8>,
/// Max data length. Will use default of 8 (CAN) or 64 (CAN-FD)
pub max_dlen: Option<usize>,
}

impl IsoTPConfig {
Expand Down Expand Up @@ -97,6 +99,7 @@ impl IsoTPConfig {
separation_time_min: None,
fd: false,
ext_address: None,
max_dlen: None,
}
}
}
Expand Down Expand Up @@ -156,10 +159,15 @@ impl<'a> IsoTPAdapter<'a> {

/// Maximum data length for a CAN frame based on the current config
fn max_can_data_length(&self) -> usize {
if self.config.fd {
self.can_fd_max_dlen()
} else {
self.can_max_dlen()
match self.config.max_dlen {
Some(dlen) => dlen,
None => {
if self.config.fd {
self.can_fd_max_dlen()
} else {
self.can_max_dlen()
}
}
}
}

Expand Down

0 comments on commit 02ec2c9

Please sign in to comment.