You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"ValueError: Sub-data not available" when trying to parse vendor VariableItem #28
I am trying to reverse engineer a device with a bunch of vendor specific report formats. I think I might have found an issue in VariableItem when parsing vendor messages:
Traceback (most recent call last):
File "/home/haku/src/usbhid-experiments/./test-parse.py", line 56, in <module>
for usage, value in desc.parse_input_report(data).items():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/haku/.cache/pyvenv-hid/lib/python3.12/site-packages/hid_parser/__init__.py", line 690, in parse_input_report
return self._parse_report(self._input, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/haku/.cache/pyvenv-hid/lib/python3.12/site-packages/hid_parser/__init__.py", line 687, in _parse_report
return self._parse_report_items(item_poll[data[0]], data[1:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/haku/.cache/pyvenv-hid/lib/python3.12/site-packages/hid_parser/__init__.py", line 669, in _parse_report_items
parsed[item.usage] = item.parse(data)
^^^^^^^^^^^^^^^^
File "/home/haku/.cache/pyvenv-hid/lib/python3.12/site-packages/hid_parser/__init__.py", line 433, in parse
if hid_parser.data.UsageTypes.LINEAR_CONTROL in self.usage.usage_types or any(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/haku/.cache/pyvenv-hid/lib/python3.12/site-packages/hid_parser/__init__.py", line 237, in usage_types
usage_page = hid_parser.data.UsagePages.get_subdata(self.page)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/haku/.cache/pyvenv-hid/lib/python3.12/site-packages/hid_parser/data.py", line 159, in get_subdata
raise ValueError(msg)
ValueError: Sub-data not available
The issue appears to be that hid_parser.data.UsagePages.get_subdata(page) fails with this exception for any value of page within the VENDOR_PAGE range. While this library's test cases in test_parse.py do test parsing vendor reports, all the data types defined are arrays which have a different decode code path.
I am still learning my way around this library so not entirely sure what the fix should be, but I am happy to spend some more time figuring it out if that would be helpful for you?
Activity