libusb_control_transfer returns LIBUSB_ERROR_IO and GetLastError()=1186 (Win7)

licedey <[email protected]> Tue, 4 Aug 2015 01:06:39 -0700 (MST)
Newsgroups gmane.comp.lib.libusb.devel.windows
Message-ID <[email protected]>
Hello,

I am trying to send Output Report to USB keyboard device using
libusb_control_transfer. After the call I've got such error from libusb
debug:
[ 0.157009] [00001c3c] libusb: debug [_hid_set_report] report ID: 0x00
[ 0.157009] [00001c3c] libusb: debug [_hid_set_report] Failed to Write HID
Outpu
t Report: [1] Incorrect function
Control Out error  - Input/Output Error (LIBUSB_ERROR_IO) (Last error -
1168)

And here is my code:

int UsbKeyboardTest()
{
	auto kbdev = FindKeyboard();
	int r;
	libusb_device_handle *devh = nullptr;
	if ((r = libusb_open(kbdev, &devh)) < 0)
	{
		ShowError("Error open device", r);
		return r;
	}

	r = libusb_set_configuration(devh, 1);
	if (r < 0)
	{
		ShowError("libusb_set_configuration error ", r);
		goto out;
	}
	printf("Successfully set usb configuration 1\n");

	libusb_set_debug(_context, 4);

	r = libusb_claim_interface(devh, 0);
	if (r < 0)
	{
		ShowError("libusb_claim_interface error ", r);
		goto out;
	}

	unsigned char data[8] = { 0 };
	r = libusb_control_transfer(devh, CTRL_OUT,
		LIBUSB_REQUEST_SET_CONFIGURATION, (HID_REPORT_TYPE_OUTPUT << 8) | 0x00,			
		0, data, (uint16_t)sizeof(data), 1000);

	if (r < 0) {
		ShowError("Control Out error ", r);
		goto out;
	}
	else
		cout << "Control Transfer send OK - " << r << endl ;

out:
	libusb_close(devh);
}






--
View this message in context: http://libusb.6.n5.nabble.com/libusb-control-transfer-returns-LIBUSB-ERROR-IO-and-GetLastError-1186-Win7-tp5714945.html
Sent from the LibUSB Dev - Win32 mailing list archive at Nabble.com.

------------------------------------------------------------------------------