[libhid-discuss] setting output problems

Hans-Christoph Steiner hans at eds.org
Sat May 3 17:18:13 UTC 2008


On May 3, 2008, at 4:58 PM, Charles Lepple wrote:

> On May 3, 2008, at 9:05 AM, Hans-Christoph Steiner wrote:
>
>> Here's hid_set_output_report():
>>
>>    TRACE: hid_set_output_report(): looking up report ID...
>>    TRACE: hid_prepare_parse_path(): preparing search path of depth 2
>> for parse tree of USB device 004/003-0925-1299-00-00[0]...
>>    TRACE: hid_prepare_parse_path(): search path prepared for parse
>> tree of USB device 004/003-0925-1299-00-00[0].
>>   NOTICE: hid_find_object(): found requested item.
>>    TRACE: hid_set_output_report(): sending report ID 0x00 (length: 2)
>> to USB device 004/003-0925-1299-00-00[0]...
>> usb_control_msg: 33 9 512 0 0xbffff140 2 10000
>>   NOTICE: hid_set_output_report(): successfully sent report to USB
>> device 004/003-0925-1299-00-00[0].
>> wrote 0 0
>
> Not sure why this doesn't work, but if the device firmware doesn't
> signal an error, then there's not much that libhid can do.
>
> I'll have to check and see if we can provide a little more debug
> output there. Are you using the SVN trunk of libhid?
>
>> Here's the error I get for hid_interrupt_write():
>>
>> [usbhid] write failed with return code 21: HID_RET_FAIL_GET_REPORT
>
> Hmm, that error code is misleading.
>
>> wrote 1 1
>>    TRACE: hid_interrupt_write(): writing interrupt report to device
>> 004/003-0925-1299-00-00[0] ...
>> libusb/darwin.c ep_to_pipeRef: Converting ep address to pipeRef.
>> libusb/darwin.c ep_to_pipeRef: No pipeRef found with endpoint address
>> 0x01.
>> USB error: libusb/darwin.c usb_bulk_transfer: Invalid pipe reference
>> USB error: usb_bulk_write: An error occured during write (see
>> messages above)
>
> That error message is coming from libusb - it can't seem to find the
> "interrupt out" endpoint. (Strange, since it does seem to be defined
> after endpoint 0x01.)
>
> What version of libusb are you using?
>
> I don't know offhand if the USB spec mandates that the endpoint
> descriptors be in ascending order (that is, output before input since
> the output address is 0x01, and input is 0x81) but if you have
> control over the firmware, that's something you could try.

Ok, I got something more concrete working, this time instead with a  
Logitech iFeel mouse.  It works fine with hid_set_output_report(),  
but I can't seem to get it working with hid_interrupt_write().  I get  
the same error as above.  I am using libhid 0.2.16 and libusb 0.1.12  
on Mac OS X 10.4.11/Intel.  I tried hid_interrupt_write() using 7  
bytes and 8 bytes, since the Max Packet Size says 8.  7 bytes of data  
worked with hid_set_output_report().  Here's the code for the iFeel  
(in test_libhid.c):

int path[] ={0x00010002, 0x00000000, 0xff000002}; // iFeel
unsigned int const depth = 3;  // number of 32bit chunks in the path
unsigned char const SEND_PACKET_LEN = 8; // number of bytes in packet
char PACKET[] = {0x11, 0x0a, 0xff, 0x0f, 0x00, 0xff, 0x00, 0x00}; //  
the data to write
unsigned int const timeout = 1000;
int i;

     ret = hid_set_output_report(hid, path, depth, PACKET,  
SEND_PACKET_LEN);
//    ret = hid_interrupt_write(hid, 0x01, PACKET, SEND_PACKET_LEN,  
timeout);
     if (ret != HID_RET_SUCCESS) {
         fprintf(stderr, "[usbhid] write failed with return code %d: % 
s\n", ret,
                 hid_return_string(ret));
     }

     ret = hid_close(hid);
     if (ret != HID_RET_SUCCESS) {
         fprintf(stderr, "hid_close failed with return code %d\n", ret);
         return 1;
     }

     hid_delete_HIDInterface(&hid);

     ret = hid_cleanup();
     if (ret != HID_RET_SUCCESS) {
         fprintf(stderr, "hid_cleanup failed with return code %d\n",  
ret);
         return 1;
     }

     return 0;




And here's the USB Prober output for that device:



