使用Python读取USB-GPS信息
我编写了一个小型 python 脚本,它使用来自 USB GPS 加密狗的信息。到目前为止,我一直在 Linux 中工作,我可以识别 /dev/ 中的设备并使用 pySerial 从中读取 NMEA 数据。但这不是一个完美的解决方案,而且它在任何方面都不独立于平台,因此我开始寻找 pyUSB 来尝试与设备进行通信。
设备:
- 产品名称:ND-100S
- 波特率:4800
- USB 类:0xEF
- 子类:2
我的问题是我对 USB 知之甚少,所以我不知道如何初始化并从中读取句子。
到目前为止,我的测试代码如下所示:
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
...主要只是获取有关设备的信息。
有人有这方面的经验吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使它是 USB 加密狗,您也只能通过串行接口与 GPS 设备通信。然而,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.