Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsoTpMessage: support ISO-TP w/ CAN FD #1524

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
11 changes: 9 additions & 2 deletions python/uds.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,22 @@ def _isotp_rx_next(self, rx_data: bytes) -> ISOTP_FRAME_TYPE:

if rx_data[0] >> 4 == ISOTP_FRAME_TYPE.SINGLE:
self.rx_len = rx_data[0] & 0x0F
assert self.rx_len < self.max_len, f"isotp - rx: invalid single frame length: {self.rx_len}"
self.rx_dat = rx_data[1:1 + self.rx_len]
# "if the first byte of SF=0, then second byte specifies the size of the data."
# - https://en.wikipedia.org/wiki/CAN_FD
offset = 1
if self.rx_len == 0x0 and len(rx_data) > 8:
sshane marked this conversation as resolved.
Show resolved Hide resolved
self.rx_len = rx_data[1]
offset = 2
# assert self.rx_len < self.max_len, f"isotp - rx: invalid single frame length: {self.rx_len}"
self.rx_dat = rx_data[offset:offset + self.rx_len]
self.rx_idx = 0
self.rx_done = True
if self.debug:
print(f"ISO-TP: RX - single frame - {hex(self._can_client.rx_addr)} idx={self.rx_idx} done={self.rx_done}")
return ISOTP_FRAME_TYPE.SINGLE

elif rx_data[0] >> 4 == ISOTP_FRAME_TYPE.FIRST:
# should work with CAN FD. maybe a check for max 62 bytes from the spec?
Comment on lines 493 to +494
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheaduncan can you get a route where you cause a query longer than the single frame can hold, so we can see the first and consecutive frame action?

Copy link

@sheaduncan sheaduncan Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is with a fresh copy of master and pointing to this Panda Branch (isotp-canfd-support):
09136c309ba9461d/2024-02-07--08-51-50

This is with a fresh copy of master with current Panda master:
09136c309ba9461d/2024-02-07--14-42-56

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 more routes:

Red Panda in Aux port of C3 and USB Power into Main
09136c309ba9461d/2024-02-07--17-31-57

Red Panda in Aux port and OBD2 Power in Main
09136c309ba9461d/2024-02-07--17-36-38

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheaduncan can you try this branch and upload the rlog? It won't fingerprint. https://github.com/commaai/openpilot/tree/ford-test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sshane None of these fingerprinted for that branch. Getting Hyundai responses and getting new FW extended versions.

09136c309ba9461d/00000000--7340e1444b
09136c309ba9461d/00000001--578b507ed2
09136c309ba9461d/00000002--b138639015
09136c309ba9461d/00000003--7e95bc66d8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's what I was looking for. I'll check it out when I have time.

self.rx_len = ((rx_data[0] & 0x0F) << 8) + rx_data[1]
assert self.max_len <= self.rx_len, f"isotp - rx: invalid first frame length: {self.rx_len}"
self.rx_dat = rx_data[2:]
Expand Down
Loading