summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-02-09 17:19:45 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-02-09 17:19:45 +0300
commit7f6adf60bb0be6e7517174f2145e80f9852b182a (patch)
tree7c784f492d8acb0bdbec40da2e3021657d2264f4
parent400bd4e79807aeb4effc427e3ac6e50241493fa4 (diff)
-rwxr-xr-xit2gpio20
1 files changed, 11 insertions, 9 deletions
diff --git a/it2gpio b/it2gpio
index f6b5e7b..1723f48 100755
--- a/it2gpio
+++ b/it2gpio
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
-import sys, re
+import sys
-regs = []
def main():
+ regs = []
+
for line in sys.stdin:
line = line.strip()
parts = line.split(' ')
@@ -12,16 +13,17 @@ def main():
regs.append(int(val, 16))
if not regs:
- raise Error("regs is empty")
+ raise Exception("regs is empty")
for k, reg in enumerate(regs):
for i in range(32):
- num = (32 * k) + i
- index = int(num / 32)
- bit = num % 32
- status = (reg >> bit) & 1
- print("GPIO%d = %d" % (num, status))
+ gpio_num = (32 * k) + i
+ if gpio_num > 75:
+ break
+ bit = gpio_num % 32
+ gpio_val = (reg >> bit) & 1
+ print("GPIO%d = %d" % (gpio_num, gpio_val))
+
if __name__ == '__main__':
main()
-