X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fjitter%2Fpd.py;h=04a2577403094fa6f6aba83376973494a9e06229;hp=6dbc27afdb29022dbc72a916e35165c1ad57d60b;hb=4539e9ca58966ce3c9cad4801b16c315e86ace01;hpb=a9f7935a3db8da5aa9b137cf758ad1c57f31cae9 diff --git a/decoders/jitter/pd.py b/decoders/jitter/pd.py index 6dbc27a..04a2577 100644 --- a/decoders/jitter/pd.py +++ b/decoders/jitter/pd.py @@ -14,8 +14,7 @@ ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## along with this program; if not, see . ## import sigrokdecode as srd @@ -31,7 +30,7 @@ class SamplerateError(Exception): pass class Decoder(srd.Decoder): - api_version = 2 + api_version = 3 id = 'jitter' name = 'Jitter' longname = 'Timing jitter calculation' @@ -63,11 +62,10 @@ class Decoder(srd.Decoder): ('ascii-float', 'Jitter values as newline-separated ASCII floats'), ) - def __init__(self, **kwargs): + 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 +172,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.