at master 1.8 kB view raw
1From c8b35f4b871d00e3020f525425517548bed9f6ad Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de> 3Date: Sun, 9 Sep 2018 20:13:27 +0200 4Subject: [PATCH] serial/rfc2217: only subnegotiate on value change 5MIME-Version: 1.0 6Content-Type: text/plain; charset=UTF-8 7Content-Transfer-Encoding: 8bit 8 9This was suggested and is a direct copy of Uwe Kleine König's patch 10from [1]. 11 12[1]: https://github.com/pyserial/pyserial/issues/376#issuecomment-418885211 13Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> 14--- 15 serial/rfc2217.py | 14 +++++++++----- 16 1 file changed, 9 insertions(+), 5 deletions(-) 17 18diff --git a/serial/rfc2217.py b/serial/rfc2217.py 19index d962c1e8..2148512d 100644 20--- a/serial/rfc2217.py 21+++ b/serial/rfc2217.py 22@@ -330,11 +330,15 @@ def set(self, value): 23 the client needs to know if the change is performed he has to check the 24 state of this object. 25 """ 26- self.value = value 27- self.state = REQUESTED 28- self.connection.rfc2217_send_subnegotiation(self.option, self.value) 29- if self.connection.logger: 30- self.connection.logger.debug("SB Requesting {} -> {!r}".format(self.name, self.value)) 31+ if value != self.value: 32+ self.value = value 33+ self.state = REQUESTED 34+ self.connection.rfc2217_send_subnegotiation(self.option, self.value) 35+ if self.connection.logger: 36+ self.connection.logger.debug("SB Requesting {} -> {!r}".format(self.name, self.value)) 37+ else: 38+ if self.connection.logger: 39+ self.connection.logger.debug("SB Requesting {} -> {!r} (skipped)".format(self.name, self.value)) 40 41 def is_ready(self): 42 """\