Question


#1

Can someone who program the gps gopigo can add a few lines , To turn on a led if the program stops ?


#2

something along the lines of this ?

def handleTheUnhandled(type, value, traceback):
logger.log(“msg”,”The Unhandled was handled”) ## stream that an unexpected exception occured
GPIO.output(7,GPIO.low) ## turn on the LED
exit() ## exit the script

not sure of it working right , that is why i am asking .


#3

You can use the atexit library to call a function when the program ends. We use it in the basic_test_all example to stop the motors on exit: https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/basic_test_all.py#L25-L26. You can read a bit about it here: https://docs.python.org/2/library/atexit.html and should be able to run your function when the program stops to turn on the LED.

-Karan