From 7f6adf60bb0be6e7517174f2145e80f9852b182a Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 9 Feb 2021 17:19:45 +0300 Subject: fixes --- it2gpio | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'it2gpio') 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() - -- cgit v1.2.3