]> sigrok.org Git - libsigrokdecode.git/commitdiff
uart: support 'ignore' parity type, remove unsupported 'check_parity' option
authorGerhard Sittig <redacted>
Fri, 29 Nov 2019 20:15:48 +0000 (21:15 +0100)
committerUwe Hermann <redacted>
Fri, 29 Nov 2019 22:19:54 +0000 (23:19 +0100)
The previous UART decoder implementation announced a 'check_parity'
option which took no effect (support code was missing). Remove it. Add
another 'ignore' parity choice instead, which consumes the parity bit's
position yet always passes the check.

decoders/uart/pd.py

index 802c5937d93ccc223d6bfb74dfae822dfe7d6cb1..7a43ee4851408738dcbdd9b173491008013cfcb4 100644 (file)
@@ -58,6 +58,9 @@ TX = 1
 # 'none' is _not_ allowed as value for 'parity_type'.
 def parity_ok(parity_type, parity_bit, data, num_data_bits):
 
 # 'none' is _not_ allowed as value for 'parity_type'.
 def parity_ok(parity_type, parity_bit, data, num_data_bits):
 
+    if parity_type == 'ignore':
+        return True
+
     # Handle easy cases first (parity bit is always 1 or 0).
     if parity_type == 'zero':
         return parity_bit == 0
     # Handle easy cases first (parity bit is always 1 or 0).
     if parity_type == 'zero':
         return parity_bit == 0
@@ -100,9 +103,7 @@ class Decoder(srd.Decoder):
         {'id': 'num_data_bits', 'desc': 'Data bits', 'default': 8,
             'values': (5, 6, 7, 8, 9)},
         {'id': 'parity_type', 'desc': 'Parity type', 'default': 'none',
         {'id': 'num_data_bits', 'desc': 'Data bits', 'default': 8,
             'values': (5, 6, 7, 8, 9)},
         {'id': 'parity_type', 'desc': 'Parity type', 'default': 'none',
-            'values': ('none', 'odd', 'even', 'zero', 'one')},
-        {'id': 'parity_check', 'desc': 'Check parity?', 'default': 'yes',
-            'values': ('yes', 'no')},
+            'values': ('none', 'odd', 'even', 'zero', 'one', 'ignore')},
         {'id': 'num_stop_bits', 'desc': 'Stop bits', 'default': 1.0,
             'values': (0.0, 0.5, 1.0, 1.5)},
         {'id': 'bit_order', 'desc': 'Bit order', 'default': 'lsb-first',
         {'id': 'num_stop_bits', 'desc': 'Stop bits', 'default': 1.0,
             'values': (0.0, 0.5, 1.0, 1.5)},
         {'id': 'bit_order', 'desc': 'Bit order', 'default': 'lsb-first',