diff --git a/python/uds.py b/python/uds.py index 416c344696cbae..18e29aca9d9bfe 100644 --- a/python/uds.py +++ b/python/uds.py @@ -151,9 +151,9 @@ def _isotp_thread(panda, bus, tx_addr, tx_queue, rx_queue): assert tx_frame["done"] == False, "tx: no active frame" # TODO: support wait/overflow assert rx_data[0] == 0x30, "tx: flow-control requires: continue" - delay_ts = ord(rx_data[2]) & 0x7F + delay_ts = rx_data[2] & 0x7F # scale is 1 milliseconds if first bit == 0, 100 micro seconds if first bit == 1 - delay_div = 1000. if ord(rx_data[2]) & 0x80 == 0 else 10000. + delay_div = 1000. if rx_data[2] & 0x80 == 0 else 100000. # first frame = 6 bytes, each consecutive frame = 7 bytes start = 6 + tx_frame["idx"] * 7 count = rx_data[1] @@ -164,7 +164,7 @@ def _isotp_thread(panda, bus, tx_addr, tx_queue, rx_queue): msg = (chr(0x20 | (tx_frame["idx"] & 0xF)) + tx_frame["data"][i:i+7]).ljust(8, "\x00") if (DEBUG): print("S: {} {}".format(hex(tx_addr), hexlify(msg))) panda.can_send(tx_addr, msg, bus) - if delay_ts: + if delay_ts > 0: time.sleep(delay_ts / delay_div) tx_frame["done"] = True