Hello,
I'm trying to make a report descriptor that contains many report IDs with different size, some with 1 byte and some with 2 bytes. At first is that possible?
I supposed that it's possible, and changed the wMaxPacketSize to 3 bytes (the max of bytes to send + one byte for the report ID) , but when I send data from the host to my stm32 I only receive the first 2 bytes the report ID and the next byte. Am I missing something? Is there something else that I have to change in the descriptor file?
Thanks,
It has been ages for me, but you need to adjust the structure of your report as well. That can be done in the respective descriptor.
> I'm trying to make a report descriptor that contains many report IDs with different size, some with 1 byte and some with 2 bytes. At first is that possible?
Of course, it's possible. But is the report ID really required for your application?
As all of your reports are just one or two bytes, - Define single 3 bytes report on the report descriptor. - The first byte is used as an "identifier" specific to your application. - ONE byte data is placed at the second byte, the third byte is filled with 0 (padding) - TWO bytes data occupies the second and the third bytes of the report.
After all, there is no difference on your application code from those in which report ID is applied, on both side, firmware and the PC application.
Tsuneo
I get rid of report ID and just want to try a simple example sending two bytes.
0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1) 0x09, 0x01, // USAGE (Vendor Usage 1) 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x02, // USAGE (Vendor Usage 1) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) 0x95, 0x02, // REPORT_COUNT (2) 0x75, 0x08, // REPORT_SIZE (8) 0x91, 0x86, // OUTPUT (Data,Var,Rel,Vol) 0x09, 0x02, // USAGE (Vendor Usage 2) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) 0x95, 0x02, // REPORT_COUNT (2) 0x75, 0x08, // REPORT_SIZE (8) 0xb1, 0x86, // FEATURE (Data,Var,Rel,Vol) 0xc0 // END_COLLECTION
I'm using usb HID demonstrator for sending data and usblyzer to visualize the data. It seems that data just wont send.
Thank you for this software. I tried to send data as you told me at least with this software I'm getting an error message : "error : a device attached to the system is not functioning (1f)" I couldn't find any documentation about this software. Can you please help me what could be the problem. I've already configured wMaxPcketSize in the endpoint out descriptor to allow three bytes transfer.
What else do I have to do?
this is my hole descriptor file
0x09, /* bLength: Configuration Descriptor size */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */ CUSTOMHID_SIZ_CONFIG_DESC, /* wTotalLength: Bytes returned */ 0x00, 0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration*/ 0xC0, /* bmAttributes: Self powered */ 0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */ /************** Descriptor of Custom HID interface ****************/ /* 09 */ 0x09, /* bLength: Interface Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints */ 0x03, /* bInterfaceClass: HID */ 0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ 0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ 0, /* iInterface: Index of string descriptor */ /******************** Descriptor of Custom HID HID ********************/ /* 18 */ 0x09, /* bLength: HID Descriptor size */ HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */ 0x10, /* bcdHID: HID Class Spec release number */ 0x01, 0x00, /* bCountryCode: Hardware target country */ 0x01, /* bNumDescriptors: Number of HID class descriptors to follow */ 0x22, /* bDescriptorType */ CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */ 0x00, /******************** Descriptor of Custom HID endpoints ******************/ /* 27 */ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */ 0x81, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ 0x02, /* wMaxPacketSize: 2 Bytes max */ 0x00, 0x20, /* bInterval: Polling Interval (32 ms) */ /* 34 */ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */ /* Endpoint descriptor type */ 0x01, /* bEndpointAddress: */ /* Endpoint Address (OUT) */ 0x03, /* bmAttributes: Interrupt endpoint */ 0x03, /* wMaxPacketSize: 2 Bytes max */ 0x00, 0x20, /* bInterval: Polling Interval (20 ms) */
I'm sorry the error message is actually : "write error : the parameter is incorrect (57)"
Umm..
I put your above descriptors (config set and report descriptor) to Keil MCB1700 USBHID example C:\Keil\ARM\Boards\Keil\MCB1700\USBHID
With these extra #define's, the modified example was compiled.
#define CUSTOMHID_SIZ_CONFIG_DESC \ USB_CONFIGUARTION_DESC_SIZE + \ USB_INTERFACE_DESC_SIZE + \ HID_DESC_SIZE + \ USB_ENDPOINT_DESC_SIZE + \ USB_ENDPOINT_DESC_SIZE #define HID_DESCRIPTOR_TYPE HID_HID_DESCRIPTOR_TYPE #define CUSTOMHID_SIZ_REPORT_DESC sizeof(HID_ReportDescriptor)
And then, the example was burnt into Olimex LPC1766-STK. This modified example runs on PC without any trouble. SimpleHIDWrite also "Writes" an output report to the interrupt OUT EP without any error, checked on a hardware bus analyzer.
If your descriptor would have any trouble, it should lies in above #defines.
Thank you for your replay. I found that I have to allocate space for the received data in a function called SetEPTxCount(Endpoint,wCount) I'm actually using the USB-FS library provided by ST. If I change wCount to 3 every think works fine. I actually made a little note for any one want to modify the custom HID code provided by the library.
//changing the report descriptor
//To change the report descriptor use the HID tool then save your file as a header file then copy past the generated data in the report descriptor
//you need to refresh CUSTOMHID_SIZ_REPORT_DESC which is the size of the total report descriptor (usb_desc.h)
--> this define variable is used both in the configuration descriptor as the "wDescriptorLength " and the report descriptor as its own size
//you need to refresh the wMaxPacket size in the corresponding endpoint descriptor
--> this values defines the maximum packet to send or receive
//go to usb_prop.c and change the wCount parameter in SetEPRxCount(Endpoint, wCount) (for out data) SetEPTxCount(Endpoint,wCount) (for in data)
-->even the maximum packet is defined by the endpoint descriptor you need to allocate space for it.
//The report ID is automatically take the first byte
-->A report ID must not be equal to 0x00