PORTS Forum
Ports and Interfaces => USB => Topic started by: grantb5 on June 06, 2013, 12:25:31 pm
-
I have a Descriptor that I've used in a device for some years and just recently ran the old USBCheck (HIDView) and noticed an error:
- Report Descriptor (OS) Passed
- Report Descriptor (TParse) *FAILED* Errors: 2, Warnings: 0
The device is a keyboard (emulator) that should support the entire range of key codes, plus a feature report that I use to send data back to the device. When I look at the detailed parse for the area in question, I get (transcribed from the screen as there is no way to copy it):
:
95 06 Report Count 6
75 08 Report Size 8
15 00 Logical Minimum 0
25 93 Logical Maximum 93h (-109d)
05 07 Usage Page Keyboard
19 00 Usage Minimum Reserved (no event indicated)
29 93 Usage Maximum Keyboard LANG4
81 00 Input Error: Logical Minimum MUST be less than Logical Maximum
09 03 Usage Keyboard ErrorUndefine
75 08 Report Size 8
95 05 Report Count 5
B1 02 Feature (Variable) Error: Logical Minimum MUST be less than Logical Maximum
C0 End Collection
So I played with the Descriptor Tool a bit (struggled more like it). And I figured that maybe since there aren't really any key codes below Aa that I should change the minimum from 0 to 4. Now at the same time, the descriptor tool did not like how I implemented the LANG4 maximum, so it changed my 25 93 into 26 93 00. The report now becomes:
:
95 06 Report Count 6
75 08 Report Size 8
15 00 Logical Minimum 0
26 93 00 Logical Maximum 93h (147d)
05 07 Usage Page Keyboard
19 04 Usage Minimum Keyboard a and A
29 93 Usage Maximum Keyboard LANG4
81 00 Input
09 03 Usage Keyboard ErrorUndefine
75 08 Report Size 8
95 05 Report Count 5
B1 02 Feature (Variable)
C0 End Collection
The error codes go away and the device still appears to work, barring an exhaustive test. The usage near the end "Keyboard ErrorUndefine" I think is supposed to be Usage "Vendor Defined"??? That's what I'm after anyway. So do these changes make sense or am I dooming myself in a different way now!?
GB
PS. BTW I have yet to get the newer Command Verifier to operate for me, but will keep working on it.
-
Well changing the Usage Minimum messes things up. With the Usage Minimum at 04 and the Logical Minimum at 00 all my key codes are offset. I tried changing the Logical Minimum also to 4 and that also messes things up, so I put the Usage Min back to 0 and the device works. This does not seem to affect the USB test results, so I will leave both Min's at zero.
Anyway, on to the Logical Max, things seem to work OK using 26 93 00 instead of 25 93 but I have to do additional tests. I'm guessing this difference distinguishes the value as (signed?) word vs byte ... as per "Device Class Definition for Human Interface Devices (HID) Version 1.11".
But what of the Usage Maximum 29 93 -- I suppose I could also use the two-byte version 2A 93 00?
-
Yes, 26 93 00 keeps the value from being considered a negative number. Try the same with the other value.
-
Hi grantb5,
Well changing the Usage Minimum messes things up. With the Usage Minimum at 04 and the Logical Minimum at 00 all my key codes are offset.
I have an impression, when you know about Input(Array) well, your problem will be sorted out.
For Input(Array), you have to put indices on the set of Usages, not the "keycode" (Usage) directly.
A set of Usages is defined before the Input(Array), using a couple of Usage, Usage Min/Max.
The first defined Usage (or Usage Min) is assigned to index 0.
Here is a numeric keypad example on the HID 1.11 spec (UID1_11.pdf, p76)
Usage Page (Generic Desktop),
Usage (Keyboard),
Report Count (0),
Collection (Application),
Usage Page(Key Codes), Definition of a set of Usages
Usage(0), ; key null <--- index 0
Usage Minimum(53h), <--- index 1 -
Usage Maximum(63h), <--- index 17
Logical Minimum (0), <--- logical min/max corresponds to the range of indices (0-17)
Logical Maximum (17),
Report Size (8),
Report Count (3)
Input (Data, Array), <--- The input report returns an array of indices
End Collection
Another point is, the set of Usages usually starts with Usage(0) - key null, so that the key (index) array on the input report is filled with 0, while no key is pressed.
The report descriptors of most of keyboard examples start with Usage Minimum(0). In this case, the indices match to the keycode (Usage). It may mislead many ones.
Tsuneo