diff options
-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() - |