diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2012-03-31 17:04:50 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2012-03-31 17:04:50 +0200 |
commit | 4180cba9a51acd32f69f0f8628bb746ea3e12be6 (patch) | |
tree | 28c2e970361961ee0386ab61224e983a0dd5b6c6 /decoders/usb | |
parent | 394b74dca66d540cae154dfeb3bea4253db4304d (diff) | |
download | libsigrokdecode-4180cba9a51acd32f69f0f8628bb746ea3e12be6.tar.gz libsigrokdecode-4180cba9a51acd32f69f0f8628bb746ea3e12be6.zip |
srd: Decoders: Fix/simplify samplenum usage.
Diffstat (limited to 'decoders/usb')
-rw-r--r-- | decoders/usb/usb.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/decoders/usb/usb.py b/decoders/usb/usb.py index f024f49..07f7bc0 100644 --- a/decoders/usb/usb.py +++ b/decoders/usb/usb.py @@ -115,16 +115,14 @@ class Decoder(srd.Decoder): # Initialise decoder state. self.sym = 'J' - self.scount = 0 + self.samplenum = 0 self.packet = '' def report(self): pass def decode(self, ss, es, data): - for (samplenum, (dm, dp)) in data: - - self.scount += 1 + for (self.samplenum, (dm, dp)) in data: sym = syms[dp, dm] @@ -132,16 +130,16 @@ class Decoder(srd.Decoder): if sym == self.sym: continue - if self.scount == 1: + if self.samplenum == 1: # We ignore single sample width pulses. # I sometimes get these with the OLS. self.sym = sym - self.scount = 0 + self.samplenum = 0 continue # How many bits since the last transition? if self.packet != '' or self.sym != 'J': - bitcount = int((self.scount - 1) * 12000000 / self.samplerate) + bitcount = int((self.samplenum - 1) * 12000000 / self.samplerate) else: bitcount = 0 @@ -153,7 +151,7 @@ class Decoder(srd.Decoder): else: # Longer than EOP, assume reset. self.put(0, 0, self.out_ann, [0, ['RESET']]) - self.scount = 0 + self.samplenum = 0 self.sym = sym self.packet = '' continue @@ -167,6 +165,6 @@ class Decoder(srd.Decoder): elif bitcount > 6: self.put(0, 0, self.out_ann, [0, ['BIT STUFF ERROR']]) - self.scount = 0 + self.samplenum = 0 self.sym = sym |