mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-27 22:23:56 +08:00
IsoTpMessage: return if message updated (#1078)
* extend timeout for each message/frame (not multi-frame full response) * linter
This commit is contained in:
@@ -414,21 +414,23 @@ class IsoTpMessage():
|
||||
msg = (struct.pack("!H", 0x1000 | self.tx_len) + self.tx_dat[:self.max_len - 2]).ljust(self.max_len - 2, b"\x00")
|
||||
self._can_client.send([msg])
|
||||
|
||||
def recv(self, timeout=None) -> Optional[bytes]:
|
||||
def recv(self, timeout=None) -> Tuple[Optional[bytes], bool]:
|
||||
if timeout is None:
|
||||
timeout = self.timeout
|
||||
|
||||
start_time = time.monotonic()
|
||||
updated = False
|
||||
try:
|
||||
while True:
|
||||
for msg in self._can_client.recv():
|
||||
self._isotp_rx_next(msg)
|
||||
start_time = time.monotonic()
|
||||
updated = True
|
||||
if self.tx_done and self.rx_done:
|
||||
return self.rx_dat
|
||||
return self.rx_dat, updated
|
||||
# no timeout indicates non-blocking
|
||||
if timeout == 0:
|
||||
return None
|
||||
return None, updated
|
||||
if time.monotonic() - start_time > timeout:
|
||||
raise MessageTimeoutError("timeout waiting for response")
|
||||
finally:
|
||||
@@ -553,7 +555,7 @@ class UdsClient():
|
||||
response_pending = False
|
||||
while True:
|
||||
timeout = self.response_pending_timeout if response_pending else self.timeout
|
||||
resp = isotp_msg.recv(timeout)
|
||||
resp, _ = isotp_msg.recv(timeout)
|
||||
|
||||
if resp is None:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user