使用此链接中的库http://www.blog.kslemb.com/doku.php/en/projects/globx/java_hid
我已修改此代码以使用中断传输在HID设备上发送数据。
public byte SetInReport(byte[] buffer, int buffersize) {
if (HIDHandle.equals(WinBase.INVALID_HANDLE_VALUE)) {
return HID_DEVICE_NOT_OPENED;
}
IntByReference bWritten = new IntByReference();
boolean Status = Kernel32.INSTANCE.WriteFile(HIDHandle, buffer, buffersize, bWritten, null);
if (Status == false) {
debug("Write File: " + getSystemError(Kernel32.INSTANCE.GetLastError()));
//System.out.println("Fail");
return HID_DEVICE_TRANSFER_FAILED;
}
else {
System.out.println("Successful!!!");
//System.out.println("buffer in communication.java = "+buffer[1]);
return HID_DEVICE_SUCCESS;
}
}
调试显示“访问被拒绝”消息。只是想知道这个问题的根源是什么。任何形式的帮助将不胜感激。谢谢!