I'm using a pi to control a stepper motor on a camera slider. I created an event to detect the carriage hitting a limit switch.
I create an event detect like GPIO.add_event_detect(7, GPIO.FALLING, callback=LimitSwitch, bouncetime=500). The event works correctly until I execute status = os.system("gphoto2 --set-config eosremoterelease=2 --wait-event=%.3fms --set-config eosremoterelease=4 >> NULL" %duration). Once I run the external CMD it appears to cancel the event.
As a workaround I tried to create and cancel the event detect in the function that spins the motor. Unfortunately it appears that if you create and cancel the event repeatedly, with not enough delay between calls, it causes an error and the python script exits.
def SpinMotor(direction, stepsCapture):
GPIO.add_event_detect(7, GPIO.FALLING, callback=LimitSwitch, bouncetime=500)
while stepsCapture > 0:
stepsCapture -= 1
Ideally I'd like to create the event one time at the beginning of the script. Any ideas what I'm doing wrong?
2 posts • Page 1 of 1
I was able to resolve the issue by using subprocess.call() instead of os.system