diff --git a/python/uds.py b/python/uds.py index 1c2b156e..b7ea96ca 100644 --- a/python/uds.py +++ b/python/uds.py @@ -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