summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2016-08-26 15:14:40 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2016-12-07 22:45:46 +0100
commit54dad54a0215683b594cc891c9e41f79530b7f1d (patch)
tree83974dda04d24b8a1873c17dd9a7aa617e13df3e /decoders
parent5844bb0f1335feaed9875712468609533b554db4 (diff)
downloadlibsigrokdecode-54dad54a0215683b594cc891c9e41f79530b7f1d.tar.gz
libsigrokdecode-54dad54a0215683b594cc891c9e41f79530b7f1d.zip
jitter: Convert to PD API version 3.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/jitter/pd.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/decoders/jitter/pd.py b/decoders/jitter/pd.py
index c3579a8..4fadbcb 100644
--- a/decoders/jitter/pd.py
+++ b/decoders/jitter/pd.py
@@ -31,7 +31,7 @@ class SamplerateError(Exception):
pass
class Decoder(srd.Decoder):
- api_version = 2
+ api_version = 3
id = 'jitter'
name = 'Jitter'
longname = 'Timing jitter calculation'
@@ -66,8 +66,7 @@ class Decoder(srd.Decoder):
def __init__(self):
self.state = 'CLK'
self.samplerate = None
- self.oldpin = None
- self.oldclk = self.oldsig = None
+ self.oldclk, self.oldsig = 0, 0
self.clk_start = None
self.sig_start = None
self.clk_missed = 0
@@ -174,19 +173,12 @@ class Decoder(srd.Decoder):
# everything we can with this sample.
return True
- def decode(self, ss, es, data):
+ def decode(self):
if not self.samplerate:
raise SamplerateError('Cannot decode without samplerate.')
-
- for (self.samplenum, pins) in data:
- # We are only interested in transitions.
- if self.oldpin == pins:
- continue
-
- self.oldpin, (clk, sig) = pins, pins
-
- if self.oldclk is None and self.oldsig is None:
- self.oldclk, self.oldsig = clk, sig
+ while True:
+ # Wait for a transition on CLK and/or SIG.
+ clk, sig = self.wait([{0: 'e'}, {1: 'e'}])
# State machine:
# For each sample we can move 2 steps forward in the state machine.