summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorSoeren Apel <soeren@apelpie.net>2021-12-17 22:50:00 +0100
committerSoeren Apel <soeren@apelpie.net>2021-12-17 22:50:20 +0100
commit82f3f4d4163ffba003a49a5c7f1f6966f132bbb8 (patch)
tree1ead1b1444d5cf4941796c592f8e56b9b752c44e /decoders
parent02aa01ad5f05f2730309200abda0ac75d3721e1d (diff)
downloadlibsigrokdecode-82f3f4d4163ffba003a49a5c7f1f6966f132bbb8.tar.gz
libsigrokdecode-82f3f4d4163ffba003a49a5c7f1f6966f132bbb8.zip
parallel: Add binary output
Diffstat (limited to 'decoders')
-rw-r--r--decoders/parallel/pd.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py
index 5acfb67..96741e7 100644
--- a/decoders/parallel/pd.py
+++ b/decoders/parallel/pd.py
@@ -108,6 +108,9 @@ class Decoder(srd.Decoder):
('words', 'Words', (Ann.WORD,)),
('warnings', 'Warnings', (Ann.WARN,)),
)
+ binary = (
+ ('binary', 'Binary'),
+ )
def __init__(self):
self.reset()
@@ -118,6 +121,7 @@ class Decoder(srd.Decoder):
def start(self):
self.out_python = self.register(srd.OUTPUT_PYTHON)
+ self.out_binary = self.register(srd.OUTPUT_BINARY)
self.out_ann = self.register(srd.OUTPUT_ANN)
def putg(self, ss, es, ann, txts):
@@ -126,6 +130,9 @@ class Decoder(srd.Decoder):
def putpy(self, ss, es, ann, data):
self.put(ss, es, self.out_python, [ann, data])
+ def putbin(self, ss, es, ann_class, data):
+ self.put(ss, es, self.out_binary, [ann_class, data])
+
def flush_word(self, bus_width):
if not self.word_items:
return
@@ -177,6 +184,7 @@ class Decoder(srd.Decoder):
txts = [self.fmt_item.format(data)]
self.putg(ss, es, Ann.ITEM, txts)
self.putpy(ss, es, 'ITEM', (data, bus_width))
+ self.putbin(ss, es, 0, data.to_bytes(1, byteorder='big'))
# Optionally queue the currently seen item.
if item is not None: