diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-02-09 17:19:45 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-02-09 17:19:45 +0300 |
commit | 7f6adf60bb0be6e7517174f2145e80f9852b182a (patch) | |
tree | 7c784f492d8acb0bdbec40da2e3021657d2264f4 /it2gpio | |
parent | 400bd4e79807aeb4effc427e3ac6e50241493fa4 (diff) |
Diffstat (limited to 'it2gpio')
-rwxr-xr-x | it2gpio | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -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() - |