Skip to content

Commit d656868

Browse files
committed
Merge branch 'fix/rfc2217_timeout_set'
2 parents a27715f + a3698dc commit d656868

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)