[libhid-discuss] help with usage path
Washington Trindade
washingtonuesc at gmail.com
Tue Jul 3 12:02:16 UTC 2007
Charles,
Below is the entire output of the program:
usb_set_debug: Setting debugging level to 6 (on)
NOTICE: hid_init(): libhid 0.2.16.0.0 is being initialized.
TRACE: hid_init(): initialising USB subsystem...
usb_os_init: Found USB VFS at /proc/bus/usb
TRACE: hid_init(): scanning for USB busses...
usb_os_find_busses: Skipping non bus directory devices
usb_os_find_busses: Skipping non bus directory drivers
usb_os_find_busses: Found 005
usb_os_find_busses: Found 004
usb_os_find_busses: Found 003
usb_os_find_busses: Found 002
usb_os_find_busses: Found 001
TRACE: hid_init(): scanning for USB devices...
usb_os_find_devices: Found 001 on 005
usb_os_find_devices: Found 002 on 005
skipped 1 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 004
usb_os_find_devices: Found 001 on 003
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
NOTICE: hid_init(): successfully initialised HID library.
TRACE: hid_new_HIDInterface(): creating a new HIDInterface instance...
TRACE: hid_force_open(): forcefully opening a device interface according
to matching criteria...
TRACE: hid_get_usb_handle(): acquiring handle for a USB device...
TRACE: hid_find_usb_device(): enumerating USB busses...
TRACE: hid_find_usb_device(): enumerating USB devices on bus 005...
TRACE: hid_find_usb_device(): inspecting USB device 005/001[0]...
Check that you have permissions to write to 005/001 and, if you don't, that
you set up hotplug (http://linux-hotplug.sourceforge.net/) correctly.
USB error: could not claim interface 0: Device or resource busy
TRACE: hid_compare_usb_device(): comparing match specifications to USB
device...
TRACE: hid_compare_usb_device(): inspecting vendor ID...
TRACE: hid_compare_usb_device(): no match on vendor ID.
TRACE: hid_compare_usb_device(): inspecting product ID...
TRACE: hid_compare_usb_device(): no match on product ID.
TRACE: hid_compare_usb_device(): no custom matching function supplied.
NOTICE: hid_find_usb_device(): vendor 0x0000 of USB device 005/001[0] does
not match 0x0483.
TRACE: hid_find_usb_device(): inspecting USB device 005/002[0]...
TRACE: hid_compare_usb_device(): comparing match specifications to USB
device...
TRACE: hid_compare_usb_device(): inspecting vendor ID...
TRACE: hid_compare_usb_device(): match on vendor ID: 0x0483.
TRACE: hid_compare_usb_device(): inspecting product ID...
TRACE: hid_compare_usb_device(): match on product ID: 0x0035.
TRACE: hid_compare_usb_device(): no custom matching function supplied.
NOTICE: hid_find_usb_device(): found a matching USB device 005/002[0].
TRACE: hid_force_open(): claiming USB device 005/002[0].
NOTICE: hid_force_open(): successfully claimed USB device 005/002[0].
TRACE: hid_init_parser(): initialising the HID parser for USB Device
005/002[0]...
TRACE: hid_init_parser(): allocating space for HIDData structure...
TRACE: hid_init_parser(): successfully allocated memory for HIDData
strcture.
TRACE: hid_init_parser(): allocating space for HIDParser structure...
TRACE: hid_init_parser(): successfully allocated memory for HIDParser
strcture.
NOTICE: hid_init_parser(): successfully initialised the HID parser for USB
Device 005/002[0].
TRACE: hid_prepare_hid_descriptor(): initialising the HID descriptor for
USB device 005/002[0]...
TRACE: hid_prepare_hid_descriptor(): retrieving HID descriptor for USB
device 005/002[0]...
NOTICE: hid_prepare_hid_descriptor(): successfully initialised HID
descriptor for USB device 005/002[0] (29 bytes).
TRACE: hid_prepare_report_descriptor(): initialising the report descriptor
for USB device 005/002[0]...
TRACE: hid_prepare_report_descriptor(): retrieving report descriptor for
USB device 005/002[0]...
NOTICE: hid_prepare_report_descriptor(): successfully initialised report
descriptor for USB device 005/002[0].
TRACE: hid_prepare_parser(): setting up the HID parser for USB device
005/002[0]...
TRACE: hid_reset_parser(): resetting the HID parser for USB device
005/002[0]...
TRACE: hid_prepare_parser(): dumping the raw report descriptor
TRACE: hid_prepare_parser(): 0x000: 0x06 0x80 0xff 0x09 0x00 0xa1 0x01
0x75
TRACE: hid_prepare_parser(): 0x008: 0x08 0x95 0x08 0x15 0x00 0x26 0xff
0x00
TRACE: hid_prepare_parser(): 0x010: 0x09 0x01 0xb1 0x82 0x09 0x01 0x81
0x82
TRACE: hid_prepare_parser(): 0x018: 0x09 0x02 0x91 0x82 0xc0
TRACE: hid_prepare_parser(): parsing the HID tree of USB device
005/002[0]...
NOTICE: hid_prepare_parser(): successfully set up the HID parser for USB
device 005/002[0].
NOTICE: hid_force_open(): successfully opened USB device 005/002[0].
device identification of HIDInterface 005/002[0]:
dev_handle: 0x0804a0a0
device: 0x08051190
location: 005/002
manufacturer: STMicroelectronics
product: ST7 RS232 USB BRIDGE
TRACE: hid_reset_parser(): resetting the HID parser for USB device
005/002[0]...
TRACE: hid_dump_tree(): iterating the parse tree for USB device
005/002[0]...
parse tree of HIDInterface 005/002[0]:
path: 0xff800000.0xff800001; type: 0xb0
path: 0xff800000.0x00000000; type: 0xb0
path: 0xff800000.0x00000000; type: 0xb0
path: 0xff800000.0x00000000; type: 0xb0
path: 0xff800000.0x00000000; type: 0xb0
path: 0xff800000.0x00000000; type: 0xb0
path: 0xff800000.0x00000000; type: 0xb0
path: 0xff800000.0x00000000; type: 0xb0
path: 0xff800000.0xff800001; type: 0x80
path: 0xff800000.0x00000000; type: 0x80
path: 0xff800000.0x00000000; type: 0x80
path: 0xff800000.0x00000000; type: 0x80
path: 0xff800000.0x00000000; type: 0x80
path: 0xff800000.0x00000000; type: 0x80
path: 0xff800000.0x00000000; type: 0x80
path: 0xff800000.0x00000000; type: 0x80
path: 0xff800000.0xff800002; type: 0x90
path: 0xff800000.0x00000000; type: 0x90
path: 0xff800000.0x00000000; type: 0x90
path: 0xff800000.0x00000000; type: 0x90
path: 0xff800000.0x00000000; type: 0x90
path: 0xff800000.0x00000000; type: 0x90
path: 0xff800000.0x00000000; type: 0x90
path: 0xff800000.0x00000000; type: 0x90
TRACE: hid_reset_parser(): resetting the HID parser for USB device
005/002[0]...
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 005/002[0]...
TRACE: hid_prepare_parse_path(): search path prepared for parse tree of
USB device 005/002[0].
NOTICE: hid_find_object(): found requested item.
TRACE: hid_set_output_report(): sending report ID 0x00 (length: 3) to USB
device 005/002[0]...
NOTICE: hid_set_output_report(): successfully sent report to USB device
005/002[0].
TRACE: hid_close(): closing USB device 005/002[0]...
TRACE: hid_close(): closing handle of USB device 005/002[0]...
NOTICE: hid_close(): successfully closed USB device 005/002[0].
TRACE: hid_reset_parser(): resetting the HID parser for USB device
005/002[0]...
TRACE: hid_close(): freeing memory allocated for HID parser...
TRACE: hid_close(): resetting HIDInterface...
NOTICE: hid_cleanup(): successfully deinitialised HID library.
And here, the output of the command lsusb -d 0x0483:0x0035 -vvv:
Bus 005 Device 002: ID 0483:0035 SGS Thomson Microelectronics
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x0483 SGS Thomson Microelectronics
idProduct 0x0035
bcdDevice 2.00
iManufacturer 3 STMicroelectronics
iProduct 1 ST7 RS232 USB BRIDGE
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 41
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 20mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Devices
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 33 US
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 29
Report Descriptor: (length is 29)
Item(Global): Usage Page, data= [ 0x80 0xff ] 65408
(null)
Item(Local ): Usage, data= [ 0x00 ] 0
(null)
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x08 ] 8
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local ): Usage, data= [ 0x01 ] 1
(null)
Item(Main ): Feature, data= [ 0x82 ] 130
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Volatile
Bitfield
Item(Local ): Usage, data= [ 0x01 ] 1
(null)
Item(Main ): Input, data= [ 0x82 ] 130
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Volatile
Bitfield
Item(Local ): Usage, data= [ 0x02 ] 2
(null)
Item(Main ): Output, data= [ 0x82 ] 130
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Volatile
Bitfield
Item(Main ): End Collection, data=none
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10
Device Status: 0x0000
(Bus Powered)
And here the program:
#include <hid.h>
#include <stdio.h>
#include <string.h>
bool match_serial_number(struct usb_dev_handle* usbdev, void* custom,
unsigned int len)
{
bool ret;
char* buffer = (char*)malloc(len);
usb_get_string_simple(usbdev, usb_device(usbdev)->descriptor.iSerialNumber
,
buffer, len);
ret = strncmp(buffer, (char*)custom, len) == 0;
free(buffer);
return ret;
}
int main(void)
{
HIDInterface* hid;
hid_return ret;
HIDInterfaceMatcher matcher = { 0x0483, 0x0035, NULL, NULL, 0 };
/* see include/debug.h for possible values */
hid_set_debug(HID_DEBUG_ALL);
hid_set_debug_stream(stderr);
/* passed directly to libusb */
hid_set_usb_debug(6);
ret = hid_init();
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_init failed with return code %d\n", ret);
return 1;
}
hid = hid_new_HIDInterface();
if (hid == 0) {
fprintf(stderr, "hid_new_HIDInterface() failed, out of memory?\n");
return 1;
}
ret = hid_force_open(hid, 0, &matcher, 3);
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_force_open failed with return code %d\n", ret);
return 1;
}
ret = hid_write_identification(stdout, hid);
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_write_identification failed with return code %d\n",
ret);
return 1;
}
ret = hid_dump_tree(stdout, hid);
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_dump_tree failed with return code %d\n", ret);
return 1;
}
//Now, to send 3 bytes:
unsigned char const PATHLEN = 2;
int const PATH_OUT[2] = { 0xff800000, 0xff800002};
unsigned char const SEND_PACKET_LEN = 3;
char const PACKET[3] = "T\r\n";
ret = hid_set_output_report(hid, PATH_OUT, PATHLEN, PACKET,
SEND_PACKET_LEN);
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_set_output_report failed with return code %d\n",
ret);
}
// char packet[8];
// ret = hid_get_input_report(hid, PATH_OUT, PATHLEN, packet, 8);
// if (ret != HID_RET_SUCCESS) {
// fprintf(stderr, "hid_get_input_report failed with return code
%d\n", 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;
}
Thanks in advance!
--
The best index to a person's character is a) how he treats people who can't
do him any good and b) how he treats people who can't fight back
More information about the libhid-discuss
mailing list