windows 通过 USB 端口发送和接收数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/552330/
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
Sending and receiving data over USB port
提问by
I'd like to send/receive data over a USB port to a device (from my vista pc). Is there a free/cheap library out there that can do this, and how involved would this project be (not taking into account what's being sent or received) ?
我想通过 USB 端口向设备(从我的 vista 电脑)发送/接收数据。是否有免费/便宜的图书馆可以做到这一点,以及这个项目的参与程度(不考虑发送或接收的内容)?
回答by Michael Kohne
You don't specify what's going on here. Does the device already exist? Is it already a USB device?
你没有具体说明这里发生了什么。设备是否已经存在?它已经是 USB 设备了吗?
If you already have a USB device, then the manufacturer should be able to help.
如果您已经有 USB 设备,那么制造商应该可以提供帮助。
If you are building the device, then you might want to look at something like a USB to serial adapter (which generally require no special drivers at all) or something from FTDI- they make a number of easy-to-use USB chips that generally don't need, or come with appropriate drivers under windows. I've worked with their chips on a couple of occasions and they've never given me any trouble.
如果您正在构建设备,那么您可能需要查看 USB 到串行适配器(通常根本不需要特殊驱动程序)或FTDI 之类的东西——它们制作了许多易于使用的 USB 芯片,通常不需要,或者在 Windows 下带有适当的驱动程序。我曾多次使用他们的筹码,他们从未给我带来任何麻烦。
回答by kgiannakakis
This articlein Code project may be a good start for you. At first you need to build your device. You can either use a micro-controller with a USB port or you can use a serial-to-USB chipset (like the already suggested FTDI).
Code project 中的这篇文章可能对你来说是一个好的开始。首先,您需要构建您的设备。您可以使用带有 USB 端口的微控制器,也可以使用串行转 USB 芯片组(如已经建议的 FTDI)。
You should avoid writing your own USB library-driver. The article in the CodeProject uses the HDI driver, which is already present in your device. It uses a PIC micro-controller, but my personal favourite is AVR. With AVR you have the following options:
您应该避免编写自己的 USB 库驱动程序。CodeProject 中的文章使用 HDI 驱动程序,该驱动程序已存在于您的设备中。它使用 PIC 微控制器,但我个人最喜欢的是 AVR。使用 AVR,您有以下选择:
- AVR-USB: Implements USB stack in firmware. Drivers, examples for all platforms. Any AVR micro can be used. You may need to build the hardware yourself.
- Atmel's USB family. These are microcontrollers with USB port. Drivers and ready to buy kits are available. Other manufacturers (like Microchip's PIC family) have similar solutions.
- AVR-USB:在固件中实现 USB 堆栈。驱动程序,适用于所有平台的示例。可以使用任何 AVR 微型。您可能需要自己构建硬件。
- Atmel 的 USB 系列。这些是带有 USB 端口的微控制器。提供驱动程序和准备购买的套件。其他制造商(如 Microchip 的 PIC 系列)也有类似的解决方案。
回答by Tim Matthews
libusb-win32maybe?
libusb-win32也许?
回答by David Grayson
Without knowing anything else about your situation, and assuming you are in control of the device's USB protocol and drivers, I would recommend using WinUSB.
在不了解您的情况的任何其他情况下,并假设您可以控制设备的 USB 协议和驱动程序,我建议您使用WinUSB。
It is a lot better than libusb-win32 because it is a native part of Windows and it supports asynchronous communication. Also, libusb-win32 only supports the libusb-0.1 API, which is really old.
它比 libusb-win32 好很多,因为它是 Windows 的本机部分,并且支持异步通信。另外,libusb-win32 只支持 libusb-0.1 API,这真的很老了。