|
From: Alan S. <st...@ro...> - 2010-07-20 19:51:27
|
On Tue, 20 Jul 2010, Nikolai Kondrashov wrote: > On 07/20/2010 11:05 PM, Alan Stern wrote: > > Don't use a _large_ buffer -- use a buffer that is the maxpacket size. > Aha. I will. Although it seems I already did, but I did try a lot and may be > wrong :) > > > Of course, the problem is that you generally won't know when a report > > is finished. Fortunately it looks like you don't really care, so long > > as all the data can be dumped. > Well, I'm not sure if I care or not. I should consider the kernel behavior. > If it uses only the report descriptor to determine the size of the reports > then it should be alright. OTOH, if the device breaks the HID protocol and > terminates the reports incorrectly will it ever work? Probably not. In fact, it probably won't even work under Windows. > Also, the HID specification says the following among other report > constraints: > ... > All reports except the longest which exceed wMaxPacketSize for the > endpoint must terminate with a short packet. The longest report > does not > require a short packet terminator. > ... > If there are multiple reports in a top level collection then all > reports, except the longest, must terminate with a short packet. > ... > > - http://www.usb.org/developers/devclass_docs/HID1_11.pdf > HID spec, 8.4 Report constraints, page 67 (57). > > Does it mean that if there is only one report (i.e. no report IDs in the > descriptor) or the report being sent is the longest one the terminating > short packet is not necessary? That's right. > So if the device sends only one report which is exactly wMaxPacketSize > (which, I guess, is typically the case for mice) there will be no short > packets. Am I right? Yes. > I should just capture a trace and check it, I guess :) Good idea. Alan Stern |