We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I'm developing a USB firmaware for LPC2378 based on the KEIL HID example. In a first step I've changed the report size to 64 Byte and added an out_endpoint as descriped in this thread: http://www.keil.com/forum/docs/thread11137.asp
Now I want to realize this procedure: The Application on the MCB2300 sends data to a USB-Buffer. Every 20 ms this Buffer has to be send to the host. If the Buffer is full before reaching the dealdine of 20 ms it is also send to the host. My problem is, that I need to send Messages of variable Size from the MCB2300 to the host. Is it possible to reach this aim with HID Example?
So if I only want to send 40 bytes after the deadline the MCB2300 will create an in_report with 64 bytes (40 bytes payload + 24 bytes padding). Now the host application interprets the whole in-report erroneously. On the other hand the host software can send data of variable lenght to the MCB2300. But al the data will be packed in 64 byte reports. So how can my firmware differentiate between payload and padding bytes?
Thanks for your help, Thomas
"Every 20 ms this Buffer has to be send to the host."
The bInterval field of the interrupt IN endpoint descriptor determines the interval. You can set up this field with any number in ms (for full-speed). But the host controller will interpret this number to the greatest integer of power of 2, less than the number. 1, 2, 4, 8 16, 32, .... (ms) When you set bInterval to 20 (ms), the host controller chooses 16 ms.
If you need 20 ms interval precisely, set bInterval to 1 (ms). Then the host controller issues IN transaction in every 1 ms. On your firmware, load the data to the interrupt IN endpoint in every 20 ms.
You can use SOF interrupt as the 1ms timer. In this case, in the SOF ISR, load the data to the IN EP on every 20th SOF interrupt. "So how can my firmware differentiate between payload and padding bytes?"
It was once discussed on this topic on USB-IF
"Change ReportCount after enumeration" on USB-IF www.usb.org/.../viewtopic.php "Now I want to test HID communication between the MCB2300 and the host pc. I tried to use the HID Client from KEIL HID example, but the client doesn't work with the MCB2300 anymore. Whats the reason for this?"
You have to modify the host app side, too. The modification is too many, I show just the point.
HIDClientDlg.h class CHIDClientDlg : public CDialog { ... BYTE InReport[65];
The original value is 2. sizeof(InReport) is handed to the ReadFile parameter, nNumberOfBytesToRead in HID_Read() call of CHIDClientDlg::OnTimer(). This causes error.
For HID, nNumberOfBytesToRead should be the size of the greatest input report plus one. As you've increased the input report size, you have to change this value.
Better practice is reading InputReportByteLength using HidP_GetCaps() Then, you don't need to worry about it, when you modify the report size on the device. Of course, you have to assign enough length of the InReport for max expected report size.
HIDP_CAPS capabilities; PHIDP_PREPARSED_DATA preparsedData; HidD_GetPreparsedData( deviceHandle, &preparsedData ); HidP_GetCaps( preparsedData, &capabilities ); HidD_FreePreparsedData( preparsedData ); .... nNumberOfBytesToRead = capabilities.InputReportByteLength; ReadFile( ..., nNumberOfBytesToRead, ...);
Tsuneo
hello,
ow my firmware seems to run properly. I've chosen a tool from http://www.lvr.com/hidpage.htm for testing my firmware instead of the KEIL HID client. As described in the thread of the USB-IF I tramsit a 'length field' in the first byte of my HID reports. (thanks for the link Tsuneo)
thanks for your help, Thomas Reinsberger