Skip to content

Commit ceeef98

Browse files
committed
gs_usb: explicitly handle timeout=None separate from =0 (@zariiii9003)
1 parent 22a3cbd commit ceeef98

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

can/interfaces/gs_usb.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,13 @@ def _recv_internal(self, timeout: float | None) -> tuple[can.Message | None, boo
178178
"""
179179
frame = GsUsbFrame()
180180

181-
# Do not set timeout as None or zero here to avoid blocking
182-
timeout_ms = round(timeout * 1000) if timeout else 0
183-
if not self.gs_usb.read(frame=frame, timeout_ms=timeout_ms):
184-
return None, False
181+
if timeout is None:
182+
timeout_ms = 0
183+
else:
184+
# Do not set timeout as None or zero here to avoid blocking
185+
timeout_ms = round(timeout * 1000) if timeout else 1
186+
if not self.gs_usb.read(frame=frame, timeout_ms=timeout_ms):
187+
return None, False
185188

186189
msg = can.Message(
187190
timestamp=frame.timestamp,

0 commit comments

Comments
 (0)