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

Needs better error reporting #11

Open
hadess opened this issue May 29, 2016 · 9 comments
Open

Needs better error reporting #11

hadess opened this issue May 29, 2016 · 9 comments

Comments

@hadess
Copy link

hadess commented May 29, 2016

$ sudo cat /sys/kernel/debug/hid/0005:3820:0009.0008/rdesc | head -n1 | xxd -r -p | jhbuild run hidrd-convert -i natv -o xml
Failed to read input item at offset 86:
invalid item encountered

Not much that I can do with that though. I'll try adding some better error reporting in lib/item/any.c, see where it fails.

@hadess
Copy link
Author

hadess commented May 29, 2016

The output of head -n1 in the above command:
8bitdo-native.txt

@spbnick
Copy link
Member

spbnick commented May 29, 2016

Hi hadess, which version of hidrd are you using?

@hadess
Copy link
Author

hadess commented May 29, 2016

That was with git master and the attached file.

@hadess
Copy link
Author

hadess commented May 30, 2016

main_tag = hidrd_item_main_get_tag(item);

It failed with "main_tag = 0"

Not sure if that means it couldn't parse the main tag, or some other failure.

@hadess
Copy link
Author

hadess commented May 30, 2016

I'll note that the above rdesc was parsed by the Linux kernel without a problem, so it's very likely to be a valid descriptor.

@hadess
Copy link
Author

hadess commented May 30, 2016

http://eleccelerator.com/usbdescreqparser/ parses the above descriptor as:

0x05, 0x01,        // Usage Page (Generic Desktop Ctrls)
0x09, 0x05,        // Usage (Game Pad)
0xA1, 0x01,        // Collection (Application)
0x85, 0x03,        //   Report ID (3)
0x05, 0x01,        //   Usage Page (Generic Desktop Ctrls)
0x15, 0x00,        //   Logical Minimum (0)
0x25, 0x07,        //   Logical Maximum (7)
0x46, 0x3B, 0x01,  //   Physical Maximum (315)
0x95, 0x01,        //   Report Count (1)
0x75, 0x04,        //   Report Size (4)
0x65, 0x14,        //   Unit (System: English Rotation, Length: Centimeter)
0x09, 0x39,        //   Usage (Hat switch)
0x81, 0x42,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,Null State)
0x75, 0x01,        //   Report Size (1)
0x95, 0x04,        //   Report Count (4)
0x81, 0x01,        //   Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x09, 0x30,        //   Usage (X)
0x09, 0x31,        //   Usage (Y)
0x09, 0x32,        //   Usage (Z)
0x09, 0x35,        //   Usage (Rz)
0x95, 0x04,        //   Report Count (4)
0x75, 0x08,        //   Report Size (8)
0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x05, 0x02,        //   Usage Page (Sim Ctrls)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x09, 0xC4,        //   Usage (Accelerator)
0x09, 0xC5,        //   Usage (Brake)
0x95, 0x02,        //   Report Count (2)
0x75, 0x08,        //   Report Size (8)
0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x05, 0x09,        //   Usage Page (Button)
0x19, 0x01,        //   Usage Minimum (0x01)
0x29, 0x10,        //   Usage Maximum (0x10)
0x15, 0x00,        //   Logical Minimum (0)
0x25, 0x01,        //   Logical Maximum (1)
0x75, 0x01,        //   Report Size (1)
0x95, 0x10,        //   Report Count (16)
0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0,              // End Collection
0x00,              // Unknown (bTag: 0x00, bType: 0x00)

// 87 bytes

And removing the trailing "00" fixes the parsing by hidrd. That's where the 0 was coming from :)

@spbnick
Copy link
Member

spbnick commented May 31, 2016

Thank you for the investigation, @hadess
Indeed, a descriptor with trailing zero would be an invalid descriptor.
However, hidrd needs to be modified to be more resilient and to produce better error messages.
I personally don't have much time for that at the moment, but I would of course welcome patches working towards that.

@hadess
Copy link
Author

hadess commented May 31, 2016

Doesn't seem to bother Windows, Linux, iOS or Android, FWIW.

@spbnick
Copy link
Member

spbnick commented May 31, 2016

@hadess Yes, that's why hidrd needs to be improved. Nevertheless the descriptor is invalid.

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

No branches or pull requests

2 participants