AlexShkarin / pyLabLib

Python package for device control and experiment automation
http://pylablib.readthedocs.io
GNU General Public License v3.0
125 stars 28 forks source link

Thorlabs.list_kinesis_devices() returns an empty list - macOS #39

Open brunopalsina opened 1 year ago

brunopalsina commented 1 year ago

I'm trying to connect to a KDC101 thorlabs controller from macOS. I have been able to work my way around some ft232 issues I had prior to this, but I am currently stuck at an empty list when performing Thorlabs.list_kinesis_devices() : `from pylablib.devices import Thorlabs

listdevices = Thorlabs.list_kinesis_devices() print(listdevices)` for which the output, without errors, is: [ ]

I am fairly new at this, so i have a couple of theories that may be wrong. First one; my macOS version is 13.x.x (ventura) for which I couldnt find the VCP drivers (only for macos 11/12, which i installed in case the 'version' field was outdated). This might be the problem? Second one; Obviously, I have not installed any Thorlabs supplied DLLs. However, seeing these are not available for linux users and they seem to not be having issues, I don't think this is creating the problem. Third one; Does pyLabLib not work on macOS? I cannot find any posts or information on its compatibility with it. Should i start thinking of getting a windows virtual machine or linux? I would rather avoid that if possible...

Any help or tips would be very much appreciated.

AlexShkarin commented 1 year ago

Hello!

I haven't tried it on MacOS, but I know that Thorlabs.list_kinesis_devices() does not work on Linux, because it does not support pyft232. However, there's a workaround with using serial port instead. Here's the description I've written elsewhere:

To make it work, first you need to figure out which dev path (e.g., /dev/ttyUSB0) corresponds to the device by, for example, plugging and unplugging it and checking which path appears and disappears. Then you need to supply this path to the class to open it. The current pylablib implementation has problems with accepting pyserial paths right aways, so the code will be a bit verbose:

conn = {"port":"/dev/ttyUSB0","baudrate":115200,"rtscts":True}  # intead of ttyUSB0 use the correct path
dev = Thorlabs.KinesisMotor(("serial",conn))  # can also be, e.g., KinesisPiezoMotor, depending on the device kind

I'm not sure if it would work on MacOS, but, as far as I know, serial device handling is pretty similar there. Let me know if that solves the issue.

Alexey.