windows 如何在没有任何驱动程序的情况下从USB读取?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4683337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:58:33  来源:igfitidea点击:

How to read from USB without any driver?

windowsdevice-driver

提问by Xinus

We are creating small system which has GPS receiver and PC. We want to test my GPS receiver, We do not want to go for a driver on the first go. First I would like to test my circuit works or nor. GPS IC has been set to output NMEA sentence. We want a program which just reads data from USB port and print it on the screen.

我们正在创建具有 GPS 接收器和 PC 的小型系统。我们想测试我的 GPS 接收器,我们不想第一次去就找司机。首先,我想测试我的电路是否正常工作。GPS IC 已设置为输出 NMEA 语句。我们想要一个程序,它只是从 USB 端口读取数据并将其打印在屏幕上。

Can we write something like this easily ? Do we have any open source tool which will achieve this purpose ?

我们可以轻松地写出这样的东西吗?我们是否有任何开源工具可以实现这一目的?

Platform : Windows 7

平台 : Windows 7

回答by Ben Voigt

All devices need a driver, so I'm going to interpret your question as "how can I read NMEA data from my GPS using only drivers provided by the OS, so I don't have to write my own?"

所有设备都需要一个驱动程序,因此我将您的问题解释为“如何仅使用操作系统提供的驱动程序从 GPS 读取 NMEA 数据,这样我就不必自己编写驱动程序了?”

If the GPS chip has a USB interface, then you should have gotten a driver with it. But most GPS chips have a UART interface which in your case sounds like it is connected to a separate USB-UART conversion chip. That conversion chip most likely came with a driver as well, but if not, you could jumper the reset pin of the converter chip, disabling it, and then attach a TTL/RS-232 level converter (available off-the-shelf) to the UART traces and then to your computer's serial port.

如果 GPS 芯片有 USB 接口,那么你应该有一个驱动程序。但是大多数 GPS 芯片都有一个 UART 接口,在您的情况下,它听起来像是连接到单独的 USB-UART 转换芯片。该转换芯片很可能也带有驱动程序,但如果没有,您可以跳接转换器芯片的复位引脚,禁用它,然后将 TTL/RS-232 电平转换器(现成可用)连接到UART 跟踪,然后到您的计算机的串行端口。

Unless you suspect that the driver for the USB-UART converter is causing problems, I wouldn't bother.

除非您怀疑 USB-UART 转换器的驱动程序导致问题,否则我不会打扰。

回答by Mark Ransom

Anything connected via USB is a device. Devices require a device driver, period.

通过 USB 连接的任何东西都是一个设备。设备需要设备驱动程序,句号。

You might be able to get away with an existing driver built into Windows. This is how USB memory keys work for example - they present a generic device that looks like a removable disk, and Windows already includes the drivers for generic removable disks.

您也许可以使用 Windows 内置的现有驱动程序。例如,这就是 USB 存储密钥的工作方式——它们提供了一个看起来像可移动磁盘的通用设备,而 Windows 已经包含了通用可移动磁盘的驱动程序。

You would need to check the documentation for your device to see if it can emulate a device which already has drivers. Otherwise you must install the company's drivers, or you're out of luck.

您需要检查设备的文档,看看它是否可以模拟已经有驱动程序的设备。否则你必须安装公司的驱动程序,否则你就不走运了。

回答by Hugh Brackett

Have a look at libusb. You should be able to read the data with that and a little code. (Yes, it's a driver. I take the question to mean "without writing a driver".)

看看libusb。您应该能够使用它和一些代码读取数据。(是的,它是一个驱动程序。我认为这个问题的意思是“不写驱动程序”。)

回答by John

You need a device driver for your device. Unless Windows already have a class driver for the device.

您的设备需要一个设备驱动程序。除非 Windows 已经有设备的类驱动程序。

For USB devices on Windows 7 you can write a user-mode driver, see UMDF.

对于 Windows 7 上的 USB 设备,您可以编写用户模式驱动程序,请参阅UMDF