HID PnP Demo, adding a thread(C# application)

Author
Kabanga
Super Member
  • Total Posts : 204
  • Reward points : 0
  • Joined: 2007/11/24 13:25:16
  • Location: 0
  • Status: offline
2010/02/12 00:31:28 (permalink)
0

HID PnP Demo, adding a thread(C# application)

Hi everyone,
I'm using a custom board with PIC24FJ256GB110, the HID PnP Demo, the C# application and it's working well.
Now I'd like to do the following:
1)-add a second endpoint (endpoint 2) to the firmware
2)-add an extra thread to the C# application just for reading and writing from the endpoint 2
 
I've seen some discussions here about adding endpoints to the firmware (thanks for that).
I'd be grateful for any help (links, tips, comments) about my second question.
 
 

Best regards
Kabanga
#1

8 Replies Related Threads

    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/12 01:47:39 (permalink)
    0
    1)-add a second endpoint (endpoint 2) to the firmware
    ...
    I've seen some discussions here about adding endpoints to the firmware (thanks for that).

    I don't know the discussion you are referring, but maybe it isn't enough for HID.
    Each HID interface is allowed just single IN endpoint, and optionally single OUT endpoint.
    If you want to add another endpoints to the device, it means you have to add another HID interface, ie. HID + HID composite device.

    Instead of adding endpoints, you can add another reports to the HID report descriptor, using report ID. Two or more communication streams share together single IN/OUT endpoint pair. Report ID identifies the communication stream to which the report belongs.
    It's simpler than handling HID + HID composite device.

    Tsuneo
    #2
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/13 10:24:02 (permalink)
    0
    ORIGINAL: chinzei


    Instead of adding endpoints, you can add another reports to the HID report descriptor, using report ID. Two or more communication streams share together single IN/OUT endpoint pair. Report ID identifies the communication stream to which the report belongs.
    It's simpler than handling HID + HID composite device.



    For the records, Tsuneo, can you confirm that the overall (maximum) throughput for the device won't change, in any of the above?

    GENOVA :D :D ! GODO
    #3
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/13 18:11:04 (permalink)
    0
    If you use multiple endpoints/reports, technically it may increase the overall bandwidth, of course there will be a limit.

    http://www.edn.com/article/CA243218.html

    The downside to using the HID class is that the typical class drivers support only one type of endpoint communication—an interrupt—and the bandwidth is limited to well below the USB's maximum throughput. The bandwidth is limited to 800 bytes/sec/report (8 bytes/msec/I/O report) for low-speed devices, 64,000 bytes/sec/report (64 bytes/msec/I/O report) for full-speed devices, and approximately 23.4 Mbytes/sec/report (3072 bytes/microframe/I/O report) for high-speed devices. An HID may specify multiple reports if more than the "per-report" bandwidth is necessary.


      USB_Links and libusb
    #4
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/13 19:38:48 (permalink)
    0
    As of the HID (interrupt endpoint), two or more endpoints on multiple HID interfaces increase the overall throughput. It's fine when independent communication stream is assigned to each endpoint.

    But if you plan to increase the throughput of single communication stream by splitting it into two or more endpoints, it's a bad idea. It's because the order of packets is not guaranteed to be preserved among endpoints. For example, your host app puts a packet to EP1 first and then EP2. The device may receive them in the order, EP2 first and then EP1.


    and approximately 23.4 Mbytes/sec/report (3072 bytes/microframe/I/O report) for high-speed devices.

    This high-speed bandwidth limit is described for ideal case, without any limitation other than raw USB capability.

    But in the real world,
    1) Windows doesn't support high-speed high-bandwidth endpoint yet.
    2) For high-speed interrupt EP, endpoint bMaxPacketSize of more than 64 bytes payload is declared in an alternate interface. Windows HID driver doesn't provide any mean for PC application to switch the interface into alternate.

    With this extra limitation, high-speed HID on Windows marks no more than 512000 bytes/sec (64 bytes x 8 microframe x 1000 frame / sec)

    Tsuneo
    #5
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/14 09:55:45 (permalink)
    0
    ORIGINAL: xiaofan

    If you use multiple endpoints/reports, technically it may increase the overall bandwidth, of course there will be a limit.



    You mean that you get more BW with multiple EPs, or with multiple reports? Smile

    Tsuneo seems to state that multiple EP or multiple interfaces do get more BW, and multiple reports don't (apart from the out-of-sequence thing, that caould be handled anyway).

    thank you both!

    GENOVA :D :D ! GODO
    #6
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/18 18:26:39 (permalink)
    0

    ORIGINAL: DarioG
    You mean that you get more BW with multiple EPs, or with multiple reports? Smile

    Multiple EPs of course do. But with multiple reports, it may help at times.
    Examples:
    1) Using feature report -- this uses control transfer, so you should be able to exchange a feature report and a Input/Output report in single frame. That helps a bit.
    2) Without using feature report, say you have report 1 (3ms per update) and report 2 (4ms per update) and polling interval of 1ms, you may be able to get both reports. I am not sure if you will lose one of them every 12ms though.
    3) not so sure here: if report 1 uses 10 bytes and report 2 uses 10 bytes, I am not so sure if you can get both reports at the same frame.

      USB_Links and libusb
    #7
    Kabanga
    Super Member
    • Total Posts : 204
    • Reward points : 0
    • Joined: 2007/11/24 13:25:16
    • Location: 0
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/19 00:28:41 (permalink)
    0
    Thanks a lot for your inputs!
    Any hint how to handle multiple reports in software (C#)?

    Best regards
    Kabanga
    #8
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: HID PnP Demo, adding a thread(C# application) 2010/02/19 04:51:03 (permalink)
    0
    Thank you Xiaofan!
    Do not need this at the moment - the 1mS / 64bytes is ok for me at the moment. But we'll see...

    GENOVA :D :D ! GODO
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5