Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 47

Thread: Windows USB example

  1. #21
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows USB example

    sorry but i can't understand how you can search HID_CLASSGUID {0x6bdd1fc6, 0x810f, 0x11d0,{ 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f }},.everytime i have searched and i allway search "{a5dcbf10-6530-11d2-901f-00c04fb951ed}" with the another USB.
    please help me!! thanks
    Please give me the directions by images!!

  2. #22
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows USB example

    I don't understand your question. This example is made for HID devices, a5dcbf10-6530-11d2-901f-00c04fb951ed is USB raw device ?

  3. #23
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows USB example

    sorry, i wrong. However how can you find PID and VID of a USB HID?? please help me!!

  4. #24
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows USB example

    Use SetupDi API

  5. #25
    Join Date
    Aug 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Windows USB example

    Hi there

    I'm a newbie in c++ programming, I'm doing my thesis and stealing code from here and there.... So thanks for the example first!

    I noted that the ReadThread is actually eating one CPU because it's in an endless loop, checking for events. I added a sleep statement that lets it run once per second and CPU usage dropped dramatically. Of course you lose responsiveness and you get a notification a second after the device is plugged in, but I don't think it's a major drawback.

    EDIT: My bad, I'm looking from the perspective of my device (a thermometer) that really doesn't run in realtime. Following joystick movement requires more frequent updates. Still some delay of 0.01sec won't be noticeable and should reduce CPU usage too.
    Attached Images Attached Images
    Last edited by bigblondewolf; 4th August 2011 at 20:20.

  6. #26
    Join Date
    Dec 2011
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Windows USB example

    Hi, all!
    First of all I want to tell "Thanks" for this example!
    Now I write project for using Magnetic Stripe Reader that recognized by Windows as USB HID Device:
    Qt Code:
    1. ##?#HID#VID_1136&PID_3003#6&2b575f1c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
    To copy to clipboard, switch view to plain text mode 
    But in this example it always return INVALID_HANDLE_VALUE in usbexample.cpp:273 on:
    Qt Code:
    1. ReadHandle = CreateFile((DetailedInterfaceDataStructure->DevicePath), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
    To copy to clipboard, switch view to plain text mode 
    And DevicePath is correct:
    Qt Code:
    1. qDebug() << QString::fromWCharArray(DetailedInterfaceDataStructure->DevicePath);
    To copy to clipboard, switch view to plain text mode 
    return
    Qt Code:
    1. \\?\hid#vid_1136&pid_3003#6&2b575f1c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
    To copy to clipboard, switch view to plain text mode 

    What's wrong?
    Last edited by stringer; 21st December 2011 at 16:35.

  7. #27
    Join Date
    Jul 2010
    Location
    Ahmedabad,Gujarat,India
    Posts
    25
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Windows USB example

    Hi stringer,

    try following code might it help's you.

    Qt Code:
    1. HANDLE hFile = CreateFile( DetailedInterfaceDataStructure->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
    To copy to clipboard, switch view to plain text mode 

  8. #28
    Join Date
    Dec 2011
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Windows USB example

    Thanks for quick reply!
    But nope!


    Added after 32 minutes:


    When I call GetLastError() after CreateFile, I get number 5. Google tell me that this is ERROR_ACCESS_DENIED. Why?
    My System is Windows 7 x64 with disabled UAC.
    Last edited by stringer; 21st December 2011 at 16:16.

  9. #29
    Join Date
    Dec 2011
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Windows USB example

    Assignment of WriteHandle goes well, but ReadHandle generate error ERROR_ACCESS_DENIED.
    Maybe, for my task, use RAW Input Devices like here: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx ?
    But I don't know how. Can anybody help me?

  10. #30
    Join Date
    Dec 2011
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Windows USB example

    Hooray! I get the example to WORK!
    I just needed to switch MSR (Magnetic Stripe Reader) Mode from "Keyboard Emulation Mode" to "HID Mode" via 3rd Party Utility which absent in box for MSR.

  11. #31
    Join Date
    Nov 2011
    Location
    Bangalore
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Post Re: Windows USB example

    i am trying to develop qt application using USB to control relay board..... I was trying this windows USB Example...
    always getting an error message " :: error: No rule to make target `../../qt/2010.05/qt/mkspecs/win32-g++/qmake.conf', needed by `makefile'. Stop." Can anyone please give suggestion how to recover from this error.........Is there any sample application available using USB in windows.....

  12. #32
    Join Date
    Nov 2011
    Location
    Bangalore
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Smile Re: Windows USB example

    please reply to my post......can any one help me to overcome this problem.....

  13. #33
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows USB example

    Call qmake. This has nothing to do with USB.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #34
    Join Date
    Nov 2011
    Location
    Bangalore
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Smile Re: Windows USB example

    Please help me regarding this !!!!!!!!!!!!!... i have entered correct VID & PID for the device but this application is not showing the device connected......
    i tried to connect USB relay board which uses Microchip Pic 18 series.... I want to control those relays through USB......

  15. #35
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows USB example

    Are you sure your device is compliant with this example?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #36
    Join Date
    Nov 2011
    Location
    Bangalore
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Windows USB example

    My device is getting connected with this app....... now the proble is that, wen am creating file ReadHandle and WriteHandle bot are getting value 0xffffffff...... i tried by changing the values but no use..... when i tried to display device path its showing correct only...... CreateFile function always returns 0xffffffff only..............

  17. #37
    Join Date
    May 2011
    Posts
    11
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Question Re: Windows USB example

    Hello, I am using this example and it seems to be recognizing my HID device just fine in the checkUSB(),
    but, in the winEvent I am getting wParam = 7 all the time, both when I connect or disconnect the device, so it doesn't catch these events:
    DBT_DEVICEARRIVAL = 0x8000 and DBT_DEVICEREMOVECOMPLETE = 0x8004.

    any ideas?
    Thanks

  18. #38
    Join Date
    Dec 2011
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Windows USB example

    My device is getting connected with this app....... now the proble is that, wen am creating file ReadHandle and WriteHandle bot are getting value 0xffffffff...... i tried by changing the values but no use..... when i tried to display device path its showing correct only...... CreateFile function always returns 0xffffffff only..............
    Try to use this libraries and demos: microchip.com


    Added after 6 minutes:


    Quote Originally Posted by galrub View Post
    Hello, I am using this example and it seems to be recognizing my HID device just fine in the checkUSB(),
    but, in the winEvent I am getting wParam = 7 all the time, both when I connect or disconnect the device, so it doesn't catch these events:
    DBT_DEVICEARRIVAL = 0x8000 and DBT_DEVICEREMOVECOMPLETE = 0x8004.

    any ideas?
    Thanks
    Try to add this line into .pro file:
    Qt Code:
    1. DEFINES += _WIN32_WINNT=0x0501
    To copy to clipboard, switch view to plain text mode 
    Last edited by stringer; 9th February 2012 at 20:22.

  19. The following user says thank you to stringer for this useful post:

    galrub (9th February 2012)

  20. #39
    Join Date
    May 2011
    Posts
    11
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Thumbs up Re: Windows USB example

    Quote Originally Posted by stringer View Post
    Try to use this libraries and demos: microchip.com


    Added after 6 minutes:




    Try to add this line into .pro file:
    Qt Code:
    1. DEFINES += _WIN32_WINNT=0x0501
    To copy to clipboard, switch view to plain text mode 
    well, it's just a part of the issue, I just realized that the USB hub for the front panel of this PC is, well, not a very 'well built' one,
    so this is why I get the wParam = 7, I tried using the USB socket in the back... no problem there.
    thanks.
    Last edited by galrub; 9th February 2012 at 22:55.

  21. #40
    Join Date
    Jan 2009
    Location
    Midlands UK
    Posts
    62
    Thanks
    6
    Thanked 9 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows USB example

    Hi All,

    I've followed this thread with great interest and with Gavagai's very usefull initial sourcefiles and everyone else's additions I finally managed to get a working usb interface between my PIC 4550 chip and a pc. I've attached my sources for both ends of the link so that others might find them useful. I also added some extra error trapping to make my life easier.

    Note the PIC end is on a Mikroelectronica EasyPIC4 board using their C Pro software.
    Attached Files Attached Files

Similar Threads

  1. Replies: 2
    Last Post: 6th September 2010, 15:22
  2. Replies: 3
    Last Post: 12th July 2010, 07:25
  3. Program runs on Windows 7, crashes on Windows XP
    By JovianGhost in forum General Programming
    Replies: 8
    Last Post: 7th June 2010, 01:55
  4. Deployment Procedure On Windows On Linux and Windows
    By Harshith J.V. in forum Installation and Deployment
    Replies: 4
    Last Post: 9th July 2009, 12:27
  5. Replies: 10
    Last Post: 25th February 2007, 01:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.