Re: Issues with simulating a keyboard device with gadgetfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 12 Apr 2009, Aniruddha Marathe wrote:

> > Get-Device-Qualifier is sent only to USB-2.0 devices.  No doubt your
> > real keyboard is USB-1.1.
> >
> 
> Thanks for clearing that out. I am specifying the device type as USB
> 1.1. However, I see USB 2.0 type of device when I list the device on
> the host. Here are the device and hid descriptors I use for the
> device:
> 
> static struct usb_device_descriptor device_desc = {
>         .bLength =              sizeof device_desc,
>         .bDescriptorType =      1,
>         .bcdUSB =               __constant_cpu_to_le16(0x0110),
>         .bDeviceClass =         0,
>         .bDeviceSubClass =      0,
>         .bDeviceProtocol =      0,
>         .idVendor =             __constant_cpu_to_le16(KEYBOARD_VENDOR_NUM),
>         .idProduct =            __constant_cpu_to_le16(KEYBOARD_PRODUCT_NUM),
>         .bcdDevice =            0x0100,
>         .iManufacturer =        STRING_MANUFACTURER,
>         .iProduct =             STRING_PRODUCT,
>         .iSerialNumber =        STRING_SERIALNUM,
>         .bNumConfigurations =   1
> };
> 
> static struct hid_descriptor hid_config_desc = {
> 
>         .bLength = sizeof(hid_config_desc),
>         .bDescriptorType = 0x21,
>         .bcdHID = 0x0110,
>         .bCountryCode = 0,
>         .bNumDescriptors = 1,
>         .desc[0].wDescriptorLength = sizeof(ReportDescriptor),
>         .desc[0].bDescriptorType = 0x22
> };
> 
> [aniruddha@localhost ~]$ cat /proc/bus/usb/devices
> 
> T:  Bus=04 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  7 Spd=12  MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=4242 ProdID=0110 Rev= 1.00
> S:  Manufacturer=Microsoft Corporation
> S:  Product=Microsoft Natural Keyboard Pro
> C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
> I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=
> E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=3ms
> 
> I am not sure why it shows Ver= 2.00, even though I specify 1.1.

This is because the gadgetfs driver overrides the value provided by
your program; it always sets the version to 2.00.  (It also always
sets the number of configurations to 1, but I don't why, since
specifying any other number of configurations would cause it to reject
the device descriptor with an error.)

> >> Was the response
> >> to the earlier 'GET DEVICE DESCRIPTOR' request malformed (the sniffer
> >> doesn't indicate that, however)?
> >
> > I can't tell since Wireshark doesn't display the response data
> > properly.

If KEYBOARD_VENDOR_NUM is 0x4242, KEYBOARD_PRODUCT_NUM is 0x0110, and
STRING_SERIALNUM is 0, then the device descriptor was sent correctly.

However the usbmon trace shows that your program still doesn't respond
properly to Set-Configuration.  The program has to read a 0-length
message from the control file to tell the host that the request has
been carried out.  Look at what the demo usb.c program does at the end 
of the USB_REQ_SET_CONFIGURATION case in handle_control().

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux