次のコードを使用して、usb4java API を使用してメッセージを ir 読み取りおよび書き込み要素に送信しようとしています。
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");
}
しかし、試すたびに、次の場所でこのエラーが発生し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
この問題を解決する方法を知っている人がいるかもしれません。
あなたの答えを本当に楽しみにしています。
編集:私のオペレーティングシステムは、Windows 8.1 64ビット上のVM VirtualBoxのLinux 64ビットであると言わざるを得ないと思います。(USB フォワーディングが有効です。既に USB デバイスにアクセスしています)