diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2020-07-22 20:41:33 +0200 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2020-07-22 20:41:33 +0200 |
commit | 32d1c3503d2c5402140c31fab37438861e0d7cb3 (patch) | |
tree | b5ecda51e5189e794f5a60635e33400bcc2921b0 /decoders/ir_sirc/pd.py | |
parent | 03fe8db14b32a625c4041e3a8890bbf809679544 (diff) | |
download | libsigrokdecode-32d1c3503d2c5402140c31fab37438861e0d7cb3.tar.gz libsigrokdecode-32d1c3503d2c5402140c31fab37438861e0d7cb3.zip |
ir_sirc: minor Python and other nits
The .wait() wrapper always receives Python lists. There is only a single
IR pin (and its value isn't even used anywhere because appropriate edge
conditions get constructed). There is a delicate ss/es detail in the
.decode() routine concerning the IR frame's annotation's start. Don't
"continue" in the loop body's last statement, just "pass" and continue.
Diffstat (limited to 'decoders/ir_sirc/pd.py')
-rw-r--r-- | decoders/ir_sirc/pd.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/decoders/ir_sirc/pd.py b/decoders/ir_sirc/pd.py index 0afacb0..d4fed65 100644 --- a/decoders/ir_sirc/pd.py +++ b/decoders/ir_sirc/pd.py @@ -96,8 +96,7 @@ class Decoder(srd.Decoder): tolerance = expected * 0.30 return (expected - tolerance) < microseconds < (expected + tolerance) - def wait_wrap(self, conds, timeout=None): - conds = list(conds) + def wait_wrap(self, conds, timeout): if timeout is not None: to = int(timeout * self.snum_per_us) conds.append({'skip': to}) @@ -109,10 +108,10 @@ class Decoder(srd.Decoder): def read_pulse(self, high, time): e = 'f' if high else 'r' max_time = int(time * 1.30) - pins, ss, es, (edge, timeout) = self.wait_wrap([{0: e}], max_time) + (ir,), ss, es, (edge, timeout) = self.wait_wrap([{0: e}], max_time) if timeout or not self.tolerance(ss, es, time): raise SIRCError('Timeout') - return pins, ss, es, (edge, timeout) + return ir, ss, es, (edge, timeout) def read_bit(self): e = 'f' if self.active else 'r' @@ -198,18 +197,19 @@ class Decoder(srd.Decoder): unknown = (['Unknown Device: ', 'UNK: '], {}) while True: e = 'h' if self.active else 'l' - _, ss, es, _ = self.wait_wrap([{0: e}], None) + _, _, frame_ss, _ = self.wait_wrap([{0: e}], None) try: addr, cmd, ext, payload_ss, payload_es = self.read_signal() names, cmds = ADDRESSES.get((addr, ext), unknown) text = cmds.get(cmd, 'Unknown') - self.putg(es, payload_es, Ann.REMOTE, [n + text for n in names]) + self.putg(frame_ss, payload_es, Ann.REMOTE, [ + n + text for n in names + ]) except SIRCErrorSilent as e: - continue + pass except SIRCError as e: - self.putg(es, self.samplenum, Ann.WARN, [ + self.putg(frame_ss, self.samplenum, Ann.WARN, [ 'Error: {}'.format(e), 'Error', 'E', ]) - continue |