0
votes

Digging around with/for HID reports, I ran into a strange problem within a USB HID device. I'm implementing an HID class device and have based my program on the HID USB program supplied by Keil. Some codes have been changed in this project and it seems working fine with 32 bytes input and 32 bytes output reports. Somehow, after thousands times data transferring, the Endpoint 1 out would hang and become a bad pipe. Then I searched the google for some tips, a topic remind me that we should write a data length zero packet after sending a length of packet match what you defined in the report description. But it's not working for me. Then I write a data length zero to the control pipe after I receive a out packet and magically, it works! It would never hang after million times transferring!

Here is my question: Why does it works after writing a data length zero to a control pipe. The data transferring in the out pipe should have no relationship with the data in the control pipe. It confuses me!

1
Refer to: How to Ask and please show a minimal reproducible example. You also didn't even bother to complete the 2-minute site tour before asking.T-Heron

1 Answers

0
votes

If you transfer any data that is less than the expected payload size, you must send a Zero Length Packet to indicate that data has transferred.

But it depends heavily on the implementation on the host controller, and not all devices follow the specification to the point and may stall.

Source:
When do USB Hosts require a zero-length IN packet at the end of a Control Read Transfer?