summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2017-06-06 21:13:27 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2017-06-06 21:22:02 +0200
commit3b5b9ad27f507a9669231940acdf411ba7139b1f (patch)
tree71523e1192ab0d218b53fe2cba6b2cbcde85462e /decoders
parentbcf6548ba8b604fa56a9cf4f7f985e9f67dd5bb6 (diff)
downloadlibsigrokdecode-3b5b9ad27f507a9669231940acdf411ba7139b1f.tar.gz
libsigrokdecode-3b5b9ad27f507a9669231940acdf411ba7139b1f.zip
gpib: Convert to PD API version 3
Have edges detected in common library code. Cope with optional initial low level (without an edge) at the start of sample data. Handle the optionally enforced processing at a specified sample number.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/gpib/pd.py42
1 files changed, 15 insertions, 27 deletions
diff --git a/decoders/gpib/pd.py b/decoders/gpib/pd.py
index 369a094..01801bc 100644
--- a/decoders/gpib/pd.py
+++ b/decoders/gpib/pd.py
@@ -20,7 +20,7 @@
import sigrokdecode as srd
class Decoder(srd.Decoder):
- api_version = 2
+ api_version = 3
id = 'gpib'
name = 'GPIB'
longname = 'General Purpose Interface Bus'
@@ -61,14 +61,12 @@ class Decoder(srd.Decoder):
)
def __init__(self):
- self.olddav = None
self.items = []
self.itemcount = 0
self.saved_item = None
self.saved_ATN = False
self.saved_EOI = False
self.samplenum = 0
- self.oldpins = None
self.ss_item = self.es_item = None
self.first = True
@@ -160,29 +158,19 @@ class Decoder(srd.Decoder):
self.itemcount, self.items = 0, []
- def find_falling_dav_edge(self, dav, datapins):
- # Ignore sample if the DAV pin hasn't changed.
- if dav == self.olddav:
- return
- self.olddav = dav
- # Sample on falling DAV edge.
- if dav == 1:
- return
-
- # Found the correct DAV edge, now get the bits.
- self.handle_bits(datapins)
+ def decode(self):
- def decode(self, ss, es, data):
+ # Inspect samples at falling edge of DAV. But make sure to also
+ # start inspection when the capture happens to start with low
+ # DAV level. Optionally enforce processing when a user specified
+ # sample number was reached.
+ waitcond = [{9: 'l'}]
lsn = self.options['sample_total']
-
- for (self.samplenum, pins) in data:
- if lsn > 0:
- if (lsn - self.samplenum) == 1: # Show the last data word.
- self.handle_bits(pins)
-
- # Ignore identical samples early on (for performance reasons).
- if self.oldpins == pins:
- continue
- self.oldpins = pins
-
- self.find_falling_dav_edge(pins[9], pins)
+ if lsn:
+ waitcond.append({'skip': lsn})
+ while True:
+ if lsn:
+ waitcond[1]['skip'] = lsn - self.samplenum - 1
+ pins = self.wait(waitcond)
+ self.handle_bits(pins)
+ waitcond[0][9] = 'f'