Skip to content

Commit

Permalink
add timeout param
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjhogan committed Oct 15, 2019
1 parent cdf2f62 commit b1c3712
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/uds.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class InvalidSubFunctioneError(Exception):
}

class UdsClient():
def __init__(self, panda, tx_addr, rx_addr=None, bus=0, debug=False):
def __init__(self, panda, tx_addr, rx_addr=None, bus=0, timeout=10, debug=False):
self.panda = panda
self.bus = bus
self.tx_addr = tx_addr
Expand All @@ -275,6 +275,7 @@ def __init__(self, panda, tx_addr, rx_addr=None, bus=0, debug=False):

self.tx_queue = Queue()
self.rx_queue = Queue()
self.timeout = timeout
self.debug = debug

self.can_reader_t = threading.Thread(target=self._isotp_thread, args=(self.debug,))
Expand Down Expand Up @@ -384,7 +385,7 @@ def _uds_request(self, service_type, subfunction=None, data=None):

while True:
try:
resp = self.rx_queue.get(block=True, timeout=10)
resp = self.rx_queue.get(block=True, timeout=self.timeout)
except Empty:
raise MessageTimeoutError("timeout waiting for response")
if resp is None:
Expand Down

0 comments on commit b1c3712

Please sign in to comment.