summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsquareplusc <cliechti@gmx.net>2020-09-14 05:26:23 +0200
committerGitHub <noreply@github.com>2020-09-14 05:26:23 +0200
commite43a771f42eeffbedd303c9f5abb6b97cdd24d83 (patch)
tree66d0c9f8579ae6d480996b14780303cc9bac7bae
parentf47bb605afe868c471f7765cb3c428e1c0bfa2cc (diff)
parent0085e1e1d55f6a5376e06ed5ff679b7c0f66b202 (diff)
downloadpyserial-git-e43a771f42eeffbedd303c9f5abb6b97cdd24d83.tar.gz
Merge pull request #519 from tim-nordell-nimbelink/master
posix: Fix custom baud rate to not temporarily set 38400 baud rates on linux
-rw-r--r--serial/serialposix.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 0e97d58..2f125c3 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -405,8 +405,15 @@ class Serial(SerialBase, PlatformSpecific):
ispeed = ospeed = self.BAUDRATE_CONSTANTS[self._baudrate]
except KeyError:
#~ raise ValueError('Invalid baud rate: %r' % self._baudrate)
- # may need custom baud rate, it isn't in our list.
- ispeed = ospeed = getattr(termios, 'B38400')
+
+ # See if BOTHER is defined for this platform; if it is, use
+ # this for a speed not defined in the baudrate constants list.
+ try:
+ ispeed = ospeed = BOTHER
+ except NameError:
+ # may need custom baud rate, it isn't in our list.
+ ispeed = ospeed = getattr(termios, 'B38400')
+
try:
custom_baud = int(self._baudrate) # store for later
except ValueError: