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) ?
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.
来源:https://stackoverflow.com/questions/552330/sending-and-receiving-data-over-usb-port