Skip to content

Commit

Permalink
fix separation time parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjhogan committed Oct 15, 2019
1 parent c641e66 commit 4429600
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/uds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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

Expand Down

0 comments on commit 4429600

Please sign in to comment.