Re: Raw hid gadget

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 7 Jan 2017, Rogan Dawes wrote:

> Hi Alan,
> 
> Thanks for the response. I have not read hiddev.txt, so that explains
> the incorrect expectations. If I may ask, why is the value a 4-byte
> field? Is that just to round it to 8 bytes?

Probably because the original programmers needed to accomodate the data 
that could appear in any report.  Since data fields can be as large as 
32 bits, that means the field has to be 4 bytes long.

> The "English" version of the descriptor is as follows, from the
> original LUFA source:
> 
> HID_DESCRIPTOR_VENDOR(0x00, 0x01, 0x02, 0x03, GENERIC_REPORT_SIZE) /*
> GENERIC_REPORT_SIZE == 64 */
> 
> And parsed using http://eleccelerator.com/usbdescreqparser/, translates to:
> 
> 0x06, 0x00, 0xFF,  // Usage Page (Vendor Defined 0xFF00)
> 0x09, 0x01,        // Usage (0x01)

Hmmm.  Is there any reason for this item?

> 0xA1, 0x01,        // Collection (Application)
> 0x09, 0x02,        //   Usage (0x02)
> 0x15, 0x00,        //   Logical Minimum (0)
> 0x25, 0xFF,        //   Logical Maximum (255)
> 0x75, 0x08,        //   Report Size (8)
> 0x95, 0x40,        //   Report Count (64)
> 0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred
> State,No Null Position)
> 0x09, 0x03,        //   Usage (0x03)
> 0x15, 0x00,        //   Logical Minimum (0)
> 0x25, 0xFF,        //   Logical Maximum (255)
> 0x75, 0x08,        //   Report Size (8)
> 0x95, 0x40,        //   Report Count (64)
> 0x91, 0x02,        //   Output (Data,Var,Abs,No Wrap,Linear,Preferred
> State,No Null Position,Non-volatile)
> 0xC0,              // End Collection
> 
> // 32 bytes

So your device produces (and consumes) reports containing 64 8-bit
values.  Presumably in a 64-byte data packet.

> So I apparently need to extract just the 5th byte from the packet, and
> discard the rest. Excellent!

(Not from the _packet_, but from the data you receive over the rawhid 
interface.)

Well, that's if you want to read just the first value.  If you want to 
read the second value, you have to extract the 13th byte, if you want 
to read the third value, you have to extract the 21st byte, and so on.

This raises the question of how many of the values in the report are 
real.  In your first example, for instance, there must have been 64 
values but only 4 of them were real.  How are you going to tell where 
the real data ends in each report?

> Thank you!

You're welcome.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux