[libhid-discuss] Misunderstanding input and output paths
Gary Briggs
chunky at icculus.org
Fri Apr 23 05:45:24 UTC 2010
On Tue, Apr 20, 2010 at 10:58:23PM -0400, Charles Lepple wrote:
> On Apr 20, 2010, at 2:50 AM, Gary Briggs wrote:
> >It appears to be an HID device, and the source code available on that
> >website uses HID code on windows.
>
> By the way, have you tried compiling their code on Linux? They have a
> bunch of "#ifdef _WIN32" blocks which seem to use the Linux hiddev API.
Yeah, I tried. I'm fairly certain that it has run on linux at some point
in the past, but that time was fairly long gone. I tried reaching them
to see if they had an older version, but I've had no response yet.
> >I'm reading the sample sourcecode on the libhid page, and it tells me
> >how to work out the path to access the input and output paths. That
> >seems predicated on a single input and output path, but the lsusb dump
> >above contains a bunch of each. Right at the end it mentions a
> >specific
> >pair of endpoints [0x81, 0x01] but I'm not clear whether that actually
> >has any bearing on the path as libhid would find it useful.
>
> After looking at the Windows app, it seems like what I said before
> about EP0 isn't necessarily going to work the same way as the
> interrupt endpoints. They are basically using the Win32 WriteFile()
> call, which apparently tries to use interrupt endpoints if they are
> available.
>
> You could probably try something like this:
<snipped>
> Not sure what is reasonable for TIMEOUT, but it's in milliseconds, so
> maybe 1000?
Your code included hid_strerror, but that doesn't appear to be available
here. I'm using the default package included in ubuntu 9.04 on PPC,
which according to showpkg is version 0.2.15+20060325-2.2ubuntu1
The code I ended using is this:
char packet_out[] = { DCDCUSB_GET_ALL_VALUES };
ret = hid_interrupt_write(hid, DCDCUSB_WRITEENDPOINT, packet_out, sizeof(packet_out), TIMEOUT);
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_interrupt_write failed with return code %d\n", ret);
return 1;
}
char packet_in[255];
memset(packet_in, 0, sizeof(packet_in));
ret = hid_interrupt_read(hid, DCDCUSB_READENDPOINT, packet_in, sizeof(packet_in), TIMEOUT);
printf("\nPacketlength %i\n", strlen(packet_in));
if (ret != HID_RET_SUCCESS) {
fprintf(stderr, "hid_interrupt_read failed with return code %d\n", ret);
return 1;
}
What I think is the salient output is this:
device identification of HIDInterface 004/002[0]:
dev_handle: 0x100141b0
device: 0x1001b188
location: 004/002
manufacturer: MINI-BOX.COM
product: DCDC-USB
serial number: 1.00rel.
TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/002[0]...
TRACE: hid_dump_tree(): iterating the parse tree for USB device 004/002[0]...
<snip>
TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/002[0]...
TRACE: hid_interrupt_write(): writing interrupt report to device 004/002[0] ...
NOTICE: hid_interrupt_write(): successfully sent interrupt report to device 004/002[0]
TRACE: hid_interrupt_read(): retrieving interrupt report from device 004/002[0] ...
WARNING: hid_interrupt_read(): failed to get interrupt read from device 004/002[0]: could not claim interface 0: Device or resource busy
Packetlength 11
hid_interrupt_read failed with return code 21
The packet itself contains binary garbage if I try to print it out.
The full output of the program is here:
http://icculus.org/~chunky/stuff/dcdcusb/dcdcusbout.txt
Would I be better off trying to approach this starting with existing UPS
drivers?
Thanks for your help,
Gary (-;
More information about the libhid-discuss
mailing list