[libhid-discuss] setting output problems
Hans-Christoph Steiner
hans at eds.org
Sat May 3 13:05:48 UTC 2008
So I've been banging away at getting output working, but no luck yet,
so I'll post more info. I have input working fine with libhid, plus
using code based on HID Utilities, I can output to this device. The
board I am using is a PIC microcontroller with a custom firmware. I
am just trying to light an LED (0x00010005.0x00010036). I've tried
both hid_set_output_report() and hid_interrupt_write(). Neither have
worked so far: hid_set_output_report() says success, but doesn't
work, and hid_interrupt_write() gives me an error:
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
Here's the error I get for hid_interrupt_write():
[usbhid] write failed with return code 21: HID_RET_FAIL_GET_REPORT
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)
WARNING: hid_interrupt_write(): failed to perform interrupt write to
device 004/003-0925-1299-00-00[0]: usb_bulk_write: An error occured
during write (see messages above)
Here's the info from the newest test_libhid:
NOTICE: hid_prepare_parser(): successfully set up the HID parser
for USB device 004/003-0925-1299-00-00[0].
NOTICE: hid_force_open(): successfully opened USB device
004/003-0925-1299-00-00[0].
device identification of HIDInterface 004/003-0925-1299-00-00[0]:
dev_handle: 0x003028a0
device: 0x01808a00
location: 004/003-0925-1299-00-00
manufacturer: Overtone
product: CUI IO v1.0
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003-0925-1299-00-00[0]...
TRACE: hid_dump_tree(): iterating the parse tree for USB device
004/003-0925-1299-00-00[0]...
parse tree of HIDInterface 004/003-0925-1299-00-00[0]:
path: 0x00010005.0x00010030; type: 0x80
path: 0x00010005.0x00010031; type: 0x80
path: 0x00010005.0x00010032; type: 0x80
path: 0x00010005.0x00010033; type: 0x80
path: 0x00010005.0x00010034; type: 0x80
path: 0x00010005.0x00010035; type: 0x80
path: 0x00010005.0x00010036; type: 0x80
path: 0x00010005.0x00010037; type: 0x80
path: 0x00010005.0x00010040; type: 0x80
path: 0x00010005.0x00010041; type: 0x80
path: 0x00010005.0x00010042; type: 0x80
path: 0x00010005.0x00010043; type: 0x80
path: 0x00010005.0x00010044; type: 0x80
path: 0x00010005.0x00010045; type: 0x80
path: 0x00010005.0x00010030; type: 0x90
path: 0x00010005.0x00010031; type: 0x90
path: 0x00010005.0x00010032; type: 0x90
path: 0x00010005.0x00010033; type: 0x90
path: 0x00010005.0x00010034; type: 0x90
path: 0x00010005.0x00010035; type: 0x90
path: 0x00010005.0x00010036; type: 0x90
path: 0x00010005.0x00010037; type: 0x90
path: 0x00010005.0x00010005; type: 0xb0
path: 0x00010005.0x00000000; type: 0xb0
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003-0925-1299-00-00[0]...
TRACE: hid_close(): closing USB device 004/003-0925-1299-00-00[0]...
Here's the code I am using to try to write (I'm now using
test_libhid.c):
int path[] = {0x00010005, 0x00010036};
unsigned int const depth = 2; // number of 32bit chunks in the path
unsigned char const SEND_PACKET_LEN = 2; // number of bytes in packet
char PACKET[SEND_PACKET_LEN]; // the data to write
unsigned int const timeout = 1000;
int i;
for(i=0; i<10; ++i) {
PACKET[0]=0x00;
PACKET[1]=0x00;
// 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));
}
printf("wrote %x %x\n", PACKET[0], PACKET[1]);
sleep(1);
PACKET[0]=0x01;
PACKET[1]=0x01;
// 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));
}
printf("wrote %x %x\n", PACKET[0], PACKET[1]);
sleep(1);
}
And here is the info from USB Prober:
Full Speed device @ 3
(0x1A200000): .............................................
Composite device: "CUI IO v1.0"
Device Descriptor
Descriptor Version Number: 0x0200
Device Class: 0 (Composite)
Device Subclass: 0
Device Protocol: 0
Device MaxPacketSize: 32
Device VendorID/ProductID: 0x0925/0x1299 (unknown vendor)
Device Version Number: 0x0001
Number of Configurations: 1
Manufacturer String: 1 "Overtone"
Product String: 2 "CUI IO v1.0"
Serial Number String: 0 (none)
Configuration Descriptor
Length (and contents): 41
Raw Descriptor (hex) 0000: 09 02 29 00 01 01 00 A0
32 09 04 00 00 02 03 00
Raw Descriptor (hex) 0010: 00 00 09 21 01 01 00 01
22 56 00 07 05 81 03 20
Raw Descriptor (hex) 0020: 00 05 07 05 01 03 20 00 05
Number of Interfaces: 1
Configuration Value: 1
Attributes: 0xA0 (bus-powered, remote wakeup)
MaxPower: 100 ma
Interface #0 - HID
Alternate Setting 0
Number of Endpoints 2
Interface Class: 3 (HID)
Interface Subclass; 0
Interface Protocol: 0
HID Descriptor
Descriptor Version Number: 0x0101
Country Code: 0
Descriptor Count: 1
Descriptor 1
Type: 0x22 (Report Descriptor)
Length (and contents): 86
Raw Descriptor (hex) 0000: 05 01 09 05 A1
01 09 30 09 31 09 32 09 33 09 34
Raw Descriptor (hex) 0010: 09 35 09 36 09
37 09 40 09 41 09 42 09 43 09 44
Raw Descriptor (hex) 0020: 09 45 15 00 26
FF 03 75 10 95 0E 81 02 09 30 09
Raw Descriptor (hex) 0030: 31 09 32 09 33
09 34 09 35 09 36 09 37 15 00 26
Raw Descriptor (hex) 0040: FF 03 75 10 95
08 91 02 09 05 15 00 26 FF 00 75
Raw Descriptor (hex) 0050: 08 95 02 B1 02 C0
Parsed Report Descriptor:
Usage Page (Generic Desktop)
Usage (GamePad)
Collection (Application)
Usage (X)
Usage (Y)
Usage (Z)
Usage (Rx)
Usage (Ry)
Usage (Rz)
Usage (Slider)
Usage (Dial)
Usage (Vx)
Usage (Vy)
Usage (Vz)
Usage (Vbrx)
Usage (Vbry)
Usage (Vbrz)
Logical Minimum......... (0)
Logical Maximum......... (1023)
Report Size............. (16)
Report Count............ (14)
Input................... (Data,
Variable, Absolute, No Wrap, Linear, Preferred State, No Null
Position, Bitfield)
Usage (X)
Usage (Y)
Usage (Z)
Usage (Rx)
Usage (Ry)
Usage (Rz)
Usage (Slider)
Usage (Dial)
Logical Minimum......... (0)
Logical Maximum......... (1023)
Report Size............. (16)
Report Count............ (8)
Output.................. (Data,
Variable, Absolute, No Wrap, Linear, Preferred State, No Null
Position, Nonvolatile, Bitfield)
Usage (GamePad)
Logical Minimum......... (0)
Logical Maximum......... (255)
Report Size............. (8)
Report Count............ (2)
Feature................. (Data,
Variable, Absolute, No Wrap, Linear, Preferred State, No Null
Position, Nonvolatile, Bitfield)
End Collection
Endpoint 0x81 - Interrupt Input
Address: 0x81 (IN)
Attributes: 0x03 (Interrupt no synchronization
data endpoint)
Max Packet Size: 32
Polling Interval: 5 ms
Endpoint 0x01 - Interrupt Output
Address: 0x01 (OUT)
Attributes: 0x03 (Interrupt no synchronization
data endpoint)
Max Packet Size: 32
Polling Interval: 5 ms
On May 2, 2008, at 7:53 PM, Hans-Christoph Steiner wrote:
>
> Hey,
>
> I am trying to get my code to output properly and having trouble.
> I was hoping someone could show me some simple example code just to
> send an output report. So here are the paths reported from libhid:
>
> path: 0x00010005.0x00010030; type: 0x90
> path: 0x00010005.0x00010031; type: 0x90
> path: 0x00010005.0x00010032; type: 0x90
> path: 0x00010005.0x00010033; type: 0x90
> path: 0x00010005.0x00010034; type: 0x90
> path: 0x00010005.0x00010035; type: 0x90
> path: 0x00010005.0x00010036; type: 0x90
> path: 0x00010005.0x00010037; type: 0x90
>
> Apple USB Prober says that they each have a Report Size of 16 and
> there is a report count of 8. Here's the code I tried, it doesn't
> give errors, it just doesn't seem to work:
>
> int path[] = {0x00010005, 0x00010030};
> unsigned int const depth = 2; // number of 32bit chunks in the path
> unsigned char const SEND_PACKET_LEN = 2; // number of bytes in packet
> char const PACKET[] = { 0x00, 0x00 }; // the data to write
> //char const PACKET[] = { 0xff, 0xff }; // the data to write
>
> if ( !hid_is_opened(x->x_hidinterface) )
> {
> printf("[usbhid] device not open, can't set data");
> return;
> }
>
> x->x_hid_return = hid_set_output_report(x->x_hidinterface,
> path, depth, PACKET,
> SEND_PACKET_LEN);
>
> .hc
>
> ----------------------------------------------------------------------
> ------
>
> You can't steal a gift. Bird gave the world his music, and if you
> can hear it, you can have it. - Dizzy Gillespie
>
>
>
------------------------------------------------------------------------
----
News is what people want to keep hidden and everything else is
publicity. - Bill Moyers
More information about the libhid-discuss
mailing list