USBDemo, something to learn USB a little bit


Closed Thread
Results 1 to 40 of 279

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    ... But seems NOBODY want to use the serial number...
    Well, if there was an easy way to do it, it might look more attractive.
    Running EasyHID or manually editing the descriptor file each time doesn't seem like an option.

    Maybe there's a way to have the descriptor file read the Hardware Serial number, then have the programmer auto-increment the serial number, ... but it doesn't currently have that feature.

    Other than that, since you can find the handle of each device with the same Vendor/Product ID, within your software you can create a Challenge/Response type arrangement that will let the computer assign a unique number to any new devices on the BUS.

    Nice utility Darrel!
    Thanks Steve,

    It's come in handy a few times troubleshooting USB connections.
    Thought I'd spruce it up and pass it on.
    <br>
    DT

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    On another forum someone already Suggest USBDeview. I use it a lot, it's a real nice utility ...
    http://www.nirsoft.net/utils/usb_devices_view.html

    They also have bunch of other nice freebies over there...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    All good info.

    But thanks for trumping my puny efforts.
    <br>
    DT

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well... when you did that utility... wasn't it to learn something ?

    And i'm sorry... i thought i posted that link before.. oops!

    It's still a nice utility you've made so far!
    Last edited by mister_e; - 1st December 2007 at 01:01.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Excellent point! That's exactly what it was.

    That program started from my attempt at modifying the USBDemo program from VB to Delphi.

    It's based on the Delphi routines supplied by David Barker in the EasyHID results.

    It's only right that I posted it here,... along with the reason I even know about USB. (USBDemo)


    <br>
    DT

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    if i find time, i may elaborate USBDemo a little bit more, but you know how busy i am right now with some current project + that ASM one

    For some spare time... my new toys... Delphi, EasyDsPIC 4, PoScope and PIC32s
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7


    Did you find this post helpful? Yes | No

    Default So much help!

    Quote Originally Posted by Darrel Taylor View Post
    Other than that, since you can find the handle of each device with the same Vendor/Product ID, within your software you can create a Challenge/Response type arrangement that will let the computer assign a unique number to any new devices on the BUS.
    Ok i will use Darrelīs exe program.

    I know it will not be exactly the same for VB but if there is any chance that you could post the source code i would finally see how itīs done!

    I am sure i can do with just the handler, i could also identify wich device was connected first and have a record of devices....

    This would be a great place to begin

    Thanks for your replies

    DJC

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Josuetas
    Ok i will use Darrelīs exe program.
    Thank You!<hr>
    Looking at the VB side of USBDemo
    Code:
    Public Sub OnPlugged(ByVal pHandle As Long)
        '
        '   A HID device has been plugged in,
        '   check if it's the right one, and enable the form LED (top left)
        '
        Dim DeviceHandle As Long
        Dim VendorName As String * 15
        Dim ProductName As String * 15
        
        If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then ' Good one?
            '
            '   get the device handle
            '   =====================
            DeviceHandle = hidGetHandle(VendorID, ProductID)
            '
            '   Get the vendor and product name from the handle
            '   ===============================================
            hidGetVendorName DeviceHandle, VendorName, 255
            hidGetProductName DeviceHandle, ProductName, 255
            '
            '   Enable the LED and display device information
            '   VendorName and ProductName
            '   =============================================
            imgON.Visible = True
            lVendorName.Caption = VendorName
            lProductName.Caption = ProductName
            End If
    End Sub
    Using the line shown in red, anytime a device is plugged in with the same Vendor/Product ID, it will forget about the last device and start using the new one.

    To get around that, you need to check further to make sure it's the device you want to talk to. And, for that, you need to search through the HID Device list.

    Again, I don't do VB, so the syntax is most probably wrong. But ...<hr>
    The function hidGetItemCount returns the number of HID devices in the List.
    Then hidGetItem(Index) returns the handle of the item in the list that's specified by Index (0 to count-1).

    You can get the info about that device by requesting each field.
    Vendor = hidGetVendorID(handle)
    Product = hidGetProductID(handle)
    Serial = hidGetSerialNumber(handle)

    Now if everything matches, you know you have the right one. If not, keep searching through the list.

    If you're not using the Serial Number, you'll need to send/receive something to the device to figure out if it's the correct one.

    Is that any help?
    I'll keep trying if not.
    <br>
    Last edited by Darrel Taylor; - 1st December 2007 at 23:18. Reason: added "hid" to function names
    DT

  9. #9
    Join Date
    Dec 2007
    Location
    Denmark
    Posts
    28


    Did you find this post helpful? Yes | No

    Default hey

    Steve, do I need the 18f4550 or any other USB pic for your USB project? or can I do it with a standard pic, like the 18f452?

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Atwoz, only USB PIC will work!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  11. #11
    Join Date
    Dec 2007
    Location
    Denmark
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Ok Thanks Steve! Looks like I will have to buy some 18f4550 .

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Well, one in the list... 18F4550, 2550,2455, 4455 they all works.

    As you'll see, it's fun to have it's first working USB project....even if you're aware of post #7 and #8
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    semiuniversal's Avatar
    semiuniversal Guest


    Did you find this post helpful? Yes | No

    Default Astoundingly good demo

    Hi mister_e & all who have contributed. I am quite new to PBP and this is my first post to this list. I just found this demo a week ago, read the thread, ordered the parts, assembled a proto board on Saturday and - (insert Windows USB Device da-dink! sound) it worked FLAWLESSLY, the first time. I am either lucky standing on the shoulders of giants - but oh, my, what a good feeling.

    I have been tinkering incessantly since then.
    Thank you for giving me super powers.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  3. Replies: 9
    Last Post: - 31st July 2008, 08:56
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts