mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-24 14:43:37 +00:00
db945b0751
These two patches significantly improve the RFC2217 negotiation and support for devices like the Moxa serial servers. The patches reduce the amount of negotiations done over RFC2217 and, in case of the timeout setter patch, prevent pyserial from setting the timeout again on every send line. We have been using these in a downstream fork for 2 years now and have not seen problems in the field. Upstream has acted neither on the issue [1] nor on the proposed pull request [2], so I am proposing to include them downstream within nixpkgs instead. [1]: https://github.com/pyserial/pyserial/issues/376 [2]: https://github.com/pyserial/pyserial/pull/382
43 lines
1.7 KiB
Diff
43 lines
1.7 KiB
Diff
From c8b35f4b871d00e3020f525425517548bed9f6ad Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
|
|
Date: Sun, 9 Sep 2018 20:13:27 +0200
|
|
Subject: [PATCH] serial/rfc2217: only subnegotiate on value change
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This was suggested and is a direct copy of Uwe Kleine König's patch
|
|
from [1].
|
|
|
|
[1]: https://github.com/pyserial/pyserial/issues/376#issuecomment-418885211
|
|
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
|
|
---
|
|
serial/rfc2217.py | 14 +++++++++-----
|
|
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/serial/rfc2217.py b/serial/rfc2217.py
|
|
index d962c1e8..2148512d 100644
|
|
--- a/serial/rfc2217.py
|
|
+++ b/serial/rfc2217.py
|
|
@@ -330,11 +330,15 @@ def set(self, value):
|
|
the client needs to know if the change is performed he has to check the
|
|
state of this object.
|
|
"""
|
|
- self.value = value
|
|
- self.state = REQUESTED
|
|
- self.connection.rfc2217_send_subnegotiation(self.option, self.value)
|
|
- if self.connection.logger:
|
|
- self.connection.logger.debug("SB Requesting {} -> {!r}".format(self.name, self.value))
|
|
+ if value != self.value:
|
|
+ self.value = value
|
|
+ self.state = REQUESTED
|
|
+ self.connection.rfc2217_send_subnegotiation(self.option, self.value)
|
|
+ if self.connection.logger:
|
|
+ self.connection.logger.debug("SB Requesting {} -> {!r}".format(self.name, self.value))
|
|
+ else:
|
|
+ if self.connection.logger:
|
|
+ self.connection.logger.debug("SB Requesting {} -> {!r} (skipped)".format(self.name, self.value))
|
|
|
|
def is_ready(self):
|
|
"""\
|