summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2021-03-18 19:14:54 +0100
committerGerhard Sittig <gerhard.sittig@gmx.net>2021-06-21 09:40:50 +0200
commitf697102ece64f8e99bfd26bbc2dedadaa037a0e5 (patch)
tree79dd046c6d36ab44bb36cd7e4ff9bbaf3fa41075 /decoders
parent0963cf62de26f00f2cbfcd2b4a841bf0a9c05384 (diff)
downloadlibsigrokdecode-f697102ece64f8e99bfd26bbc2dedadaa037a0e5.tar.gz
libsigrokdecode-f697102ece64f8e99bfd26bbc2dedadaa037a0e5.zip
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 <Anders.Gustafsson@pedago.fi>
Diffstat (limited to 'decoders')
-rw-r--r--decoders/ieee488/pd.py9
1 files changed, 9 insertions, 0 deletions
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)