Reading USB-GPS info with Python

不羁的心 提交于 2019-12-07 13:04:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!