问题
I've written a small python script that uses information from a usb gps dongle. This far I've been working in linux where I could just identify the device in /dev/ and read NMEA data from it using pySerial. This isn't a perfect solution though and it's not platform independent in any way so I started looking at pyUSB to try to communicate with the device.
The device:
- Product name: ND-100S
- baud rate: 4800
- USB class: 0xEF
- subclass: 2
My problem is that I know very little about usb so I don't know how to initialize and read sentences from it.
My testing code this far looks like:
import usb
import sys
device = usb.core.find(bDeviceClass=0xef)
print " + Class: %s" % device.bDeviceClass
print " + Subclass: %i" % device.bDeviceSubClass
print " + Protocol: %i" % device.bDeviceProtocol
print " + Length : %s" % device.bLength
print " + Configurations: %i" % device.bNumConfigurations
... Mostly just getting information about the device.
Anyone have any experience with this?
回答1:
even if it is USB dongle, you communicate with GPS device via serial interface only. However, there are a dozen of NMEA flavors so if you want it to be more platform independent, I would suggest using python-gpsd.
来源:https://stackoverflow.com/questions/6305188/reading-usb-gps-info-with-python