PDA

View Full Version : How to use WinUSB in Qt?



oiluj
20th December 2011, 02:16
Good evening, for all!

I have a problem and I can not solve ...
I need communication the PC with PIC using USB ....
Then, I have to create a software in Qt, my plataform is Windows ...
I study with the book USB Complete, and I searched on the net...
In my application, which is a kind of data acquisition in real time, I need a fast communication and erros checking...
In this case I think the right option is Bulk Communication ...
But in my searches I always arrive at the same point...
Using WinUSB to create a driver and a DLL, and import functions from the DLL ..
I saw several examples using VB, VC+ + and VC#...
But with Qt I can't do it because I don't know and I think it's impossible import DLL functions ...
The only exemple I found in the net with Qt, is a HID communication ...

I need someone give me an idea of how to do this...
If it's possible to create the DLL functions inside the Qt code...
And, if it's possible, where I find them for I see and implement them in my code!


Thanks all!

ChrisW67
20th December 2011, 10:12
This has nothing to do with Qt. Qt is not a compiler or linker.

You cannot use raw C++ objects in DLLs unless your compiler matches the compiler used to create the original DLL.
You can use C functions and structures in foreign DLLs.
You can use objects defined in ActiveX DLLs using generic Windows programming or Active Qt.

Given that WinUSB follows the usual Windows API conventions this task should be no more difficult than including the relevant header file and linking the relevant library.

oiluj
20th December 2011, 16:09
Hi....

I don't understand everything you said...
But I think you wanted say that it's possible create a program without a DLL...
Using only the library functions....

But I don't know how and where I find the library...
Because in my searches I always find the program with a DLL...

Can you or anyone help me??

Thanks All!

ChrisW67
21st December 2011, 00:41
But I think you wanted say that it's possible create a program without a DLL...
No. I said nothing like that. I gave you the generic answer to mixing libraries built in different ways and with different compilers.
The WinUSB library functions are in the winusb.dll file that is part of Microsoft Windows Driver Kit (WDK).

Using only the library functions....
Yes

But I don't know how and where I find the library...
It is part of Microsoft Windows Driver Kit (WDK) according to http://msdn.microsoft.com/en-us/library/windows/hardware/ff540196%28v=vs.85%29.aspx

Because in my searches I always find the program with a DLL...
That is because WinUSB's user functions are delivered in a DLL.

Do you ultimately want to write a custom USB driver or are you trying to talk to a device that falls into one of the standard classes?
Have you looked at libusb?

oiluj
22nd December 2011, 00:58
Hi!! And Sorry for my bad english and my bad understanding...

I want comunicate the PC with my device...
My device is a data acquisition system controled for PIC microcontroler...
And I need a fast comunication and errors checking...
From this I think it's best to me is Bulk!!
But bulk needs a driver, so I use WinUSB...

And how is a project of my university, and the teacher doesn't want me to use libraries like libusb...
I think the only way is the WinUSB!

And I read the link if you send to me...
In this link has all the functions...
But, it's in C++??

And the header file is created automatically when I use WinUSB??

Thank's a lot!

ChrisW67
22nd December 2011, 01:42
The header files, library files and documentation should be in the Microsoft Windows Driver Kit (WDK) (http://www.microsoft.com/download/en/details.aspx?id=11800). These should work without problems when using the Microsoft compiler.

If you are using the MingW compiler you will probably have issues with the headers using things not present in MingW. You should be able to use the library if you can get past any header issues.

The functions in the WinUSB library are like all the Windows API: they are accessible from C++.

I cannot help with actually using the WinUSB library. From what I gather it is not for the faint hearted, which I why I suggested libusb.

oiluj
22nd December 2011, 02:58
Hello...

Thanks for all help...

And if is not abuse....
I read the link of Microsoft about de WinUSB, and I found a piece that talk about the import libraries...
And I saw the example code of the site, and in example there isn't DLL imports....
And I saw too the example I found in the net... And the functions that are imported in the example are the same in the example of the site...

And I think if I just include the libraries, I can use its functions...
And I think which I need modify the libraries too..

What are you think about this??

Thanks a lot!