Closed drbel8 closed 1 year ago
Hi!
Unfortunately, I have limited exprience with device communications in Linux, so I can't tell what exactly the issue is.
First thing would be to figure out if the device is recognized by the OS at all, and how it is addressed. As far as I undestand, Thorlabs APT devices (such as KIM101, KDC101, or FW102) might show up directly as a serial port, e.g., dev/ttyUSB0
. Could you check that? For example, if there's an analog of Windows device manager, you can unplug the device and plug it back in, and check what changes.
Hi @AlexShkarin, yes the KIM101 appears correctly as /dev/ttyUSB0 (it shows up when I plug and disappears when I unplug).
Ok, in this case could you try giving this address to the device class instead of its ID? That is, execute x = Thorlabs.KinesisPiezoMotor("/dev/ttyUSB0")
In principle, the code should work with the standard serial interface library, though I haven't tested it in this more.
Thanks for your help, I copy and paste the Exception (it's identical to the one I get with the serial number)
LibFtdiException Traceback (most recent call last) ~/.local/lib/python3.10/site-packages/pylablib/core/devio/comm_backend.py in init(self, conn, timeout, term_write, term_read, open_retry_times, datatype, reraise_error) 805 try: --> 806 self.instr=self._open_instr(port,conn_dict) 807 self.opened=True
~/.local/lib/python3.10/site-packages/pylablib/core/devio/comm_backend.py in _open_instr(self, port, params) 817 if "serial_number" in sig.arg_names: # pyft232 v0.11 signature change --> 818 return ft232.Ft232(serial_number=port,**params) 819 else:
~/.local/lib/python3.10/site-packages/ft232/libftdi.py in init(self, port, serial_number, description, baudrate, bytesize, parity, stopbits, timeout, xonxoff, rtscts, writeTimeout) 163 PRODUCT, None, serial) --> 164 if ret != 0: raise LibFtdiException(self._context) 165 elif description:
<class 'str'>: (<class 'TypeError'>, TypeError('str returned non-string (type bytes)'))
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Ah, looks like there's an error in a regex, so it doesn't recognize that it needs to use serial backend. Could you try x = Thorlabs.KinesisPiezoMotor(("serial","/dev/ttyUSB0"))
instead? This specifies the backend explicitly.
we are getting closer,
ThorlabsBackendError: backend exception: 'read returned less than expected: 0 instead of 6' ('read returned less than expected: 0 instead of 6')
Ok, looks like there's another minor bug regarding default backend settings. Could you now try
conn = {"port":"/dev/ttyUSB0","baudrate":115200,"rtscts":True}
x = Thorlabs.KinesisPiezoMotor(("serial",conn))
success! :) thank you very much for your help and your time
Great! Thanks for testing the code for me!
In the next release I'll update the documentation and fix these two bugs, so that the simple Thorlabs.KinesisPiezoMotor("/dev/ttyUSB0")
will also be able to work.
thanks again!
Hi, from a Linux environment I'm trying to connect to a KIM101 but In [1]: from pylablib.devices import Thorlabs In [2]: Thorlabs.list_kinesis_devices()
results in Segmentation fault (core dumped)
while In [1]: from pylablib.devices import Thorlabs In [2]: x = Thorlabs.KinesisPiezoMotor("XXXXXXXX") in a LibFtdiException
I've seen from another bug (#27 ) another user is able to use a KIM101, but I didn't want to "pollute" the discussion.
Any suggestion on how to move forward?