我用的是树莓皮2板,我已经连接了非Xpod脉冲氧传感器。我在python脚本中使用PyUSB模块来访问传感器的基本数据,如供应商id、产品id等。我无法设置设备的配置并继续收集读数。我尝试安装http://www.ftdichip.com/为Raspberry Pi提供的ftdi驱动程序。但是我的python脚本中没有导入d2xx模块。 我对编写设备代码很陌生。请帮助我如何继续。在
我累了以下几点:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0424, idProduct=0x9514)
dev.set_configuration()
设置配置出错。在
^{pr2}$传感器的数据表是Nonin Xpod 3012LP
首先感谢你的回答。我已经尝试过libftd2XX安装,在使用命令make -B
后,我得到以下错误
for n in BitMode EEPROM/erase EEPROM/read EEPROM/write EEPROM/user/read EEPROM/user/size EEPROM/user/write Events LargeRead MultiThread SetVIDPID Simple Timeouts ; do make -C $n || exit 1; done
make[1]: Entering directory '/home/pi/iiitd/release/examples/BitMode'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/BitMode'
make[1]: Entering directory '/home/pi/iiitd/release/examples/EEPROM/erase'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/EEPROM/erase'
make[1]: Entering directory '/home/pi/iiitd/release/examples/EEPROM/read'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/EEPROM/read'
make[1]: Entering directory '/home/pi/iiitd/release/examples/EEPROM/write'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/EEPROM/write'
make[1]: Entering directory '/home/pi/iiitd/release/examples/EEPROM/user/read'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/EEPROM/user/read'
make[1]: Entering directory '/home/pi/iiitd/release/examples/EEPROM/user/size'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/EEPROM/user/size'
make[1]: Entering directory '/home/pi/iiitd/release/examples/EEPROM/user/write'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/EEPROM/user/write'
make[1]: Entering directory '/home/pi/iiitd/release/examples/Events'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/Events'
make[1]: Entering directory '/home/pi/iiitd/release/examples/LargeRead'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/pi/iiitd/release/examples/LargeRead'
make[1]: Entering directory '/home/pi/iiitd/release/examples/MultiThread'
gcc main.c -o multi -Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
/usr/bin/ld: /tmp/ccStfEVz.o: undefined reference to symbol 'pthread_join@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: ld returned 1 exit status
Makefile:9: recipe for target 'multi' failed
make[1]: *** [multi] Error 1
make[1]: Leaving directory '/home/pi/iiitd/release/examples/MultiThread'
Makefile:11: recipe for target 'subdirs' failed
make: *** [subdirs] Error 1
我终于能够使用以下代码从传感器获取数据:
我意识到传感器正在显示字符。然后我把数据转换成整数,放入帧中,把帧组织成一个包(数据表中提到了帧和包的细节)。然后我从数据包中提取传感器读数。 框架和包是用python中的列表实现的。在
我还没有用过非Xpod脉冲氧传感器,但现在还不清楚它的接口。如果有通讯数据表,请张贴。在
如果设备显示为虚拟com端口,Raspberry PI应该已经准备好库,这样来自Python的pySerial应该可以工作。在
如果需要使用FTDI D2XX库,请首先安装native library first(直接链接)。提供详细信息here并查看readme,尤其是这部分:
我发现Raspberry PI在默认情况下加载ftdi_sio和usbserial驱动程序,因此必须先禁用这些驱动程序,然后才能使用D2XX库列出ftdi设备和详细信息。确保您可以首先编译它们的示例(库被正确链接),并运行它们的示例(您可以看到列出的FTDI设备以及详细信息(例如VID/PID/等等)。只需导航到samples文件夹并使用
make -b
。 请注意,您可能需要将它们作为sudo运行。在如果上面的工作正常,剩下的就是为D2XX库安装Python绑定。我用过这些ftd2xx Python bindings。设置应该是直截了当的。如果出现错误,请检查ftd2xx是否在正确的路径(
/usr/local/lib/libftd2xx.so
)中查找.so文件安装后,您可以尝试先列出您的设备:
^{pr2}$更新
看起来只有一个示例出现了与pthreads库相关的错误。我现在尝试安装ftd2xx python库。 令人困惑的是,普通序列号应该可以工作:
您应该尝试使用串行库简单地读取数据:
^{3}$请务必阅读有关3.8v到3.3v转换的说明以及基于所用电阻器的不同数据格式(数据表第3页和第4页)。在
注意我使用的端口(
/dev/ttyACM0
):这通常是新的Arduino端口显示的。你必须检查你的设备是什么(可能显示为/dev/ttyUSB0
,在将你的设备连接到usb端口之前和之后做ls /dev/tty*
)。在相关问题 更多 >
编程相关推荐