commaai / commaai/opendbc

[ISO-TP] Number of consecutive frames is wrong when FC contains Block Size

Open
#1,682 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3.4k
Forks
2.3k
Avg merge
3d 2h
Merged PRs (30d)
38

Description

When an ECU responds with a non zero Block Size in the flow control, the number of consecutive frames might be wrong. E.g. if the ECU responds with a block size of 8, but there are less consecutive frames to send it will send zeroes instead.

Example:

```python
uds_client._uds_request(0x23, None, b"\x00" * 7)
```

Debug output:

```
ISO-TP: REQUEST - 0x7b7 0x2300000000000000
ISO-TP: TX - first frame - 0x7b7
CAN-TX: 0x7b7 - 0x1008230000000000
CAN-RX: 0x7bf - 0x300814aaaaaaaaaa
ISO-TP: RX - flow control continue - 0x7b7
CAN-TX: 0x7b7 - 0x2100000000000000
CAN-TX: delay - 0.02
CAN-TX: 0x7b7 - 0x2200000000000000
CAN-TX: delay - 0.02
CAN-TX: 0x7b7 - 0x2300000000000000
CAN-TX: delay - 0.02
CAN-TX: 0x7b7 - 0x2400000000000000
CAN-TX: delay - 0.02
CAN-TX: 0x7b7 - 0x2500000000000000
CAN-TX: delay - 0.02
CAN-TX: 0x7b7 - 0x2600000000000000
CAN-TX: delay - 0.02
CAN-TX: 0x7b7 - 0x2700000000000000
CAN-TX: delay - 0.02
CAN-TX: 0x7b7 - 0x2800000000000000
ISO-TP: TX - consecutive frame - 0x7b7 idx=8 done=True
CAN-RX: 0x7bf - 0x037f2331aaaaaaaa
ISO-TP: RX - single frame - 0x7bf idx=0 done=True
ISO-TP: RESPONSE - 0x7bf 0x7f2331
```

I think the fix should be to change https://github.com/commaai/panda/blob/master/python/uds.py#L535 to
```python
end = min(start + count * num_bytes, self.tx_len) if count > 0 else self.tx_len
```
But don't have time right now to verify.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.