diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2017-06-15 22:02:52 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2017-06-15 22:24:03 +0200 |
commit | ba2eca6e2d52e6ebe342a50ebf7b0c00a55bdc55 (patch) | |
tree | 6cb38d91dd5e2837bfc1be7f7eebf90eaf79d5b7 /decoders/dmx512 | |
parent | 06ca8df7b2994a4dcd480d11b5c30fc8085b0e7d (diff) | |
download | libsigrokdecode-ba2eca6e2d52e6ebe342a50ebf7b0c00a55bdc55.tar.gz libsigrokdecode-ba2eca6e2d52e6ebe342a50ebf7b0c00a55bdc55.zip |
dmx512: Convert to PD API version 3.
Diffstat (limited to 'decoders/dmx512')
-rw-r--r-- | decoders/dmx512/pd.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/decoders/dmx512/pd.py b/decoders/dmx512/pd.py index e83d943..2f4471f 100644 --- a/decoders/dmx512/pd.py +++ b/decoders/dmx512/pd.py @@ -20,7 +20,7 @@ import sigrokdecode as srd class Decoder(srd.Decoder): - api_version = 2 + api_version = 3 id = 'dmx512' name = 'DMX512' longname = 'Digital MultipleX 512' @@ -54,7 +54,6 @@ class Decoder(srd.Decoder): def __init__(self): self.samplerate = None self.sample_usec = None - self.samplenum = -1 self.run_start = -1 self.run_bit = 0 self.state = 'FIND BREAK' @@ -71,15 +70,14 @@ class Decoder(srd.Decoder): def putr(self, data): self.put(self.run_start, self.samplenum, self.out_ann, data) - 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: + while True: # Seek for an interval with no state change with a length between # 88 and 1000000 us (BREAK). if self.state == 'FIND BREAK': - if self.run_bit == pins[0]: - continue + pins = self.wait({0: 'h' if self.run_bit == 0 else 'l'}) runlen = (self.samplenum - self.run_start) * self.sample_usec if runlen > 88 and runlen < 1000000: self.putr([1, ['Break']]) @@ -93,8 +91,7 @@ class Decoder(srd.Decoder): self.run_start = self.samplenum # Directly following the BREAK is the MARK AFTER BREAK. elif self.state == 'MARK MAB': - if self.run_bit == pins[0]: - continue + pins = self.wait({0: 'h' if self.run_bit == 0 else 'l'}) self.putr([2, ['MAB']]) self.state = 'READ BYTE' self.channel = 0 @@ -104,6 +101,7 @@ class Decoder(srd.Decoder): # Mark and read a single transmitted byte # (start bit, 8 data bits, 2 stop bits). elif self.state == 'READ BYTE': + pins = self.wait({'skip': 1}) self.next_sample = self.run_start + (self.bit + 1) * self.skip_per_bit self.aggreg += pins[0] if self.samplenum != self.next_sample: @@ -155,8 +153,7 @@ class Decoder(srd.Decoder): self.bit += 1 # Mark the INTERFRAME-TIME between bytes / INTERPACKET-TIME between packets. elif self.state == 'MARK IFT': - if self.run_bit == pins[0]: - continue + pins = self.wait({0: 'h' if self.run_bit == 0 else 'l'}) if self.channel > 512: self.putr([8, ['Interpacket']]) self.state = 'FIND BREAK' |