Skip to content

Commit

Permalink
ISO-TP fix single frame escape sequence for extended addr
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm committed Sep 2, 2024
1 parent c8fae87 commit c72d3b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/isotp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ impl<'a> IsoTPAdapter<'a> {
pub async fn send_single_frame(&self, data: &[u8]) -> Result<()> {
let mut buf;

if data.len() < 0x8 {
// Len fits in single nibble
if data.len() < self.can_max_dlen() {
// Len fits in classic CAN message
buf = vec![FrameType::Single as u8 | data.len() as u8];
} else {
// Use escape sequence for length, length is in the next byte
Expand Down
7 changes: 7 additions & 0 deletions tests/isotp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ async fn isotp_test_fd() {
};

// Single frame with some padding to reach next DLC
isotp_test_echo(6, config).await;
isotp_test_echo(7, config).await;
isotp_test_echo(8, config).await;

// Single frame escape
Expand Down Expand Up @@ -231,6 +233,11 @@ async fn isotp_test_fd_extended() {
..Default::default()
};

// Single frame with some padding to reach next DLC
isotp_test_echo(6, config).await;
isotp_test_echo(7, config).await;
isotp_test_echo(8, config).await;

// Single frame escape
isotp_test_echo(62, config).await;

Expand Down

0 comments on commit c72d3b5

Please sign in to comment.