Generic HID example with LibUsb

1,288 views
Skip to first unread message

marko...@gmail.com

unread,
Nov 7, 2014, 3:39:48 AM11/7/14
to lufa-s...@googlegroups.com
Hi,

i want to test Generic HID example with LibUsb java version. Control transfer looks like :

LibUsb.controlTransfer(handle, (byte)0x21, (byte)0x01, (short)0, (short)0, buffer, 1000).

0x21 = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)
0x01 = HID_REQ_GetReport

Program is giving me the exception that parameters are invalid.

What proper values do I need to put for requestType, request, wValue and vIndex to put it to work ?



Thanks in advance.


Dean Camera

unread,
Nov 8, 2014, 5:18:10 AM11/8/14
to lufa-s...@googlegroups.com
Marko,

Without having an identical setup I can't say for sure what your issue is caused by (presumably you are correctly obtaining a handle to your USB device, opening it and performing any other required libUSB setup) but one thing I can see is the wValue entry. A wValue of zero is not valid for the HID GetReport request.

From the USB HID Class Specification:
"The wValue field specifies the Report Type in the high byte and the Report ID in the low byte. Set Report ID to 0 (zero) if Report IDs are not used. Report Type is specified as follows:
Value  Report Type
01  Input
02  Output
03  Feature
04-FF  Reserved"

So you should specify in the upper 8-bits of wValue what type of report you are asking for, and the report ID in the lower 8 bits. You should obtain the HID report descriptor beforehand to determine what the report structure of your device looks like, and what report IDs are valid for it.

Another possible error source is "buffer" - is it the correct length to fit the report response?

Cheers!
- Dean
--
You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lufa-support...@googlegroups.com.
To post to this group, send email to lufa-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/lufa-support.
For more options, visit https://groups.google.com/d/optout.

marko...@gmail.com

unread,
Nov 9, 2014, 11:40:07 AM11/9/14
to lufa-s...@googlegroups.com
Now i'm testing with following command :


LibUsb.controlTransfer(handle, (byte)0x21, (byte)0x09, (short)0, (short)0, buffer, 1000)

is this ok for sending report from host to device ? Buffer in this case is 8 bytes. If i go in debug handle and init of device if ok, but after this command i'm getting "invalid parameter exception". Can you
help me calculate which numbers to put for wValue and wIndex in this case ?

Thanks in advance.

marko...@gmail.com

unread,
Nov 10, 2014, 8:25:49 AM11/10/14
to lufa-s...@googlegroups.com
And i'm testing with this code on my microcontroller

lufa-LUFA-140928\Demos\Device\LowLevel\GenericHID.

marko...@gmail.com

unread,
Nov 10, 2014, 4:19:01 PM11/10/14
to lufa-s...@googlegroups.com
Well it looks that I getting some progress :

When I put this values :

LibUsb.controlTransfer(handle, (byte) 0x21,(byte) 0x09, (short) 0x200, (short) 0x02, buffer, 1000) for setting Report, i get
different error, which says "LibUsb : Other error".

This happens only if vwalue is 0x200 or (00000010 00000000).which is reportType = 2, reportId = 0.  Is this correct ? I don't know
what to put for wIndex value. I tried to iterate it in loop from 0 to 1024 and the result is always the same (LibUsb : other error).

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages