我有一个Thorlabs直流电机控制器,可以使用以下dmesg日志检测到:
usb 5-2: new full-speed USB device number 6 using uhci_hcd
usb 5-2: New USB device found, idVendor=0403, idProduct=faf0
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 5-2: Product: APT DC Motor Controller
usb 5-2: Manufacturer: Thorlabs
usb 5-2: SerialNumber: 83858610
ftdi_sio 5-2:1.0: FTDI USB Serial Device converter detected
usb 5-2: Detected FT232RL
usb 5-2: Number of endpoints 2
usb 5-2: Endpoint 1 MaxPacketSize 64
usb 5-2: Endpoint 2 MaxPacketSize 64
usb 5-2: Setting MaxPacketSize 64
usb 5-2: FTDI USB Serial Device converter now attached to ttyUSB0
也可以在lsusb:
下找到Bus 005 Device 007: ID 0403:faf0 Future Technology Devices International, Ltd
根据以上信息,我设置了/etc/udev/rules.d/99-libftdi.rules
:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="faf0", GROUP="dialout", MODE="0660"
(我还尝试过users
群组和0666
模式。)
然后我运行了命令
$ udevadm test -a -p $(udevadm info -q path -n /dev/ttyUSB0)
哪个收益
GROUP 20 /etc/udev/rules.d/99-libftdi.rules:1
MODE 0660 /etc/udev/rules.d/99-libftdi.rules:1
handling device node '/dev/ttyUSB0', devnum=c188:0, mode=0660, uid=0, gid=20
preserve permissions /dev/ttyUSB0, 020660, uid=0, gid=20
preserve already existing symlink '/dev/char/188:0' to '../ttyUSB0'
found 'c188:0' claiming '/run/udev/links/\x2fserial\x2fby-id\x2fusb-Thorlabs_APT_DC_Motor_Controller_83858610-if00-port0'
creating link '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83858610-if00-port0' to '/dev/ttyUSB0'
preserve already existing symlink '/dev/serial/by-id/usb-Thorlabs_APT_DC_Motor_Controller_83858610-if00-port0' to '../../ttyUSB0'
found 'c188:0' claiming '/run/udev/links/\x2fserial\x2fby-path\x2fpci-0000:00:1d.0-usb-0:2:1.0-port0'
creating link '/dev/serial/by-path/pci-0000:00:1d.0-usb-0:2:1.0-port0' to '/dev/ttyUSB0'
preserve already existing symlink '/dev/serial/by-path/pci-0000:00:1d.0-usb-0:2:1.0-port0' to '../../ttyUSB0'
现在是软件方面。 Libftdi v1.0通过以下指令安装在Linux Mint 17下:
Pylibftdi library not working (serial mode, UM232H)
和pylibftdi通过pip安装:
$ sudo -H env PATH=$PATH pip install pylibftdi
它可以回显正确版本的libftdi:
$ python -m pylibftdi.examples.info
pylibftdi version : 0.15.0
libftdi version : libftdi_version(major=1, minor=0, micro=0, version_str='1.0', snapshot_str='v1.0')
libftdi library name : libftdi1.so.2
libusb version : libusb_version(major=1, minor=0, micro=17, nano=10830, rc='', describe='http://libusbx.org')
libusb library name : libusb-1.0.so.0
Python version : 2.7.10
OS platform : Linux-3.13.0-37-generic-x86_64-with-debian-jessie-sid
然而,即使使用sudo
,它也不会列出任何连接的FTDI设备:
$ sudo python -m pylibftdi.examples.list_devices
$ (nothing printed)
有没有办法单独测试libftdi和pylibftdi?或者,我们是否已经有足够的信息来完成这项工作?提前谢谢。
答案 0 :(得分:1)
未检测到设备,因为它有一个奇怪的idProduct
。官方Q& A提供了一个可行解决方案的提示:
http://pylibftdi.readthedocs.org/en/latest/how_to.html
打开.../pylibftdi/examples/list_devices.py
并在第24行后添加以下行:
from pylibftdi import USB_PID_LIST
USB_PID_LIST.append(0xfaf0)
并尝试再次触发命令:
$ python -m pylibftdi.examples.list_devices
Thorlabs:APT DC Motor Controller:83858610