From: Gerhard Sittig Date: Thu, 18 Mar 2021 18:14:54 +0000 (+0100) Subject: ieee488: support optional parity for ATN commands (for HP gear) X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f697102ece64f8e99bfd26bbc2dedadaa037a0e5;p=libsigrokdecode.git ieee488: support optional parity for ATN commands (for HP gear) HP gear is said to sometimes send commands (ATN asserted) with a parity. Introduce an option to check and strip the MSB before interpretation. Reported-By: Anders Gustafsson --- diff --git a/decoders/ieee488/pd.py b/decoders/ieee488/pd.py index 4531cb3..0451c14 100644 --- a/decoders/ieee488/pd.py +++ b/decoders/ieee488/pd.py @@ -288,6 +288,8 @@ class Decoder(srd.Decoder): 'default': 'no', 'values': ('no', 'yes')}, {'id': 'delim', 'desc': 'Payload data delimiter', 'default': 'eol', 'values': ('none', 'eol')}, + {'id': 'atn_parity', 'desc': 'ATN commands use parity', + 'default': 'no', 'values': ('no', 'yes')}, ) annotations = ( ('bit', 'IEC bit'), @@ -486,6 +488,13 @@ class Decoder(srd.Decoder): upd_iec = False, py_type = None py_peers = False + if self.options['atn_parity'] == 'yes': + par = 1 if b & 0x80 else 0 + b &= ~0x80 + ones = bin(b).count('1') + par + if ones % 2: + warn_texts = ['Command parity error', 'parity', 'PAR'] + self.emit_warn_ann(self.ss_raw, self.es_raw, warn_texts) is_cmd, is_unl, is_unt = _is_command(b) laddr = _is_listen_addr(b) taddr = _is_talk_addr(b)