[libhid-discuss] Misunderstanding input and output paths

Charles Lepple clepple at ghz.cc
Wed Apr 21 02:58:23 UTC 2010


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.

> 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:

	char packet_out[] = { DCDCUSB_GET_ALL_VALUES };
	char packet_in[255];

	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: %s 
\n", ret,hid_strerror(ret));
		return 1;
	}

	ret = hid_interrupt_read(hid, DCDCUSB_READENDPOINT, packet_in,  
sizeof(packet_in), TIMEOUT);
	if (ret != HID_RET_SUCCESS) {
		fprintf(stderr, "hid_interrupt_read failed with return code %d: %s 
\n", ret,hid_strerror(ret));
		return 1;
	}

Not sure what is reasonable for TIMEOUT, but it's in milliseconds, so  
maybe 1000?

-- 
Charles Lepple



More information about the libhid-discuss mailing list