Skip to content

Commit a3698dc

Browse files
committed
serial/rfc2217: add timeout.setter for rfc2217
Add a new setter method for the timeout property which does not invoke the port reconfiguration. This is a direct copy of the SerialBase timeout property without the port reconfiguration. Signed-off-by: Rouven Czerwinski <[email protected]>
1 parent a27715f commit a3698dc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

serial/rfc2217.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,23 @@ def cd(self):
722722
raise portNotOpenError
723723
return bool(self.get_modem_state() & MODEMSTATE_MASK_CD)
724724

725+
@property
726+
def timeout(self):
727+
"""Get the current timeout setting."""
728+
return self._timeout
729+
730+
@timeout.setter
731+
def timeout(self, timeout):
732+
"""Change timeout setting."""
733+
if timeout is not None:
734+
try:
735+
timeout + 1 # test if it's a number, will throw a TypeError if not...
736+
except TypeError:
737+
raise ValueError("Not a valid timeout: {!r}".format(timeout))
738+
if timeout < 0:
739+
raise ValueError("Not a valid timeout: {!r}".format(timeout))
740+
self._timeout = timeout
741+
725742
# - - - platform specific - - -
726743
# None so far
727744

0 commit comments

Comments
 (0)