]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/uart/pd.py
uart: rephrase check for required input signals, reword error message
[libsigrokdecode.git] / decoders / uart / pd.py
index d38258b9c7b5055995e65f2c649ced11e1fcc444..effa3c5dfc505e8840e7597c82cab0f4fe815daf 100644 (file)
@@ -43,6 +43,7 @@ This is the list of <ptype>s and their respective <pdata> values:
  - 'FRAME': The data is always a tuple containing two items: The (integer)
    value of the UART data, and a boolean which reflects the validity of the
    UART frame.
+ - 'IDLE': The data is always 0.
 
 The <rxtx> field is 0 for RX packets, 1 for TX packets.
 '''
@@ -57,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):
 
+    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
@@ -99,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',
-            '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',
@@ -140,13 +142,13 @@ class Decoder(srd.Decoder):
         ('tx-packet', 'TX packet'),
     )
     annotation_rows = (
-        ('rx-data', 'RX', (0, 2, 4, 6, 8)),
         ('rx-data-bits', 'RX bits', (12,)),
+        ('rx-data', 'RX', (0, 2, 4, 6, 8)),
         ('rx-warnings', 'RX warnings', (10,)),
         ('rx-break', 'RX break', (14,)),
         ('rx-packets', 'RX packets', (16,)),
-        ('tx-data', 'TX', (1, 3, 5, 7, 9)),
         ('tx-data-bits', 'TX bits', (13,)),
+        ('tx-data', 'TX', (1, 3, 5, 7, 9)),
         ('tx-warnings', 'TX warnings', (11,)),
         ('tx-break', 'TX break', (15,)),
         ('tx-packets', 'TX packets', (17,)),
@@ -502,8 +504,8 @@ class Decoder(srd.Decoder):
             raise SamplerateError('Cannot decode without samplerate.')
 
         has_pin = [self.has_channel(ch) for ch in (RX, TX)]
-        if has_pin == [False, False]:
-            raise ChannelError('Either TX or RX (or both) pins required.')
+        if not True in has_pin:
+            raise ChannelError('Need at least one of TX or RX pins.')
 
         opt = self.options
         inv = [opt['invert_rx'] == 'yes', opt['invert_tx'] == 'yes']