How to use QT under Libusb-win32

Source: Internet
Author: User

Source: How to use QT under Libusb-win32

have been unable to find a suitable WIN7 under the Tiny6410 USB download software, just these days to start learning USB, so I intend to write a dedicated Tiny6410 for the WIN7 under the USB download software.

Found the Libusb This library can be used as a non-drive USB development, that is, do not need to understand the Windows Driver development knowledge can be developed USB device driver, only need to understand the relevant USB protocol. Under Windows I almost do not use vs to write programs, or I do not understand MFC, hehe, I use QT to do the interface. All right, get to the chase.

First download the libusb-win32,:http://sourceforge.net/projects/libusb-win32/files/, Note that selecting the downloaded file is Libusb-win32-bin-1.2.6.0.zip, which is not the source code, but some already compiled libraries. Unzip it, there are so many files (clips):

Here is a brief introduction to how the contents of the inside are used.

(1) Bin folder. The most important thing is Inf-wizard.exe this program , when your USB device plugged into the computer and did not find the driver can be used to install the universal USB driver. Double-click on it, next, find your USB device inside, select Next, and finally a dialog box will pop up to let you save it to build the driver. This will have the driver, but has not been installed, can be installed through the Device Manager, after the successful installation, you can use LIBUSB to write programs to access your USB device.

(2) Examples folder. There are two routines in it, a simple one, a complicated one, and a reference to the BULK.C routines on the inside.

(3) Include folder. You need to write the program, usually put in your project directory.

(4) Lib folder. Inside are some already compiled library, have Borland version, have VC + + version, have x64 bit version, the most important is also has the GCC version, here is the GCC version, this version can be used on QT.

Here's how to use the library under QT.

1. Create a new QT project

2. Copy the GCC version of the library file LIBUSB.A to the project directory (which can be placed in a different directory) and append the following line to the. Pro file (the path is modified as appropriate):

libs+= "F:/QT/PRATISE/LIBUSB-TEST/LIBUSB/LIBUSB.A"

This allows you to find the function you want at the link.

3. Copy the Lusb0_usb.h file under the Include folder mentioned above into the project directory.

4. Write a test file, I write here is relatively simple, the function of the program is to list only my USB device, as follows:

#include"Testlibusb.h"#include"Lusb0_usb.h"Usb::usb () {//Usb_set_debug (+);Usb_init ();/*Initialize the library*/usb_find_busses ();/*Find all busses*/usb_find_devices ();/*Find all connected devices*/my_usb_get_device_list (); Resize ( the, -);}voidUsb::my_usb_get_device_list (void){    structUsb_bus *bus; structUsb_device *Dev;  for(bus = usb_get_busses (); bus; bus = bus->next) {         for(dev = bus->devices; dev; dev = dev->next) {            /*For specified device if (Dev->descriptor.idvendor = = My_vid && dev->d            Escriptor.idproduct = = my_pid) {return usb_open (dev); }            */Qdebug ("Vid:vid =%x:%x\n", Dev->descriptor.idvendor, dev->descriptor.idproduct); }    }}

Well, run the program, Effect:

The last line prints out exactly the Tiny6410 USB device number.

Attention:

This can only list USB devices that have drivers installed with the Inf-wizard.exe build . At the beginning, I did not pick up the Tiny6410, the program did not output, plug a U disk, or no output, thought is the program or the library has problems, tangled a will, then a flash, plug in the Development Board try it, sure enough, the program run results as shown above.

Continue to learn USB, 2 days after the USB Development Board to start the actual combat.

Postscript:

The first to use Delphi call Libusb has been found not STM32 do HID devices, but can find the AVR development tool usbasp. This makes me depressed, the difference is that in the win Device Manager USBasp is a separate device, and STM23 HID is in the "Human input device" group, the display name is "input device." The most suspicious is to refer to the online example of a user's debugging tool can be found and can send data, so has been suspected that the program calls have problems, toss dead ....

Finally on the Internet to find the above article, referring to the role of Inf-wizard.exe. So according to the above operation completed in the win device management in a separate display as a device, and can normally find. Thanks a lot of netizens!

So, now turn the article (before the original address, point to the original text), so that more users encounter the same problem can be seen.

How to use QT under Libusb-win32 (turn)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.