-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a method to gracefully end communication? #6
Comments
Hi, I'm not aware of any method closing the communication other than calling On 06/23/2016 11:09 PM, thisismynamenow wrote:
|
The _cleanup() method does the trick! I was just having trouble finding it in core.py, nothing came up for ctrl+f end/stop/quit/exit or any other synonyms. In order to get it to work I had to add an 'import thorlabs_apt.core as core', as the function didn't import from a standard 'from thorlabs_atp import *', but once that was included everything runs like a charm. Thanks a bunch! |
you're welcome. I would like to understand this a little better. Could On 06/24/2016 10:53 PM, thisismynamenow wrote:
|
The program I wrote is for user control for those not familiar with the more complex python commands, since my setup has 2 motors, I set it up so that users can move it between three configurations. The program as a whole just ran in a while loop, with user input via input(). But when exiting the program and reentering it, it will always crash without a power cycle on the controllers, as the communication channel remains open after exiting the program. The cleanup() method ends communication so that it can be reestablished next time the program is launched. |
Hi guys, Thanks heaps! NOTE: using python 2.7 |
Hi guys, I was planning on calling it via a SIGINT capture so when i ctrl+C to quit, it first runs this, but just can't seem to get it to call. Any chance you could offer a quick example that opens, runs, and gracefully exits using the APTCleanup method? Thanks |
Here's how I am running it. Note that I put ALL of my code (requesting input from the user, everything after "import_thorlabs_apt") inside the try block. This is so that if ANY of my code causes an exception, or the user quits with the keyboard, or anything else happens after I've imported thorlabs_apt, I still get to call _cleanup() before the program exits. Otherwise it'll refuse to run next time.
ps, I can't figure out getting a multi-line code block, or how to get the code style to respect indents. Everything inside the "try" needs to be indented, as well as everything inside the "finally:" Take a look at some python exception handling examples if you're new to exceptions :-) |
Thanks LeftyAce. That should all work just fine now. |
I've been looking through the core.py file for a method that will end comms, but I can't find anything... The official Thor manual lists a StopCtrl method, but it doesn't seem like that method is included in the package.
I've written a small program that allows for user communication with a while loop controlling the whole process, but if the program crashes or is willingly exited it can't relaunch without resetting the motors. I'm guessing its cause the communication channel never closes. It won't even load the packages.
Other than that, it works great on BSC 201 and KDC 101 model stepper motor controllers.
The text was updated successfully, but these errors were encountered: