Skip to content

different result on hid_get_input_report and hid_read, or how to read a specified reportid? #801

@lexr1

Description

@lexr1

I have a Logitech mouse which can be configured by sending data to 0xff00/0x2.
Report descriptor in Windows.

0x06, 0x00, 0xFF,  // Usage Page (Vendor Defined 0xFF00)
0x09, 0x02,        // Usage (0x02)
0xA1, 0x01,        // Collection (Application)
0x85, 0x11,        //   Report ID (17)
0x09, 0x02,        //   Usage (0x02)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x13,        //   Report Count (19)
0x81, 0x00,        //   Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x09, 0x02,        //   Usage (0x02)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x13,        //   Report Count (19)
0x91, 0x00,        //   Output (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0xC0,              // End Collection

// 36 bytes

Below code set LED light to red(so I know it's working). read-input returns correct data but read-input-report always returns same result, even in Linux.

C:\>hidapitester --vidpid 046d/c08b --usagePage 0xFF00 --usage 2 --open -l 20 --send-output 0x11,0xff,2,0x3f,0,1,0xff --read-input
Opening device, vid/pid:0x046D/0xC08B, usagePage/usage: FF00/2
Device opened
Writing output report of 20-bytes...wrote 20 bytes:
 11 FF 02 3F 00 01 FF 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading up to 20-byte input report, 250 msec timeout...read 20 bytes:
 11 FF 02 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

C:\>hidapitester --vidpid 046d/c08b --usagePage 0xFF00 --usage 2 --open -l 20 --send-output 0x11,0xff,2,0x3f,0,1,0xff --read-input-report 17
Opening device, vid/pid:0x046D/0xC08B, usagePage/usage: FF00/2
Device opened
Writing output report of 20-bytes...wrote 20 bytes:
 11 FF 02 3F 00 01 FF 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 20-byte input report using hid_get_input_report, report_id 17...read 20 bytes:
 11 FF 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Closing device

In Windows, each usagepage/usage is assigned as a separated device and I can use hid_read, but in Linux several usagepage/usage are all under same /dev/hidraw1, read-input reads 0 bytes and read-input-report returns same wrong data as in Windows.

# ./hidapitester  --vidpid 046d/c08b --usagePage 0xFF00 --usage 2 --open --get-report-descriptor
Opening device, vid/pid:0x046D/0xC08B, usagePage/usage: FF00/2
Device opened
Report Descriptor:
 05 01 09 06 A1 01 85 01 05 07 19 E0 29 E7 15 00 25 01 75 01 95 08 81 02 81 03 95 06 75 08 15 00
 26 A4 00 19 00 2A A4 00 81 00 C0 05 0C 09 01 A1 01 85 03 75 10 95 02 15 01 26 8C 02 19 01 2A 8C
 02 81 00 C0 05 01 09 80 A1 01 85 04 75 02 95 01 15 01 25 03 09 82 09 81 09 83 81 60 75 06 81 03
 C0 06 00 FF 09 01 A1 01 85 10 75 08 95 06 15 00 26 FF 00 09 01 81 00 09 01 91 00 C0 06 00 FF 09
 02 A1 01 85 11 75 08 95 13 15 00 26 FF 00 09 02 81 00 09 02 91 00 C0

# ./hidapitester  --vidpid 046d/c08b --usagePage 0xFF00 --usage 2 --open -l 20 --send-output 0x11,0xff,2,0x3f,0,1,0xff --read-input
Opening device, vid/pid:0x046D/0xC08B, usagePage/usage: FF00/2
Device opened
Writing output report of 20-bytes...wrote 20 bytes:
 11 FF 02 3F 00 01 FF 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading up to 20-byte input report, 250 msec timeout...read 0 bytes:
Closing device

# ./hidapitester  --vidpid 046d/c08b --usagePage 0xFF00 --usage 2 --open -l 20 --send-output 0x11,0xff,2,0x3f,0,1,0xff --read-input-report 0x11
Opening device, vid/pid:0x046D/0xC08B, usagePage/usage: FF00/2
Device opened
Writing output report of 20-bytes...wrote 20 bytes:
 11 FF 02 3F 00 01 FF 00 00 00 00 00 00 00 00 00 00 00 00 00
Reading 20-byte input report using hid_get_input_report, report_id 17...read 20 bytes:
 11 FF 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

So how to read data from report id 0x11 in Linux? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionInformation is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions