X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fir_sirc%2Fpd.py;h=14ba63f0d10a75a0be3289a5111e05566bf8d832;hb=5c47b179b3e1e90b79478a9feca18990c481d014;hp=0afacb0fdc97c0c5fb4cb6691564ab1989ab5f20;hpb=03fe8db14b32a625c4041e3a8890bbf809679544;p=libsigrokdecode.git diff --git a/decoders/ir_sirc/pd.py b/decoders/ir_sirc/pd.py index 0afacb0..14ba63f 100644 --- a/decoders/ir_sirc/pd.py +++ b/decoders/ir_sirc/pd.py @@ -17,7 +17,7 @@ ## along with this program; if not, see . ## -from common.srdhelper import bitpack +from common.srdhelper import bitpack_lsb from .lists import ADDRESSES import sigrokdecode as srd @@ -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' @@ -169,8 +168,8 @@ class Decoder(srd.Decoder): raise SIRCError('incorrect bits count {}'.format(len(bits))) break - command_num = bitpack([b[0] for b in command]) - address_num = bitpack([b[0] for b in address]) + command_num = bitpack_lsb(command, 0) + address_num = bitpack_lsb(address, 0) command_str = '0x{:02X}'.format(command_num) address_str = '0x{:02X}'.format(address_num) self.putg(command[0][1], command[-1][2], Ann.CMD, [ @@ -183,7 +182,7 @@ class Decoder(srd.Decoder): ]) extended_num = None if extended: - extended_num = bitpack([b[0] for b in extended]) + extended_num = bitpack_lsb(extended, 0) extended_str = '0x{:02X}'.format(extended_num) self.putg(extended[0][1], extended[-1][2], Ann.EXT, [ 'Extended: {}'.format(extended_str), @@ -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