nyholku / purejavahidapi

Other
122 stars 69 forks source link

SetFeature() on Linux is not working (for me) #38

Closed nietamten closed 7 years ago

nietamten commented 7 years ago

(poor english - sorry) With strace (and htop as GUI for it) I found that param for ioctl() is wrong. I guess _IOC() (as I see copied from C) give different result in java.

Fast hack that work (for my app http://ble.athost.net/index.php?dir=pub/czujniki_wilgotnosci/software/java ):

In HIDRAW.java replace public static int HIDIOCSFEATURE(int len) { return _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len); } with public static int HIDIOCSFEATURE(int len) { return 0xC0004806 |(len<<16); }

I found 0xC0004806 value with https://github.com/torvalds/linux/blob/master/samples/hidraw/hid-example.c by appending " printf(" %04X ",HIDIOCSFEATURE(0));" .

nyholku commented 7 years ago

Hi nietamten,

great detective work and many thanks for contributing, I will include this in the next release.

nyholku commented 7 years ago

This should now be fixed in the next release, when that happens, please test and report back if it is still a problem. I will close this for now, please re-open if the problem persists.