gpt4 book ai didi

python - 无法将 FT232RL 设备与 Pylibftdi 连接(Thorlabs APT 直流电机 Controller )

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:51:19 27 4
gpt4 key购买 nike

我有一个 Thorlabs 直流电机 Controller ,可以使用以下 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?或者,我们是否已经有足够的信息来完成这项工作?提前致谢。

最佳答案

未检测到设备,因为它有一个奇怪的 idProduct。官方问答给出了一个可行的解决方案提示: 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

关于python - 无法将 FT232RL 设备与 Pylibftdi 连接(Thorlabs APT 直流电机 Controller ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31143376/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com