<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="sans-serif">Hi<br>
<br>
I notice this list has been very quite recently, so I hope someone is
still out there?<br>
<br>
I am trying to write an interface in C so I can communicate with a PIC
chip via USB using libhid, but I do not understand how to use the path
information I am seeing to send and receive massages. <br>
<br>
This is the output I get when I run the example code that I downloaded
from the libhid site.<br>
<br>
NOTICE: hid_find_usb_device(): found a matching USB device 004/003[0].<br>
TRACE: hid_force_open(): claiming USB device 004/003[0].<br>
NOTICE: hid_force_open(): successfully claimed USB device 004/003[0].<br>
TRACE: hid_init_parser(): initialising the HID parser for USB Device
004/003[0]...<br>
TRACE: hid_init_parser(): allocating space for HIDData structure...<br>
TRACE: hid_init_parser(): successfully allocated memory for HIDData
strcture.<br>
TRACE: hid_init_parser(): allocating space for HIDParser structure...<br>
TRACE: hid_init_parser(): successfully allocated memory for HIDParser
strcture.<br>
NOTICE: hid_init_parser(): successfully initialised the HID parser for
USB Device 004/003[0].<br>
TRACE: hid_prepare_hid_descriptor(): initialising the HID descriptor
for USB device 004/003[0]...<br>
TRACE: hid_prepare_hid_descriptor(): retrieving HID descriptor for
USB device 004/003[0]...<br>
NOTICE: hid_prepare_hid_descriptor(): successfully initialised HID
descriptor for USB device 004/003[0] (29 bytes).<br>
TRACE: hid_prepare_report_descriptor(): initialising the report
descriptor for USB device 004/003[0]...<br>
TRACE: hid_prepare_report_descriptor(): retrieving report descriptor
for USB device 004/003[0]...<br>
NOTICE: hid_prepare_report_descriptor(): successfully initialised
report descriptor for USB device 004/003[0].<br>
TRACE: hid_prepare_parser(): setting up the HID parser for USB device
004/003[0]...<br>
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...<br>
TRACE: hid_prepare_parser(): dumping the raw report descriptor<br>
TRACE: hid_prepare_parser(): 0x000: 0x06 0x00 0xff 0x09 0x01 0xa1
0x01 0x19 <br>
TRACE: hid_prepare_parser(): 0x008: 0x01 0x29 0x40 0x15 0x00 0x26
0xff 0x00 <br>
TRACE: hid_prepare_parser(): 0x010: 0x75 0x08 0x95 0x40 0x81 0x00
0x19 0x01 <br>
TRACE: hid_prepare_parser(): 0x018: 0x29 0x40 0x91 0x00 0xc0 <br>
TRACE: hid_prepare_parser(): parsing the HID tree of USB device
004/003[0]...<br>
NOTICE: hid_prepare_parser(): successfully set up the HID parser for
USB device 004/003[0].<br>
NOTICE: hid_force_open(): successfully opened USB device 004/003[0].<br>
device identification of HIDInterface 004/003[0]:<br>
dev_handle: 0x00a68ea0<br>
device: 0x00a7c470<br>
location: 004/003<br>
manufacturer: Microchip Technology Inc.<br>
product: Simple HID Device Demo<br>
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...<br>
TRACE: hid_dump_tree(): iterating the parse tree for USB device
004/003[0]...<br>
parse tree of HIDInterface 004/003[0]:<br>
path: 0xff000001.0x00000000; type: 0x80<br>
{listed a total of 64 times} <br>
<br>
path: 0xff000001.0x00000000; type: 0x90<br>
</font><font face="sans-serif"> {listed a total of 64 times} </font><br>
<font face="sans-serif"><br>
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...<br>
TRACE: hid_close(): closing USB device 004/003[0]...<br>
TRACE: hid_close(): closing handle of USB device 004/003[0]...<br>
NOTICE: hid_close(): successfully closed USB device 004/003[0].<br>
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...<br>
TRACE: hid_close(): freeing memory allocated for HID parser...<br>
TRACE: hid_close(): resetting HIDInterface...<br>
NOTICE: hid_cleanup(): successfully deinitialised HID library.<br>
<br>
I have tried the following code in an attempt to read some data:<br>
<br>
unsigned char const RECV_PACKET_LEN = 64;<br>
char packet[RECV_PACKET_LEN];<br>
unsigned char const PATHLEN = 2;<br>
int const PATH_IN[2] = { 0xff000001, 0 };<br>
int i;<br>
<br>
ret = hid_get_input_report(hid, PATH_IN, PATHLEN, packet,
RECV_PACKET_LEN);<br>
if (ret != HID_RET_SUCCESS)<br>
{<br>
fprintf(stderr, "hid_get_input_report failed with return code
%d\n", ret);<br>
}<br>
else<br>
{<br>
printf("data...\n");<br>
<br>
for (i=0; i<RECV_PACKET_LEN; i++)<br>
printf("0x%02X ", (unsigned char) packet[i]);<br>
<br>
printf("\n");<br>
}<br>
<br>
But it complains of a broken pipe.....<br>
<br>
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...<br>
TRACE: hid_get_input_report(): looking up report ID...<br>
TRACE: hid_prepare_parse_path(): preparing search path of depth 2 for
parse tree of USB device 004/003[0]...<br>
TRACE: hid_prepare_parse_path(): search path prepared for parse tree
of USB device 004/003[0].<br>
NOTICE: hid_find_object(): found requested item.<br>
TRACE: hid_get_input_report(): retrieving report ID 0x00 (length: 64)
from USB device 004/003[0]...<br>
WARNING: hid_get_input_report(): failed to retrieve report from USB
device 004/003[0]:error sending control message: Broken pipe.<br>
hid_get_input_report failed with return code 20<br>
TRACE: hid_close(): closing USB device 004/003[0]...<br>
TRACE: hid_close(): closing handle of USB device 004/003[0]...<br>
NOTICE: hid_close(): successfully closed USB device 004/003[0].<br>
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...<br>
TRACE: hid_close(): freeing memory allocated for HID parser...<br>
TRACE: hid_close(): resetting HIDInterface...<br>
NOTICE: hid_cleanup(): successfully deinitialised HID library.<br>
<br>
<br>
<br>
This is the output I get from lsusb<br>
<br>
$ sudo lsusb -d 0x04d8:0x003f -vvv<br>
<br>
Bus 004 Device 003: ID 04d8:003f Microchip Technology, Inc. <br>
Device Descriptor:<br>
bLength 18<br>
bDescriptorType 1<br>
bcdUSB 2.00<br>
bDeviceClass 0 (Defined at Interface level)<br>
bDeviceSubClass 0 <br>
bDeviceProtocol 0 <br>
bMaxPacketSize0 8<br>
idVendor 0x04d8 Microchip Technology, Inc.<br>
idProduct 0x003f <br>
bcdDevice 0.02<br>
iManufacturer 1 Microchip Technology Inc.<br>
iProduct 2 Simple HID Device Demo<br>
iSerial 0 <br>
bNumConfigurations 1<br>
Configuration Descriptor:<br>
bLength 9<br>
bDescriptorType 2<br>
wTotalLength 41<br>
bNumInterfaces 1<br>
bConfigurationValue 1<br>
iConfiguration 0 <br>
bmAttributes 0xc0<br>
Self Powered<br>
MaxPower 100mA<br>
Interface Descriptor:<br>
bLength 9<br>
bDescriptorType 4<br>
bInterfaceNumber 0<br>
bAlternateSetting 0<br>
bNumEndpoints 2<br>
bInterfaceClass 3 Human Interface Device<br>
bInterfaceSubClass 0 No Subclass<br>
bInterfaceProtocol 0 None<br>
iInterface 0 <br>
** UNRECOGNIZED: 09 21 11 01 00 01 22 1d 00<br>
Endpoint Descriptor:<br>
bLength 7<br>
bDescriptorType 5<br>
bEndpointAddress 0x81 EP 1 IN<br>
bmAttributes 3<br>
Transfer Type Interrupt<br>
Synch Type None<br>
Usage Type Data<br>
wMaxPacketSize 0x0040 1x 64 bytes<br>
bInterval 1<br>
Endpoint Descriptor:<br>
bLength 7<br>
bDescriptorType 5<br>
bEndpointAddress 0x01 EP 1 OUT<br>
bmAttributes 3<br>
Transfer Type Interrupt<br>
Synch Type None<br>
Usage Type Data<br>
wMaxPacketSize 0x0040 1x 64 bytes<br>
bInterval 1<br>
Device Status: 0x0001<br>
Self Powered<br>
<br>
<br>
Can someone give me some pointers as I am a little stuck.<br>
<br>
Thanks<br>
<br>
<br>
Tim<br>
</font>
</body>
</html>