From 143bc38e47bdc33652e8417b43d18f2f3e20c153 Mon Sep 17 00:00:00 2001 From: Henry Bruce Date: Tue, 1 Mar 2016 13:39:42 -0800 Subject: [PATCH] examples: hello_isr.py now catches exception if invalid pin is specified Signed-off-by: Henry Bruce --- examples/python/hello_isr.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/python/hello_isr.py b/examples/python/hello_isr.py index b5aaff4..76912ad 100644 --- a/examples/python/hello_isr.py +++ b/examples/python/hello_isr.py @@ -43,9 +43,12 @@ if (len(sys.argv) == 2): pin = int(sys.argv[1], 10) except ValueError: printf("Invalid pin " + sys.argv[1]) -print("Starting ISR for pin " + repr(pin)) -x = mraa.Gpio(pin) -x.dir(mraa.DIR_IN) -x.isr(mraa.EDGE_BOTH, test, x) -var = raw_input("Press ENTER to stop") -x.isrExit() +try: + x = mraa.Gpio(pin) + print("Starting ISR for pin " + repr(pin)) + x.dir(mraa.DIR_IN) + x.isr(mraa.EDGE_BOTH, test, x) + var = raw_input("Press ENTER to stop") + x.isrExit() +except ValueError as e: + print(e)