使用Python读取USB-GPS信息 [英] Reading USB-GPS info with Python
问题描述
我编写了一个小python脚本,该脚本使用了来自USB gps加密狗的信息.到目前为止,我一直在linux中工作,我可以在/dev/中识别设备并使用pySerial从中读取NMEA数据.但是,这并不是一个完美的解决方案,并且它也不以任何方式独立于平台,因此我开始着眼于pyUSB尝试与该设备进行通信.
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.
设备:
- 产品名称:ND-100S
- 波特率:4800
- USB类别:0xEF
- 子类:2
我的问题是我对USB知之甚少,所以我不知道如何初始化和读取其中的句子.
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?
推荐答案
即使是USB加密狗,也只能通过串行接口与GPS设备通信.但是,有12种NMEA版本,因此,如果您希望它与平台无关,我建议使用python-gpsd.
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.
这篇关于使用Python读取USB-GPS信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!