Reference: http://blog.sina.com.cn/s/blog_4b4b54da010153zb.html
As a device developer, generally need to let the device and the host PC communication, we often consider the following interfaces: RS232, USB, Ethernet.
Now on the PC has been difficult to see RS232 interface, and Ethernet also need to do a special configuration, USB has become our first choice. For the application of less data, we can use the USB virtual serial port way to complete such tasks, virtual serial port driver and instance, for the lower machine is also very common. There is a problem: Many applications can not be used in the way of virtual serial port to be satisfied, can only follow the USB way to solve the problem. This time, we had to program for USB. For complex driver programming, most programmers are often deterred. But there are always other simple ways to solve the problem. Here, we introduce a USB communication library: Libusb.
Introduced
The LIBUSB is a library for USB communication. Using it, you do not need to know the details of the operating system, you only need to have enough knowledge of USB. It also does not require you to write the driver, all the work can be done in the user state. The way to use it is simple, here's an example: Http://sourceforge.net/apps/trac/libusb-win32/wiki/libusbwin32_documentation#IV.Examples, isn't it simple?
Principle
Libusb himself with a kernel driver, named Libusb0.sys, placed in the windowssystem32drivers inside. The user program calls Libusb0.dll, and the DLL puts the task to the driver. This ensures that the user configuration is able to complete the operation of the USB communication.
Specifically what to do, you can download the project source files to understand, and so I have time to see it again.
Installation method
LIBUSB now has several versions. Main Page here: http://www.libusb.org/
- Because we are generally in the engineering application, choose the relatively stable version: libusb-0.1.
- Platform under windows, we use the Libusb-win32:http://www.libusb.org/wiki/libusb-win32
- Linux under the general has been added to the source inside, find Libusb can.
Installation method under Windows: Http://www.libusb.org/wiki/libusb-win32#Installation
There are 2 kinds of installation methods, Filter Driver installation and Device Driver installation, the front one can be said to be a development environment, the latter can be said to be the release of the driver itself. We are doing the system, choose the front one way, save trouble.
Use
Here are the more detailed documentation: http://sourceforge.net/apps/trac/libusb-win32/wiki/libusbwin32_documentation
Libusb-win32 of the Http://sourceforge.net/apps/trac/libusb-win32/wiki
Developer Forum Address: http://libusb.6.n5.nabble.com/
libusb-1.0 API Reference: http://libusb.sourceforge.net/api-1.0/
the reason for the time-out problem in the development process: http://sourceforge.net/apps/trac/libusb-win32/wiki/libusbwin32_documentation
About the experience of LIBUSB-WIN32 development