python-microscope / microscope

Python library for control of microscope devices, supporting hardware triggers and distribution of devices over the network for performance and flexibility.
https://www.python-microscope.org
GNU General Public License v3.0
73 stars 42 forks source link

Thorlabs filter wheel fails to update #236

Closed thomasmfish closed 2 years ago

thomasmfish commented 2 years ago

Thorlabs filter wheel audibly moves but it's not updated within the software (both GUI and metadata).

This was fixed at B24 with Ian's help a while back (see PR #215). That said, it may be something that can be done a little more elegantly?

carandraug commented 2 years ago

Regarding the fix in #215, if the root issue is that getting the position fails because the device is still moving, then simply trying a second time could still fail if the move is long.

Is there a command in the filterwheel that returns when it has finished moving?

thomasmfish commented 2 years ago

I haven't yet had a chance to delve into this more but I'm hoping so. Does microscope have a way to expose the output from devices to the command line?

thomasmfish commented 2 years ago

Okay, I've fixed the issue in a much more comprehensive way now. The issue was empty lines being returned, presumably due to a change in polling frequency or something, which ended the while loop before it had even echoed the command. I've improved the methods involved to:

  1. Never return fully empty strings as readings. There should be at least some non-whitespace characters there before it is considered a response.
  2. Catch ">" rather than stripping it and waiting for "". I'll link the PR now so you can take a closer look.
  3. Raise a microscope.DeviceError if it's unable to cast the response in _do_get_position to an int.
thomasmfish commented 2 years ago

Just linked #215 with the latest changes