]> sigrok.org Git - libsigrokdecode.git/commitdiff
Python: Bugfixes (True/False != 1/0).
authorUwe Hermann <redacted>
Sun, 18 Apr 2010 01:15:06 +0000 (03:15 +0200)
committerUwe Hermann <redacted>
Sun, 18 Apr 2010 19:13:38 +0000 (21:13 +0200)
scripts/i2c.py
scripts/transitioncounter.py

index 46c338175eb78c8fdd18d85cddbb3dac73df3686..973751b466be40181be530cee0b4634f8505b23e 100644 (file)
@@ -84,8 +84,8 @@ def sigrokdecode_i2c(inbuf):
 
        # Get SCL/SDA bit values (0/1 for low/high) of the first sample.
        s = ord(inbuf[0])
 
        # Get SCL/SDA bit values (0/1 for low/high) of the first sample.
        s = ord(inbuf[0])
-       oldscl = (s & (1 << scl_bit)) != 0
-       oldsda = (s & (1 << sda_bit)) != 0
+       oldscl = (s & (1 << scl_bit)) >> scl_bit
+       oldsda = (s & (1 << sda_bit)) >> sda_bit
 
        # Loop over all samples.
        # TODO: Handle LAs with more/less than 8 channels.
 
        # Loop over all samples.
        # TODO: Handle LAs with more/less than 8 channels.
@@ -94,8 +94,8 @@ def sigrokdecode_i2c(inbuf):
                s = ord(s) # FIXME
 
                # Get SCL/SDA bit values (0/1 for low/high).
                s = ord(s) # FIXME
 
                # Get SCL/SDA bit values (0/1 for low/high).
-               scl = (s & (1 << scl_bit)) != 0
-               sda = (s & (1 << sda_bit)) != 0
+               scl = (s & (1 << scl_bit)) >> scl_bit
+               sda = (s & (1 << sda_bit)) >> sda_bit
 
                # TODO: Wait until the bus is idle (SDA = SCL = 1) first?
 
 
                # TODO: Wait until the bus is idle (SDA = SCL = 1) first?
 
index 7c9c6a3e3d05bef37be6a57f399226968c034e4d..c16ce46aacc67a90cb5c00bec11a66ba6416dbf5 100644 (file)
@@ -41,7 +41,7 @@ def sigrokdecode_count_transitions(inbuf):
        # Presets...
        oldbyte = inbuf[0]
        for i in range(channels):
        # Presets...
        oldbyte = inbuf[0]
        for i in range(channels):
-               oldbit[i] = (oldbyte & (1 << i)) != 0
+               oldbit[i] = (oldbyte & (1 << i)) >> i
 
        # Loop over all samples.
        # TODO: Handle LAs with more/less than 8 channels.
 
        # Loop over all samples.
        # TODO: Handle LAs with more/less than 8 channels.
@@ -50,7 +50,7 @@ def sigrokdecode_count_transitions(inbuf):
                if oldbyte == s:
                        continue
                for i in range(channels):
                if oldbyte == s:
                        continue
                for i in range(channels):
-                       curbit = (s & (1 << i) != 0)
+                       curbit = (s & (1 << i)) >> i
                        # Optimization: Skip identical bits (no transitions).
                        if oldbit[i] == curbit:
                                continue
                        # Optimization: Skip identical bits (no transitions).
                        if oldbit[i] == curbit:
                                continue