Skip to content

Commit

Permalink
adding serial timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
snhobbs committed May 14, 2024
1 parent 2d89276 commit 216e12d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/isp_programmer/IODevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def GetBaudrate(self):

class UartDevice(IODevice):
'''Serial IO device wrapper around pyserial'''
def __init__(self, port: str = "/dev/ttyUSB0", baudrate: int = 9600):
self.uart = Serial(port, baudrate, xonxoff=False)
def __init__(self, port: str = "/dev/ttyUSB0", baudrate: int = 9600, timeout: float = kTimeout):
self.uart = Serial(port, baudrate, xonxoff=False, timeout=timeout)
self.read = self.uart.read
self.read_all = self.uart.read_all
self.read_byte = self.uart.read
Expand All @@ -71,3 +71,4 @@ def ReadLine(self):
return bytes(line).decode("utf-8")
except UnicodeDecodeError:
raise TimeoutError

0 comments on commit 216e12d

Please sign in to comment.