python读取usb数据,使用Python读取USB-GPS信息

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?

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值