summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2010-04-18 03:15:06 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2010-04-18 21:13:38 +0200
commit930bd9d961b9a13259ffb4997be9fa6ebcdb9da9 (patch)
treee6bb54b59753814d9aaa04ea3dad422c114863a1 /scripts
parenta5fdab452f682e50cc05d6f392f750473fd93e78 (diff)
downloadlibsigrokdecode-930bd9d961b9a13259ffb4997be9fa6ebcdb9da9.tar.gz
libsigrokdecode-930bd9d961b9a13259ffb4997be9fa6ebcdb9da9.zip
Python: Bugfixes (True/False != 1/0).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/i2c.py8
-rw-r--r--scripts/transitioncounter.py4
2 files changed, 6 insertions, 6 deletions
diff --git a/scripts/i2c.py b/scripts/i2c.py
index 46c3381..973751b 100644
--- a/scripts/i2c.py
+++ b/scripts/i2c.py
@@ -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])
- 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.
@@ -94,8 +94,8 @@ def sigrokdecode_i2c(inbuf):
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?
diff --git a/scripts/transitioncounter.py b/scripts/transitioncounter.py
index 7c9c6a3..c16ce46 100644
--- a/scripts/transitioncounter.py
+++ b/scripts/transitioncounter.py
@@ -41,7 +41,7 @@ def sigrokdecode_count_transitions(inbuf):
# 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.
@@ -50,7 +50,7 @@ def sigrokdecode_count_transitions(inbuf):
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