Sending and receiving data over USB port

好久不见. 提交于 2019-11-30 15:21:58

You don't specify what's going on here. Does the device already exist? Is it already a USB device?

If you already have a USB device, then the manufacturer should be able to help.

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.

libusb-win32 maybe?

This article in 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).

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:

  • 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.

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.

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.

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