gary-rowe / hid4java

A cross-platform Java Native Access (JNA) wrapper for the libusb/hidapi library. Works out of the box on Windows/Mac/Linux.
MIT License
229 stars 71 forks source link

Write not working with Windows 8.1 #64

Closed lightway82 closed 4 years ago

lightway82 commented 7 years ago

I use this code with win8 and hidDevice.read(bytes, 10000); always returned by timeout. On win 7 and Linux everything is working fine.

If i set HidApi.dropReportIdZero=false; then everything is working fine on win8!!! This is strange because default on Win8 and win10 this flag is set to true.

private void sendMessage(HidDevice hidDevice) {
        if (!hidDevice.isOpen()) {
            if(!hidDevice.open()) throw new RuntimeException();

             byte[] commandWrite = new byte[64];
             commandWrite[0]=50;

            int val = hidDevice.write(commandWrite, commandWrite.length, (byte) 0x00);
             System.out.println("Num  bytes: " + val);
            if (val < 0)  throw new RuntimeException();
            byte[] bytes = new byte[64];
            int read = hidDevice.read(bytes, 10000);
                System.out.println("Num  bytes: " + read);
            if (val < 0)  throw new RuntimeException();
        }
    }
gary-rowe commented 4 years ago

This is probably due to the #43 issue which has been resolved in the develop branch.

I'll mark it as closed.