Customer trying to implement a USB HID and transfers data on USB HID Frames. The packet length is variable and implementation can send or receive data at any time (within USB HID restrictions of course). The packets also include a Sequence Number to allow the host and or device to notice if packets are being dropped. Using TM4C1233E6PM, they are using the TivaWare USB Library to handle the USB layer. Over long runs of data being transferred in both directions, they noticed we would receive duplicate packets very sporadically. After troubleshooting with a debugger, they noticed the following:
Using a USB analyzer, we noticed that we would have random ‘Classification Error’ failures. The USB analyzer defines a ‘Classification Error’ as ‘An error occurred during class-level parsing.’ This message will always have 0 byte payload
-
This ‘classification error’ packet will always occur 1-2 Frames after a Frame where there was an input report and output report.
-
While troubleshooting, they noticed that sometimes immediately after the ‘classification error’ packet the ‘USBDHIDReportWrite’ function that returned ‘0’ (which per the function header, means a failure) when it was called.
-
When the ‘USBDHIDReportWrite’ function that returned ‘0’ (which per the function header, means a failure) they would see duplicate packets being sent to the host
-
The code is set up so if ‘USBDHIDReportWrite’ returned ‘0’, they would not move the buffer forward to the next USB HID packet, as they interpreted a failure as meaning they would need to reload it into the USB HID driver again.
-
Because of this observation, they decided to modify the code to advance the buffer regardless of the value that was returned from the ‘USBDHIDReportWrite’ function
-
Running a quick test with the debugger, they were able to trap on the on a case where ‘USBDHIDReportWrite’ returned ‘0’ and noticed that no packets were duplicated (the ‘classification error’ failure was still present)
-
Based on these results, they decided to run a test overnight to see the performance
-
In this software configuration, they verified that the approximately 5 million messages that were sent and/or received contained the correct sequence number, resulting in none being analyzed as dropped and/or duplicated
-
They believe they have found a workaround for the duplicate message, but based on the function header, they are not cofident that they are using the library in the correct way. They believe the ‘classification error’ packet is acceptable as it will be dropped, but would not consider it ‘expected’.
The larger concern for them is if they are doing something incorrect causing the ‘USBDHIDReportWrite’ function to report a failure, yet still send out the message.