ir_nec: Addresses and commands are transmitted LSB-first.
authorUwe Hermann <uwe@hermann-uwe.de>
Fri, 7 Mar 2014 19:17:00 +0000 (20:17 +0100)
committerUwe Hermann <uwe@hermann-uwe.de>
Mon, 10 Mar 2014 14:39:33 +0000 (15:39 +0100)
decoders/ir_nec/pd.py

index 8a41a875ed714115f5056df9b32b09ae128bde33..1368e417d7daff0545c25645713e9f62602fe873 100644 (file)
@@ -104,14 +104,14 @@ class Decoder(srd.Decoder):
         self.stop = int(self.samplerate * 0.000652) - 1 # 0.652ms
 
     def handle_bit(self, tick):
-        ret = 0xff
+        ret = None
         if tick in range(self.dazero - self.margin, self.dazero + self.margin):
             ret = 0
         elif tick in range(self.daone - self.margin, self.daone + self.margin):
             ret = 1
-        if ret < 2:
+        if ret in (0, 1):
             self.putb([0, ['%d' % ret]])
-            self.data = self.data * 2 + ret
+            self.data |= (ret << self.count) # LSB-first
             self.count = self.count + 1
         self.ss_bit = self.samplenum
 
@@ -122,7 +122,7 @@ class Decoder(srd.Decoder):
             self.ss_start = self.samplenum
             return True
         if ret == 0:
-            self.putd(self.data & 0xff)
+            self.putd(self.data >> 8)
         else:
             self.putx([11, ['%s error: 0x%04X' % (name, self.data)]])
         self.data = self.count = 0