diff options
author | zsquareplusc <cliechti@gmx.net> | 2021-10-02 01:43:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-02 01:43:32 +0200 |
commit | baa7c78a138c5b4fa2803d3caa82ee7f30f6683e (patch) | |
tree | 37cf2264ccc055e2b6106cb3bffe7281bcb720a7 | |
parent | aa68609f40d16a61f0ba65f4485419c0b04efcc0 (diff) | |
parent | 5ce1773fdce16a0b184363695a7d7d9483c4da0c (diff) | |
download | pyserial-git-baa7c78a138c5b4fa2803d3caa82ee7f30f6683e.tar.gz |
Merge pull request #496 from ckielstra/master
fix(serialposix): Add support for setting a custom baudrate on the MIPS platform
-rw-r--r-- | serial/serialposix.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/serial/serialposix.py b/serial/serialposix.py index 7aceb76..0464075 100644 --- a/serial/serialposix.py +++ b/serial/serialposix.py @@ -32,6 +32,7 @@ from __future__ import absolute_import import errno import fcntl import os +import platform import select import struct import sys @@ -80,8 +81,14 @@ if plat[:5] == 'linux': # Linux (confirmed) # noqa CMSPAR = 0o10000000000 # Use "stick" (mark/space) parity # baudrate ioctls - TCGETS2 = 0x802C542A - TCSETS2 = 0x402C542B + if platform.machine().lower() == "mips": + TCGETS2 = 0x4030542A + TCSETS2 = 0x8030542B + BAUDRATE_OFFSET = 10 + else: + TCGETS2 = 0x802C542A + TCSETS2 = 0x402C542B + BAUDRATE_OFFSET = 9 BOTHER = 0o010000 # RS485 ioctls @@ -154,7 +161,7 @@ if plat[:5] == 'linux': # Linux (confirmed) # noqa # set custom speed buf[2] &= ~termios.CBAUD buf[2] |= BOTHER - buf[9] = buf[10] = baudrate + buf[BAUDRATE_OFFSET] = buf[BAUDRATE_OFFSET + 1] = baudrate # set serial_struct fcntl.ioctl(self.fd, TCSETS2, buf) |