• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

Getting details of HID device can fail.

Started by bflorac, March 22, 2015, 01:29:45 am

Previous topic - Next topic

bflorac

When calling TnrHid.LoadDeviceCapabilities, it can be called with full mode to extract more details for ProductString, ManufacturerString and SerialNumberString. In doing so, it calls function HidD_GetCommonString() which uses the HID.DLL library make calls to the device to extract this info via GET_DESCRIPTOR requests.  However, HidD_GetCommonString allocates a string of 256 bytes. This should be no longer than 128 characters. According MS documentation :

The maximum possible number of characters in an embedded string is device specific. For USB devices, the maximum string length is 126 wide characters (not including the terminating NULL character).

This seems like a odd bug but I have seen USB devices that will either return nothing or a malformed packet if set too long. Off course, this is more like a bug in the device as it should handle this properly. On the otherhand, it is safer code to just not ask for more than could possibly be needed.

Roman Novgorodov

Hello William

Thank you for detailed info.

We have checked msdn and reviewed some development forums.
It seems like your are right.

Next release will include fix for this issue.

Thank you.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Roman Novgorodov

March 22, 2015, 03:29:01 pm #2 Last Edit: March 22, 2015, 03:31:20 pm by Roman Novgorodov
From other side MSDN describes param as:

BufferLength [in]
    Specifies the length, in bytes, of a caller-allocated buffer provided at Buffer....

This means that 126 length of wide string has 252 length in bytes ...

We will check more .

Roman
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

bflorac

Just to confirm, I changed the value from 256 to 252 and it seems to now work for the HID device I'm working with.

Roman Novgorodov

Hello

Great!
We've already changed length from 255 to 252 in sources. But not tested with problem devices.
Thank you for feedback.

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.