diff --git a/python/uds.py b/python/uds.py index 9b25dffe6..f60720941 100644 --- a/python/uds.py +++ b/python/uds.py @@ -473,6 +473,7 @@ class IsoTpMessage(): # assert len(rx_data) == self.max_len, f"isotp - rx: invalid CAN frame length: {len(rx_data)}" if rx_data[0] >> 4 == ISOTP_FRAME_TYPE.SINGLE: + assert not self.rx_done, "isotp - rx: unexpected single frame" 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] @@ -483,6 +484,7 @@ class IsoTpMessage(): return ISOTP_FRAME_TYPE.SINGLE elif rx_data[0] >> 4 == ISOTP_FRAME_TYPE.FIRST: + assert self.rx_dat == b"", "isotp - rx: first frame with data already received" 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:]