Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing a report descriptor spams me with warnings #9

Open
whot opened this issue Dec 16, 2021 · 2 comments
Open

Parsing a report descriptor spams me with warnings #9

whot opened this issue Dec 16, 2021 · 2 comments

Comments

@whot
Copy link

whot commented Dec 16, 2021

hid_parser is incredibly spammy for the Roccat Kone XTD

import hid_parser

with open("/sys/class/hidraw/hidraw0/device/report_descriptor", "rb") as fd:
    bs = fd.read()
hid_parser.ReportDescriptor(bs)

Yields a lot of warnings like this:

/home/whot/.local/lib/python3.10/site-packages/hid_parser/__init__.py:373: HIDComplianceWarning: Usage(page=Consumer, usage=Consumer Control) has no compatible usage types with an array item

While I understand that this may be an issue for the parser (didn't check the actual conformity), it makes it hard to use hid_parser as library - if this was normal logging I could filter it more easily. I tried to filter the warnings with no success so far. Using warnings for this particular issue seems excessive anyway, afaict they're intended for more system-level issues. Then again, never had to deal with them before, so I'm not exactly the expert here.

Report descriptor as printed by hidtools' hid-recorder:

# ROCCAT ROCCAT Kone XTD
# 0x05, 0x01,                    // Usage Page (Generic Desktop)        0
# 0x09, 0x02,                    // Usage (Mouse)                       2
# 0xa1, 0x01,                    // Collection (Application)            4
# 0x85, 0x01,                    //  Report ID (1)                      6
# 0x09, 0x01,                    //  Usage (Pointer)                    8
# 0xa1, 0x00,                    //  Collection (Physical)              10
# 0x05, 0x09,                    //   Usage Page (Button)               12
# 0x19, 0x01,                    //   Usage Minimum (1)                 14
# 0x29, 0x05,                    //   Usage Maximum (5)                 16
# 0x15, 0x00,                    //   Logical Minimum (0)               18
# 0x25, 0x01,                    //   Logical Maximum (1)               20
# 0x95, 0x05,                    //   Report Count (5)                  22
# 0x75, 0x01,                    //   Report Size (1)                   24
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              26
# 0x75, 0x03,                    //   Report Size (3)                   28
# 0x95, 0x01,                    //   Report Count (1)                  30
# 0x81, 0x03,                    //   Input (Cnst,Var,Abs)              32
# 0x05, 0x01,                    //   Usage Page (Generic Desktop)      34
# 0x09, 0x30,                    //   Usage (X)                         36
# 0x09, 0x31,                    //   Usage (Y)                         38
# 0x16, 0x00, 0x80,              //   Logical Minimum (-32768)          40
# 0x26, 0xff, 0x7f,              //   Logical Maximum (32767)           43
# 0x95, 0x02,                    //   Report Count (2)                  46
# 0x75, 0x10,                    //   Report Size (16)                  48
# 0x81, 0x06,                    //   Input (Data,Var,Rel)              50
# 0x09, 0x38,                    //   Usage (Wheel)                     52
# 0x15, 0x81,                    //   Logical Minimum (-127)            54
# 0x25, 0x7f,                    //   Logical Maximum (127)             56
# 0x75, 0x08,                    //   Report Size (8)                   58
# 0x95, 0x01,                    //   Report Count (1)                  60
# 0x81, 0x06,                    //   Input (Data,Var,Rel)              62
# 0x05, 0x0c,                    //   Usage Page (Consumer Devices)     64
# 0x0a, 0x38, 0x02,              //   Usage (AC Pan)                    66
# 0x81, 0x06,                    //   Input (Data,Var,Rel)              69
# 0xc0,                          //  End Collection                     71
# 0xc0,                          // End Collection                      72
# 0x05, 0x0c,                    // Usage Page (Consumer Devices)       73
# 0x09, 0x01,                    // Usage (Consumer Control)            75
# 0xa1, 0x01,                    // Collection (Application)            77
# 0x85, 0x02,                    //  Report ID (2)                      79
# 0x19, 0x00,                    //  Usage Minimum (0)                  81
# 0x2a, 0x3c, 0x02,              //  Usage Maximum (572)                83
# 0x15, 0x00,                    //  Logical Minimum (0)                86
# 0x26, 0x3c, 0x02,              //  Logical Maximum (572)              88
# 0x95, 0x01,                    //  Report Count (1)                   91
# 0x75, 0x10,                    //  Report Size (16)                   93
# 0x81, 0x00,                    //  Input (Data,Arr,Abs)               95
# 0xc0,                          // End Collection                      97
# 0x05, 0x0a,                    // Usage Page (Ordinals)               98
# 0x09, 0x00,                    // Usage (Unused)                      100
# 0xa1, 0x01,                    // Collection (Application)            102
# 0x85, 0x03,                    //  Report ID (3)                      104
# 0x19, 0x00,                    //  Usage Minimum (0)                  106
# 0x29, 0x00,                    //  Usage Maximum (0)                  108
# 0x15, 0x00,                    //  Logical Minimum (0)                110
# 0x25, 0x00,                    //  Logical Maximum (0)                112
# 0x95, 0x04,                    //  Report Count (4)                   114
# 0x75, 0x08,                    //  Report Size (8)                    116
# 0x81, 0x00,                    //  Input (Data,Arr,Abs)               118
# 0xc0,                          // End Collection                      120
# 0x05, 0x0b,                    // Usage Page (Telephony Devices)      121
# 0x09, 0x00,                    // Usage (Unassigned)                  123
# 0xa1, 0x01,                    // Collection (Application)            125
# 0x85, 0x04,                    //  Report ID (4)                      127
# 0x19, 0x00,                    //  Usage Minimum (0)                  129
# 0x29, 0x00,                    //  Usage Maximum (0)                  131
# 0x15, 0x00,                    //  Logical Minimum (0)                133
# 0x25, 0x00,                    //  Logical Maximum (0)                135
# 0x95, 0x02,                    //  Report Count (2)                   137
# 0x75, 0x08,                    //  Report Size (8)                    139
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             141
# 0x85, 0x05,                    //  Report ID (5)                      143
# 0x95, 0x02,                    //  Report Count (2)                   145
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             147
# 0x85, 0x06,                    //  Report ID (6)                      149
# 0x95, 0x2a,                    //  Report Count (42)                  151
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             153
# 0x85, 0x07,                    //  Report ID (7)                      155
# 0x95, 0x4c,                    //  Report Count (76)                  157
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             159
# 0x85, 0x08,                    //  Report ID (8)                      161
# 0x96, 0x21, 0x08,              //  Report Count (2081)                163
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             166
# 0x85, 0x09,                    //  Report ID (9)                      168
# 0x95, 0x05,                    //  Report Count (5)                   170
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             172
# 0x85, 0x0a,                    //  Report ID (10)                     174
# 0x95, 0x07,                    //  Report Count (7)                   176
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             178
# 0x85, 0x0c,                    //  Report ID (12)                     180
# 0x95, 0x03,                    //  Report Count (3)                   182
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             184
# 0x85, 0x0d,                    //  Report ID (13)                     186
# 0x96, 0x03, 0x04,              //  Report Count (1027)                188
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             191
# 0x85, 0x0e,                    //  Report ID (14)                     193
# 0x95, 0x02,                    //  Report Count (2)                   195
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             197
# 0x85, 0x0f,                    //  Report ID (15)                     199
# 0x95, 0x05,                    //  Report Count (5)                   201
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             203
# 0x85, 0x10,                    //  Report ID (16)                     205
# 0x95, 0x0f,                    //  Report Count (15)                  207
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             209
# 0x85, 0x1a,                    //  Report ID (26)                     211
# 0x96, 0x04, 0x04,              //  Report Count (1028)                213
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             216
# 0x85, 0x1b,                    //  Report ID (27)                     218
# 0x96, 0x01, 0x04,              //  Report Count (1025)                220
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             223
# 0x85, 0x1c,                    //  Report ID (28)                     225
# 0x95, 0x02,                    //  Report Count (2)                   227
# 0xb1, 0x01,                    //  Feature (Cnst,Arr,Abs)             229
# 0xc0,                          // End Collection                      231
# 
R: 232 05 01 09 02 a1 01 85 01 09 01 a1 00 05 09 19 01 29 05 15 00 25 01 95 05 75 01 81 02 75 03 95 01 81 03 05 01 09 30 09 31 16 00 80 26 ff 7f 95 02 75 10 81 06 09 38 15 81 25 7f 75 08 95 01 81 06 05 0c 0a 38 02 81 06 c0 c0 05 0c 09 01 a1 01 85 02 19 00 2a 3c 02 15 00 26 3c 02 95 01 75 10 81 00 c0 05 0a 09 00 a1 01 85 03 19 00 29 00 15 00 25 00 95 04 75 08 81 00 c0 05 0b 09 00 a1 01 85 04 19 00 29 00 15 00 25 00 95 02 75 08 b1 01 85 05 95 02 b1 01 85 06 95 2a b1 01 85 07 95 4c b1 01 85 08 96 21 08 b1 01 85 09 95 05 b1 01 85 0a 95 07 b1 01 85 0c 95 03 b1 01 85 0d 96 03 04 b1 01 85 0e 95 02 b1 01 85 0f 95 05 b1 01 85 10 95 0f b1 01 85 1a 96 04 04 b1 01 85 1b 96 01 04 b1 01 85 1c 95 02 b1 01 c0
@pfps
Copy link

pfps commented Oct 9, 2022

I also saw a lot of warnings.

I used

            with warnings.catch_warnings():
                warnings.simplefilter("ignore")
                rd = hid_parser.ReportDescriptor(fd.read())

to ignore them.

@tlyu
Copy link

tlyu commented Jan 4, 2024

I agree that this is an inappropriate quantity of warnings, especially for the common use cases of validating descriptor syntax and printing the human-readable version of the parsed descriptor.

There might be a use for an additional conformance checker. I also think that report field attributes (DV, OOC, etc.) being inconsistent with the usage type (Sel) are somewhat common, and don't deserve warning about at default levels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants