我想使用 Usb4Java 的低级 API 将单个包发送到 USB 设备(Arduino 控制器),但我收到以下错误:
org.usb4java.LibUsbException: USB error 9: Pipe error
这是关键部分的代码:
ByteBuffer buffer = ByteBuffer.allocateDirect(8);
buffer.put(new byte[] {'a', 'b', 'c'});
int transfered = LibUsb.controlTransfer(handle,
(byte) (LibUsb.REQUEST_TYPE_CLASS | LibUsb.RECIPIENT_INTERFACE),
(byte) 0x09,
(short) 256,
(short) 0,
buffer,
1000);
System.out.println(transfered);
if (transfered < 0){
throw new LibUsbException("Control transfer failed", transfered);
我觉得可能和驱动有关,也可能和参数有关。LibUsb.controlTransfer(...);
值得一提的是:源机运行的是Windows 7。