1From a3698dc952fce0d07628133e987b7b43ed6e1157 Mon Sep 17 00:00:00 2001
2From: Rouven Czerwinski <rouven@czerwinskis.de>
3Date: Sun, 9 Sep 2018 20:08:40 +0200
4Subject: [PATCH] serial/rfc2217: add timeout.setter for rfc2217
5
6Add a new setter method for the timeout property which does not invoke
7the port reconfiguration.
8This is a direct copy of the SerialBase timeout property without the port
9reconfiguration.
10
11Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
12---
13 serial/rfc2217.py | 17 +++++++++++++++++
14 1 file changed, 17 insertions(+)
15
16diff --git a/serial/rfc2217.py b/serial/rfc2217.py
17index d962c1e8..12615cf3 100644
18--- a/serial/rfc2217.py
19+++ b/serial/rfc2217.py
20@@ -722,5 +722,22 @@ def cd(self):
21 raise portNotOpenError
22 return bool(self.get_modem_state() & MODEMSTATE_MASK_CD)
23
24+ @property
25+ def timeout(self):
26+ """Get the current timeout setting."""
27+ return self._timeout
28+
29+ @timeout.setter
30+ def timeout(self, timeout):
31+ """Change timeout setting."""
32+ if timeout is not None:
33+ try:
34+ timeout + 1 # test if it's a number, will throw a TypeError if not...
35+ except TypeError:
36+ raise ValueError("Not a valid timeout: {!r}".format(timeout))
37+ if timeout < 0:
38+ raise ValueError("Not a valid timeout: {!r}".format(timeout))
39+ self._timeout = timeout
40+
41 # - - - platform specific - - -
42 # None so far