Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: RAWHID custom device identifier

  1. #1
    Senior Member
    Join Date
    Apr 2018
    Location
    Eastern Time, USA
    Posts
    163

    RAWHID custom device identifier

    The goal of this question is to find the Teensy boards that are communiticating over RAWHID and programmed to run a particular application.

    For example, one Teensy might be programmed to act as a spectrometer (with a CCD), Another might be programmed to act as an analog i/o device.

    In the python HIDAPI there is an enumerator that returns a dictionary object for each HID device, with the following fields (see https://trezor.github.io/cython-hidapi/api.html)

    ‘path’
    ‘vendor_id’
    ‘product_id’
    ‘serial_number’
    ‘release_number’
    ‘manufacturer_string’
    ‘product_string’
    ‘usage_page’
    ‘usage’
    ‘interface_number’

    The enumerator is an attractive way to find the Teensy boards because it does not "open" the device.

    So, can any of these fields be customized in an easy way in the Teensy? I think I would leave the vendor and perhaps the product alone. The serial number, or either of the strings seems most interesting for this purpose.

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,623
    Technically, you can easily change those fields in the core files. Look at the usb*.* files.

    Following remarks:
    • In case you are using a development system which uses a fixed location of the core library, changing the core files for different applications might turn out quite tedious. If your development system allows to have the core files bundled with the project this will be much easier to handle.
    • If you are going that way, I suggest to code your different usages in the usage number of the RAWHID interface. After all, this is what the usage number is meant for. Of course, since the VID doesn't belong to you, you can't be sure that PJRC never decides to change the default usage number later which might clash with yours then.
    • I wouldn't touch the vid/pid numbers and the usage/usage_page of the SerEmu interface since then (depending on the uploader) you need to press the prog button to upload new firmware

    AFAIK, the only enumeration field accessible without touching the core files is the serial number. Here some information how to do this: https://github.com/TeensyUser/doc/wi...-Serial-Number. Just make sure that you define a unique string if there is a chance that you'll have more than one device on the USB-Bus. There are a few posts in the forum reporting some OS confusion in that case.

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,623
    APPENDIX:
    I installed python and the mentioned HID library and had a look if it works with the custom serial number set by the code from the link in #2.

    Code:
    import hid
    
    for device_dict in hid.enumerate():
        keys = list(device_dict.keys())
        for key in keys:
            print("%s : %s" % (key, device_dict[key]))
        print()
    prints (deleted the other found HIDs...)
    Code:
    path : b'\\\\?\\hid#vid_16c0&pid_0486&mi_00#9&2df9efa9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'
    vendor_id : 5824
    product_id : 1158
    serial_number : MYSN00001
    release_number : 640
    manufacturer_string : Teensyduino
    product_string : Teensyduino RawHID
    usage_page : 65451
    usage : 512
    interface_number : 0
    
    path : b'\\\\?\\hid#vid_16c0&pid_0486&mi_01#9&36f93e87&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}'
    vendor_id : 5824
    product_id : 1158
    serial_number : MYSN00001
    release_number : 640
    manufacturer_string : Teensyduino
    product_string : Teensyduino RawHID
    usage_page : 65481
    usage : 4
    interface_number : 1
    The first one with Usage 512 (0x200) is the raw hid interface, the second one is SEREMU. So, looks like the serial number manipulation is feasible to achieve your goal.

  4. #4
    Senior Member
    Join Date
    Apr 2018
    Location
    Eastern Time, USA
    Posts
    163
    That's wonderful. Thank you.

Posting Permissions

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