问题描述
我正在使用 FTDI D2XX 驱动程序API与FTDI设备进行通信.它为我提供了有关设备的信息,例如locid,序列号,描述,但还不够.
I am using FTDI D2XX driver API to communicate with a FTDI device.It gives me some information about the device like locid, serialnumber, description but it is not enough.
如何通过此API获取设备号(/dev/ttyUSBXX
)或总线或端口.
How can I get the device number (/dev/ttyUSBXX
) or bus or port with this API.
谢谢
推荐答案
作为 D2XX程序员指南在引言中指出:
问题是您的Linux可能会自动加载VCP驱动程序(ftdi_sio
),因此您不能使用D2XX驱动程序.在您的终端中键入以下内容,以确保ftdi_sio
已加载:
The problem is that your Linux may automatically loads the VCP driver (ftdi_sio
) and therefore you cannot use D2XX driver. Type the following into your terminal to make sure, the ftdi_sio
is loaded:
sudo lsmod | grep -a "ftdi_sio"
通过本文文章I成功地解决了这个问题.我的工作解决方案是在/etc/udev/rules.d/
下创建两个文本文件.第一个从ftdi_sio
驱动程序解除我的设备的绑定,第二个调整我的设备的权限.假设第一个与我的设备解除绑定的文件被命名为98-my-device.rules
,并且具有以下内容:
By this article I succesfully overcame the problem. My working solution is to create two text files under the /etc/udev/rules.d/
. The first unbinds my device from the ftdi_sio
driver and the second adjusts the permissions for my device. Let assume the first file which unbinds my device is named to 98-my-device.rules
and has the following content:
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{product}=="FTDI Device",\
PROGRAM="/bin/sh -c '\
echo -n $id:1.0 > /sys/bus/usb/drivers/ftdi_sio/unbind;\
echo -n $id:1.1 > /sys/bus/usb/drivers/ftdi_sio/unbind\
'"
现在,假设第二个文件使我的设备无需root权限就可以使用,其名称为99-my-device.rules
,并且具有以下内容:
Now let assume the second file which makes my device usable without root rights is named to 99-my-device.rules
and has the following content:
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{product}=="FTDI Device",\
MODE="0666"
这些规则将在下次重启时生效,或者可以通过以下方式应用:
These rules will be active from the next restart or they can be applied by:
sudo udevadm trigger
可以通过sudo lsusb -v
命令获得设备的属性(供应商ID,产品ID和产品说明),但这会显示过多信息.您可以使用以下内容过滤结果:
The device's attributes (vendor id, product id and the product description) can be obtained by the sudo lsusb -v
command but this will show too much information. You can filter the results with something like this:
sudo lsusb -v | grep -a "Bus ... Device ...:\|idVendor\|idProduct\|iProduct"
成功阻止Linux为特定设备加载ftdi_sio
驱动程序后,可以使用D2XX API.要从所有连接的设备中获取信息,请尝试使用《 D2XX程序员指南》中功能FT_GetDeviceInfoDetail
的示例代码.
After you succesfully prevented the Linux to load the ftdi_sio
driver for a specific device, you can use the D2XX API. To get informations from all connected devices try the example code of function FT_GetDeviceInfoDetail
from the D2XX Programmer's Guide.
这篇关于如何使用FTDI D2XX驱动程序API获取Linux设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!