Skip to content

Commit e303fd4

Browse files
committed
parallel: flush accumulated data when input data is exhausted
The "parallel" decoder buffers the currently seen data pattern, and defers annotation emission until the end position is known. Which is why the last data pattern would not show up in the decoder's output. See bug #292 and its duplicates for examples and concerns. Catch the EOFError exception, and flush previously accumulated data. It is yet to get determined whether a warning annotation is due. Most probably not for "parallel" which merely visualizes data line states. But other decoders which have the concept of frames shall NOT follow this "parallel" decoder's naive approach, and claim that a frame had completed although its end condition was never seen. Add a developer TODO comment to raise awareness.
1 parent 27a86ce commit e303fd4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

decoders/parallel/pd.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ def decode(self):
257257
# This results in robust operation for low-oversampled input.
258258
in_reset = False
259259
while True:
260-
pins = self.wait(conds)
260+
try:
261+
pins = self.wait(conds)
262+
except EOFError as e:
263+
break
261264
clock_edge = cond_idx_clock is not None and self.matched[cond_idx_clock]
262265
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]]
263266
reset_edge = cond_idx_reset is not None and self.matched[cond_idx_reset]
@@ -275,3 +278,8 @@ def decode(self):
275278
data_bits = data_bits[:num_item_bits]
276279
item = bitpack(data_bits)
277280
self.handle_bits(self.samplenum, item, num_item_bits)
281+
282+
self.handle_bits(self.samplenum, None, num_item_bits)
283+
# TODO Determine whether a WARN annotation needs to get emitted.
284+
# The decoder has not seen the end of the last accumulated item.
285+
# Instead it just ran out of input data.

0 commit comments

Comments
 (0)