[Tutor] terminating driver instance prior to completion

David Haan dghmerch at comcast.net
Tue Aug 24 12:48:52 EDT 2021


I have a driver written in Python by others that is used to move a 
stepper motor.  The parameters of the driver calls for, among other 
things, the number of steps the motor needs to be moved.  It can be from 
1 to infinity.

I also have a hardware interrupt available that will indicate when the 
device the motor is moving has reached its home position.  I need to 
stop the driver at that point regardless of the number of steps it has 
processed.

I create an instance of the driver and pass it appropriate values for 
its variables.  Once the driver instance starts, it will not return to 
the main program until it has processed all the steps I passed in one of 
the instance variables.

When the hardware interrupt fires, I want to terminate the driver code 
execution so it will return control immediately to the main program flow.

My question is if there is a method to terminate the Python driver code 
instance.  I really don't want to copy the driver code and modify it 
specifically for my own program if I don't have to.

Any suggestions would be appreciated.


More information about the Tutor mailing list