summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst1
-rw-r--r--serial/serialposix.py3
-rw-r--r--serial/serialutil.py4
-rw-r--r--serial/serialwin32.py3
4 files changed, 9 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 85633f0..f40d717 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -652,6 +652,7 @@ Version 3.x.x 2016-xx-xx
Improvements:
- add client mode to exmaple tcp_serial_redirect.py
+- add PARITY_IGNORE ('X'): receive parity bit, but ignore its value
Bugfixes:
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 30af312..27f97f3 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -360,6 +360,9 @@ class Serial(SerialBase, PlatformSpecific):
elif self._parity == serial.PARITY_SPACE and plat[:5] == 'linux':
cflag |= (termios.PARENB | CMSPAR)
cflag &= ~(termios.PARODD)
+ elif self._parity == serial.PARITY_IGNORE:
+ cflag |= termios.PARENB # enable parity bit
+ iflag |= termios.IGNPAR # ignore its value / no error report
else:
raise ValueError('Invalid parity: {!r}'.format(self._parity))
# setup flow control
diff --git a/serial/serialutil.py b/serial/serialutil.py
index 474b4c2..c2bd774 100644
--- a/serial/serialutil.py
+++ b/serial/serialutil.py
@@ -79,7 +79,7 @@ CR = to_bytes([13])
LF = to_bytes([10])
-PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE = 'N', 'E', 'O', 'M', 'S'
+PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE, PARITY_IGNORE = 'N', 'E', 'O', 'M', 'S', 'X'
STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO = (1, 1.5, 2)
FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS = (5, 6, 7, 8)
@@ -116,7 +116,7 @@ class SerialBase(io.RawIOBase):
576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000,
3000000, 3500000, 4000000)
BYTESIZES = (FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS)
- PARITIES = (PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE)
+ PARITIES = (PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE, PARITY_IGNORE)
STOPBITS = (STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO)
def __init__(self,
diff --git a/serial/serialwin32.py b/serial/serialwin32.py
index 484c4a1..756d921 100644
--- a/serial/serialwin32.py
+++ b/serial/serialwin32.py
@@ -157,6 +157,9 @@ class Serial(SerialBase):
elif self._parity == serial.PARITY_SPACE:
comDCB.Parity = win32.SPACEPARITY
comDCB.fParity = 1 # Enable Parity Check
+ elif self._parity == serial.PARITY_IGNORE:
+ comDCB.Parity = win32.NOPARITY # ignore the value
+ comDCB.fParity = 1 # Enable Parity bit
else:
raise ValueError("Unsupported parity mode: {!r}".format(self._parity))