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

Need to update hidapi.dll to open device on windows #92

Closed drome77 closed 4 years ago

drome77 commented 4 years ago

Hey Gary, first of all thanks for you super work! I'm working with a Boca printer on windows 10 64 were i installed jre 1.8.0_241 32bit, I'm able to find device but open function always return false. Device I'm trying to open is: HidDevice [path=\?\hid#vid_0a43&pid_0201#6&3a1cd3da&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}, vendorId=0xa43, productId=0x201, serialNumber=0000278143, releaseNumber=0x100, manufacturer=Boca Systems Inc., product=FGL46 Thermal Printer, usagePage=0x1, usage=0x0, interfaceNumber=-1] , usagePage is 0x1 so it could be manage properly by your driver. After open the getLastErrorMessage() return always Device not initialised, can you help me revolving it ?

drome77 commented 4 years ago

Hi Gary, I did a test taking the last source of hidapi.dll, then i recompiled it and inserted into the jar file in substitution of the version already there, doing that my program works fine!! Which version of the dll are you using ? Since i'm getting the jar from Maven is there a way to update your code ?

gary-rowe commented 4 years ago

Hi. I don't have a Windows machine that I can use for compiling the DLLs so I've attempted to use Docker containers and cross compilation instead. Unfortunately that means that I have to rely on others to test if the DLL works which isn't ideal.

While it's possible to accept a new DLL via a pull request and merge it into the main code I can't then be sure that no malicious code has crept in leading to a toolchain attack on downstream users. Is there a way that you can resolve this dilemma?

drome77 commented 4 years ago

actually no, :( where did you get the windows version inserted into you jar, I didn't see any repository of compile dll in the hidapi project

drome77 commented 4 years ago

Sorry Gary to bother you but what can i do for my problem? Is there a way to understand what is happening and try to fix it ? I don't want to force you to use new dll, I just need to use you jar to properly manage my device

drome77 commented 4 years ago

Hi. I don't have a Windows machine that I can use for compiling the DLLs so I've attempted to use Docker containers and cross compilation instead. Unfortunately that means that I have to rely on others to test if the DLL works which isn't ideal.

While it's possible to accept a new DLL via a pull request and merge it into the main code I can't then be sure that no malicious code has crept in leading to a toolchain attack on downstream users. Is there a way that you can resolve this dilemma?

I probably found it, what if you use the last released hidapi.dll version ? I tried with it (hidapi-0.9.0) and it works, using those versions(64 and 32bit) you should avoid security problems, is it possible ?

drome77 commented 4 years ago

hey Gary, do you have any answer to my last comment ? do you plan to update the library on your next release ?

gary-rowe commented 4 years ago

Hi. Apologies for disappearing on you. I'm currently very limited on the time I have available for hid4java but I'd like to get an updated release out. The closest I've got is in the develop branch, which you can compile for yourself (you'll get a version called "develop-SNAPSHOT") which is also in the Maven snapshot repository.

My current plan is to try to get a bit more community involvement by means of a Telegram group and a regular time slot where I can do some work on this. Currently this is every Wednesday at 5pm (UTC) onwards. Is this something that you'd be interested in?

drome77 commented 4 years ago

Sure , I'll try to give my help on this, I need an upgraded an stable release :) Please take note that I have already tried the snapshot version from Maven repository but it doesn't solve my issue. Please let me know what i have to do

gary-rowe commented 4 years ago

I've set up a Telegram group to allow for real time communication. Please review the updated README for more information. I'll see about getting the new DLL into the project based on your findings.

Could you try building locally using your hidapi-0.9.0 and seeing if it works with your machine? I'd like to get a cross compilation environment working so that anyone can build it on any Docker enabled machine.

gary-rowe commented 4 years ago

Given the recent work on the develop branch to cover this, would you say it's ready to close?

gary-rowe commented 4 years ago

Confirmed working via Telegram.