I try to send a message with the usb4java api to a ir read and write element with this code:
public static void sendData(DeviceHandle handle, int timeout) {
ByteBuffer buffer = ByteBuffer.allocateDirect(12);
buffer.put(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
buffer.rewind();
int transfered = LibUsb.controlTransfer(handle,
(byte) (LibUsb.REQUEST_TYPE_CLASS | LibUsb.RECIPIENT_INTERFACE),
(byte) 0x09, (short) 2, (short) 1, buffer, timeout);
if (transfered < 0) {
throw new LibUsbException("Control transfer failed", transfered);
}
System.out.println(transfered + " bytes sent");
}
But each time I try it, I get this error at int = controlTransfer(handle, (LibUsb.REQUEST_TYPE_CLASS | RECIPIENT_INTERFACE), 0x09, (short) 2, (short) 1, buffer, timeout);
:
Exception in thread "main" org.usb4java.LibUsbException: USB error 1: Control transfer failed: Input/Output Error
at usb.reader.USBReader.sendData(USBReader.java:56)
at usb.reader.USBReader.main(USBReader.java:42)
Java Result: 1
Maybe one of you have an idea how to fix this problem?
I really looking forward to your answer.
EDIT: I think I have to say that my operating system is Linux 64 bit in a VM VirtualBox on Windows 8.1 64 bit. (USB forwarding is activated; I already have accessed to the USB device)
value wValue=256