diff --git a/main.py b/main.py index ddf866d..cea303b 100644 --- a/main.py +++ b/main.py @@ -3,8 +3,8 @@ from util import * from receive import receive_packet debug = True -GDO0_PIN=23, -GDO2_PIN=24 +GDO0_PIN=17 +GDO2_PIN=27 def menu(): print("\nMenu") @@ -13,6 +13,7 @@ def menu(): print("3: Dump registers") print("4: Poll for packets") print("5: Run Read+Write test") + print("6: Print GDO state") print("0: Quit") @@ -78,6 +79,8 @@ if __name__ == "__main__": elif cmd == 5: res = test_read_write_reg(spi, True) print("Test result : "+str(res)) + elif cmd == 6: + print_gdo_state(GDO0_PIN, GDO2_PIN) else: print("Invalid command") finally: diff --git a/util.py b/util.py index d454daa..7ccc283 100644 --- a/util.py +++ b/util.py @@ -13,7 +13,7 @@ SNOP = STROBES["SNOP"] VERSION = STATUS["VERSION"] MARCSTATE = STATUS["MARCSTATE"] -def init_gpio(GDO0_PIN=23, GDO2_PIN=24): +def init_gpio(GDO0_PIN=17, GDO2_PIN=27): # Use BCM numbering GPIO.setmode(GPIO.BCM) @@ -22,20 +22,13 @@ def init_gpio(GDO0_PIN=23, GDO2_PIN=24): # GPIO.setup(GDO2_PIN, GPIO.IN) GPIO.setup(GDO0_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(GDO2_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) + sleep(0.1) -# def clear_csn(): -# CSN_PIN = 8 # CE0 = GPIO8 (Pin 24) -# GPIO.setmode(GPIO.BCM) -# GPIO.setup(CSN_PIN, GPIO.OUT) -# sleep(0.1) -# GPIO.output(CSN_PIN, GPIO.HIGH) -# sleep(0.1) - -def print_gdo_state(GDO0_PIN=23, GDO2_PIN=24): - gdo0 = GPIO.input(23) # Reads 1 or 0 - gdo2 = GPIO.input(24) - print(f"GDO0 (GPIO23): {gdo0}, GDO2 (GPIO24): {gdo2}") +def print_gdo_state(GDO0_PIN=17, GDO2_PIN=27): + gdo0 = GPIO.input(GDO0_PIN) # Reads 1 or 0 + gdo2 = GPIO.input(GDO2_PIN) + print(f"GDO0 (GPIO{GDO0_PIN}): {gdo0}, GDO2 (GPIO{GDO2_PIN}): {gdo2}") sleep(0.1)