Low Speed device @ 2  
(0x1D100000): .............................................    
Composite device: "iFeel Mouse   "
     Device Descriptor
         Descriptor Version Number:   0x0100
         Device Class:   0   (Composite)
         Device Subclass:   0
         Device Protocol:   0
         Device MaxPacketSize:   8
         Device VendorID/ProductID:   0x046D/0xC030   (Logitech Inc.)
         Device Version Number:   0x0101
         Number of Configurations:   1
         Manufacturer String:   4 "Logitech Inc."
         Product String:   32 "iFeel Mouse   "
         Serial Number String:   0 (none)
     Configuration Descriptor
         Length (and contents):   41
             Raw Descriptor (hex)    0000: 09 02 29 00 01 01 00 A0   
FA 09 04 00 00 02 03 01
             Raw Descriptor (hex)    0010: 02 00 09 21 00 01 21 01   
22 4A 00 07 05 81 03 08
             Raw Descriptor (hex)    0020: 00 0A 07 05 01 03 08 00  0A
         Number of Interfaces:   1
         Configuration Value:   1
         Attributes:   0xA0 (bus-powered, remote wakeup)
         MaxPower:   500 ma
         Interface #0 - HID/Boot Interface
             Alternate Setting   0
             Number of Endpoints   2
             Interface Class:   3   (HID)
             Interface Subclass;   1   (Boot Interface)
             Interface Protocol:   2
             HID Descriptor
                 Descriptor Version Number:   0x0100
                 Country Code:   33
                 Descriptor Count:   1
                 Descriptor 1
                     Type:   0x22  (Report Descriptor)
                     Length (and contents):   74
                         Raw Descriptor (hex)    0000: 05 01 09 02 A1  
01 A1 02  05 09 19 01 29 03 15 00
                         Raw Descriptor (hex)    0010: 25 01 75 01 95  
03 81 02  95 05 06 00 FF 09 01 81
                         Raw Descriptor (hex)    0020: 02 05 01 09 01  
A1 00 15  81 25 7F 75 08 95 02 09
                         Raw Descriptor (hex)    0030: 30 09 31 81 06  
C0 09 38  95 01 81 06 C0 A1 02 06
                         Raw Descriptor (hex)    0040: 00 FF 09 02 95  
07 91 02  C0 C0
                     Parsed Report Descriptor:
                           Usage Page    (Generic Desktop)
                           Usage (Mouse)
                               Collection (Application)
                                     Collection (Logical)
                                       Usage Page    (Button)
                                       Usage Minimum...........    (1)
                                       Usage Maximum...........    (3)
                                       Logical Minimum.........    (0)
                                       Logical Maximum.........    (1)
                                       Report Size.............    (1)
                                       Report Count............    (3)
                                       Input...................    
(Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null  
Position, Bitfield)
                                       Report Count............    (5)
                                       Usage Page    (65280)
                                       Usage 1 (0x1)
                                       Input...................    
(Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null  
Position, Bitfield)
                                       Usage Page    (Generic Desktop)
                                       Usage (Pointer)
                                           Collection (Physical)
                                             Logical  
Minimum.........    (-127)
                                             Logical  
Maximum.........    (127)
                                             Report  
Size.............    (8)
                                             Report  
Count............    (2)
                                             Usage (X)
                                             Usage (Y)
                                              
Input...................   (Data, Variable, Relative, No Wrap,  
Linear, Preferred State, No Null Position, Bitfield)
                                           End Collection
                                       Usage (Wheel)
                                       Report Count............    (1)
                                       Input...................    
(Data, Variable, Relative, No Wrap, Linear, Preferred State, No Null  
Position, Bitfield)
                                     End Collection
                                     Collection (Logical)
                                       Usage Page    (65280)
                                       Usage 2 (0x2)
                                       Report Count............    (7)
                                       Output..................    
(Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null  
Position, Nonvolatile, Bitfield)
                                     End Collection
                               End Collection
             Endpoint 0x81 - Interrupt Input
                 Address:   0x81  (IN)
                 Attributes:   0x03  (Interrupt no synchronization  
data endpoint)
                 Max Packet Size:   8
                 Polling Interval:   10 ms
             Endpoint 0x01 - Interrupt Output
                 Address:   0x01  (OUT)
                 Attributes:   0x03  (Interrupt no synchronization  
data endpoint)
                 Max Packet Size:   8
                 Polling Interval:   10 ms


.hc


------------------------------------------------------------------------ 
----

News is what people want to keep hidden and everything else is  
publicity.          - Bill Moyers





More information about the libhid-discuss mailing list