“Access is denied” in interrupt Write in JNA imple

2019-09-11 10:04发布

Using the library in this link http://www.blog.kslemb.com/doku.php/en/projects/globx/java_hid

I have been modfied this code to send data on a HID device using interrupt transfer.

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;
        }

        }

Debugging shows a "Access is denied" Message. Just wondering what can be the source of this problem. Any kind of help would be greatly appreciated. Thanks!

标签: usb jna hid
0条回答
登录 后发表回答