sauravsingh29 / javahidapi

Automatically exported from code.google.com/p/javahidapi
Other
0 stars 0 forks source link

Two apps can't access one HID device. Windows Only (includes Fix) #46

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have modified the hidtest application to use the PID and VID of my HID 
device.  When run on a Mac and on Linux, the application is able to list and 
read the device.

On my Windows machine (Windows 7 32-bit, javahidapi-1.1, java 1.7.), there is a 
service running that is also trying to access the HID device.  The test 
application lists and reads properly when the service is stopped.  With the 
service running, the application can list, but HIDDevice.openById() returns 
null.

The issue is with the Windows native code, specifically hidapi's open_device(). 
 During the list() operation, open_device() calls CreateFileA() with 
FILE_SHARE_READ | FILE_SHARE_WRITE.  However, during the openById() operation, 
open_device() calls CreateFileA() with only FILE_SHARE_READ.

Perhaps read-only share mode was selected for a reason, but when the attached 
patch is applied (to always grant read and write sharing mode) the hidtest 
application runs successfully regardless if the service is running or not.

Original issue reported on code.google.com by finlayth...@gmail.com on 31 Jan 2013 at 1:03

GoogleCodeExporter commented 8 years ago
Oops - Problem with the previous patch.  Here's a working one.

Original comment by finlayth...@gmail.com on 31 Jan 2013 at 1:05

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The jar in comment #2 doesn't contain the proper DLL for 64-bit Windows.  Here 
are the updated jars for read/write on 32 and 64 bit platforms.

Original comment by abyth...@ziptrek.com on 26 Jun 2013 at 10:59

Attachments: