python - How do I get data from Nonin Xpod PulseOxy Sensor to Raspberry Pi -
i using raspberry pi 2 board , have connected nonin xpod pulseoxy sensor it. used pyusb module in python script access basic data of sensor vendor id , product id, etc. not able set configuration of device , proceed collection of readings. tried installing ftdi drivers provided http://www.ftdichip.com/ raspberry pi. d2xx module isnt getting imported in python script. new writing code devices. please me on how proceed.
i tired following:
import usb.core import usb.util dev = usb.core.find(idvendor=0x0424, idproduct=0x9514) dev.set_configuration() i getting error in set configuration.
traceback (most recent call last): file "s1.py", line 18, in <module> main() file "s1.py", line 13, in main dev.set_configuration() file "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 799, in set_configuration self._ctx.managed_set_configuration(self, configuration) file "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 128, in managed_set_configuration self.backend.set_configuration(self.handle, cfg.bconfigurationvalue) file "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", line 439, in set_configuration _check(_lib.usb_set_configuration(dev_handle, config_value)) file "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb0.py", line 380, in _check raise usberror(errmsg, ret) usb.core.usberror: [errno none] not set config 1: device or resource busy the datasheet sensor nonin xpod 3012lp
firstly thank answer. have tried libftd2xx installation , getting following error after use command 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 ; make -c $n || exit 1; done make[1]: entering directory '/home/pi/iiitd/release/examples/bitmode' make[1]: nothing done '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 done '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 done '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 done '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 done '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 done '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 done '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 done 'all'. make[1]: leaving directory '/home/pi/iiitd/release/examples/events' make[1]: entering directory '/home/pi/iiitd/release/examples/largeread' make[1]: nothing done '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 symbol 'pthread_join@@glibc_2.4' //lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: dso missing command line collect2: ld returned 1 exit status makefile:9: recipe target 'multi' failed make[1]: *** [multi] error 1 make[1]: leaving directory '/home/pi/iiitd/release/examples/multithread' makefile:11: recipe target 'subdirs' failed make: *** [subdirs] error 1
i haven't used nonin xpod pulseoxy sensor, it's not clear interfaces. if there datasheet communication please post that.
if device appears virtual com port, raspberry pi should have library ready python, pyserial should work.
if need use ftdi d2xx library, first install native library first(direct link). details available here , check out readme, part:
> if message "ft_open failed" appears: > perhaps kernel automatically loaded driver > ftdi usb device. > > `sudo lsmod` > > if "ftdi_sio" listed: > unload (and helper module, usbserial), follows. > > `sudo rmmod ftdi_sio` > `sudo rmmod usbserial` > > otherwise, it's possible libftd2xx not recognise > device's vendor , product identifiers. call ft_setvidpid before > calling ft_open/ft_openex/ft_listdevices. i found raspberry pi loads ftdi_sio , usbserial drivers default, had disable first before list ftdi devices , details using d2xx library. make sure can compile samples first (libraries correctly linked) , run samples (you see ftdi devices listed , along details (such vid/pid/etc.)). navigate samples folders , use make -b. note may need run them sudo.
if above works well, left install python bindings d2xx library. i've used these ftd2xx python bindings. setup should straight forward. if errors, check ftd2xx looking .so file in right path (/usr/local/lib/libftd2xx.so)
once that's installed, can try listing devices first:
import ftd2xx print ftd2xx.listdevices() update
it looks 1 of samples had errors depeneds on pthreads library. i'd try install ftd2xx python library now. part confusing plain serial should work:
"green wire = serial output: 9600 baud, 8 data bits, 1 start bit (start bit =0), 1 stop bit (stop bit = 1), no parity."
you should try read data serial library:
import serial,time def stringashex(s): return ":".join("{:02x}".format(ord(c)) c in s) sensor = serial.serial('/dev/ttyacm0',timeout=1)#should default 9600, 8 data bits, 1 stop bit, feel free use constructor arguments configure while true: data = sensor.read() if len(data) > 0: print "data str:",data,"hex:",stringashex(data) be sure read notes on 3.8v 3.3v conversion , different data formats based on resistors used (on page 3 , 4 of datasheet).
notice port use (/dev/ttyacm0): that's new arduino port shows as. you'll have check device( may show /dev/ttyusb0, ls /dev/tty* before , after connecting device on usb port).
Comments
Post a Comment