USB HID Output Report Issue

Hi All,

Trying to get a basic USBHID implementation working on a Nucleo WB55RG. I’m using the exact code here. This code instantiates an HID device and creates both input and output interrupt endpoints. I’m able to receive input data (host ← device) but I cannot see output data (host → device).

I don’t know if it is a host issue or device issue. I’m on a Mac using hidapitester to send the output packets. Below is a snippet from the cmd line:

% ./hidapitester --vidpid 1234/0006 --open --length 8 --send-output 01,02,03,04,05,06,07,8 --read-input
Opening device, vid/pid: 0x1234/0x0006
Writing output report of 8-bytes...wrote -1 bytes:
 01 02 03 04 05 06 07 08
Reading 8-byte input report 0, 250 msec timeout...read 8 bytes:
 01 15 42 6A D2 EF 9B 0F
Closing device

I do not see 1, 2, 3, 4, 5, 6, 7, 8 printed in main(). Any suggestions on what could be happening here? I wonder if my output reports are being sent on the control pipe instead of the output pipe, in which case main() wouldn’t see it. I don’t have an analyzer so not sure how I can verify which pipe it’s being sent on.

I also tried sending packets using python’s hidapi, but am having the same issue. Any ideas on what may be happening here?

As a side note - I’ve found the HID driver a little light weight. Doesn’t look like there is support for feature reports or regular messages sent over the control pipe. Are these features extended anywhere?

Hello @aji_man ,

I do not understand how your PC saw correct VID and PID because I can not find it in Windows device manager. Then I found there is a mistake in constructor of the official example.

// Declare a USBHID device
USBHID HID(8, 8, 0x1234, 0x0006, 0x0001, true);

That is not corresponding with:

So the boolean must be as first parameter and not last.

// Declare a USBHID device
USBHID HID(true, 8, 8, 0x1234, 0x0006, 0x0001);

Also the python script seems to be wrong. When I tried to executed it, then i received syntax error about row 6

    print(f"Got message {data}")

when I deleted the f char, then it was working.

I hope that will help you.

BR, Jan

Thanks @JohnnyK for the feedback.

I also found the constructor issue before I did my original post, I forgot to mention that. I was able to see VID/PID no issue, and I’m able to see input reports with no problem. The issue is output reports (host → device), I’m not seeing those. Did that work for you?

I can’t use the python script in the link because it uses pywinusb and I’m using macOS but there is a similar library called hidapi that I tried w/ the same issue (inputs work, but output reports do not work). I’m curious to know if output reports are working for you, if so then it’s probably a host side issue (I’m suspicious that I may be using control instead of interrupt pipe). If it isn’t working for you then at least I can look more into the device driver.

Hello again,

so, I installed that Python’s hidapi and executed a script called try.py via Windows CMD, please see the result bellow.

Windows Terminal:

Opening the device
Manufacturer: mbed.org
Product: HID DEVICE
Serial No: 0123456789
Write the data
Read the data
[8, 7, 6, 5, 4, 3, 2, 1]
[8, 7, 6, 5, 4, 3, 2, 1]
Closing the device
Done

Response from my Serial Terminal connected to ST-link of my Nucleo-F767ZI:

USBHID example

63353500000

Into Mbed’s USBHID example I added this static data (87654321) instead of random from original.
The data what were received are exactly same data like from script try.py .

As a conclusion I can say it is working in my case with my board.

BR, Jan

Thanks @JohnnyK - Unfortunately I am still not able to see the output reports. I will continue to troubleshoot. I took a detour and tried it with STM32HAL and it is somewhat working, so I am able to make a little bit of progress.