X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fparallel%2Fpd.py;h=1e3120858a7a4f750cd1ee3810a803c4439b7435;hp=b4dbdb3dbc1fd53a8c5365c1c2a31f2e085ae08a;hb=HEAD;hpb=4f4e035397fa0770d47bf8b663e87651e0709511 diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py index b4dbdb3..1e31208 100644 --- a/decoders/parallel/pd.py +++ b/decoders/parallel/pd.py @@ -54,7 +54,7 @@ Packet: word is 7, and so on. ''' -NUM_CHANNELS = 8 +NUM_CHANNELS = 16 class Pin: CLOCK = 0 @@ -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 @@ -140,8 +147,7 @@ class Decoder(srd.Decoder): txts = [self.fmt_word.format(word)] self.putg(ss, es, Ann.WORD, txts) - self.putpy(ss, es, 'WORD', word) - # self.putpy(ss, es, 'WORD', (word, bus_width, word_size)) + self.putpy(ss, es, 'WORD', (word, bus_width, word_size)) if len(items) != word_size: txts = ['incomplete word size', 'word size', 'ws'] @@ -177,8 +183,8 @@ class Decoder(srd.Decoder): es = now txts = [self.fmt_item.format(data)] self.putg(ss, es, Ann.ITEM, txts) - self.putpy(ss, es, 'ITEM', data) - # self.putpy(ss, es, 'ITEM', (data, bus_width)) + 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: @@ -251,7 +257,10 @@ class Decoder(srd.Decoder): # This results in robust operation for low-oversampled input. in_reset = False while True: - pins = self.wait(conds) + try: + pins = self.wait(conds) + except EOFError as e: + break clock_edge = cond_idx_clock is not None and self.matched[cond_idx_clock] data_edge = cond_idx_data_0 is not None and [idx for idx in range(cond_idx_data_0, cond_idx_data_N) if self.matched[idx]] reset_edge = cond_idx_reset is not None and self.matched[cond_idx_reset] @@ -269,3 +278,8 @@ class Decoder(srd.Decoder): data_bits = data_bits[:num_item_bits] item = bitpack(data_bits) self.handle_bits(self.samplenum, item, num_item_bits) + + self.handle_bits(self.samplenum, None, num_item_bits) + # TODO Determine whether a WARN annotation needs to get emitted. + # The decoder has not seen the end of the last accumulated item. + # Instead it just ran out of input data.