sandervs / javahidapi

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

NullPointerException after opening device #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compiled on 64bit Ubuntu 12.4, copied the libhidapi-jni.so to /usr/lib
2. Running HIDAPITest lists mouse/keyboard and DataLogic barcodescanner 
successfully (DataLogic under /dev/hidraw3)
3. Uncomment the command readDevice for appropriate vendorID/productID or use 
the openByPath method.

What is the expected output? What do you see instead?
I expect an actual object returned by openByPath/ById,
buth it returns null on any listed USB-device, generating 
anNullPointerException on the next line:
System.err.print("Manufacturer: " + dev.getManufacturerString() + "\n");

What version of the product are you using? On what operating system?
v2011-12-21 on Ubuntu 12.4 x64

Please provide any additional information below.
Is there something trivial I am doing wrong? Listing devices works fine, 
however opening a device not.

Original issue reported on code.google.com by martijnv...@gmail.com on 1 Jun 2012 at 9:58

GoogleCodeExporter commented 8 years ago
Same here on Windows 7 64-Bit. openByPath/ById always returns null in the 
latest revision #354. Maybe it has something to do with the added 
64-Bit-Support. 

If used Revision #347 and everything works fine.

Original comment by nada...@gmx.net on 10 Jun 2012 at 4:37

GoogleCodeExporter commented 8 years ago
Also getting this issue now. Anyone have any idea why? I could go back but I 
need a 64bit dll. API is basically useless with this problem :(

Original comment by Reece.Sean on 11 Jun 2012 at 5:40

GoogleCodeExporter commented 8 years ago

Original comment by kroko...@gmail.com on 1 Aug 2012 at 1:38

GoogleCodeExporter commented 8 years ago
I try to call openById/Path in while loop and after second execution device is 
opened and returned, but I can not write or read anything.:( - Reading returns 
0, writing returns IOException - I have used last Repository sources.

Original comment by hanousek...@gmail.com on 2 Aug 2012 at 10:20

GoogleCodeExporter commented 8 years ago
I had to run the jvm as root in order to get actual non-null devices back. docs 
should be updated to explain the case where null is returned from openByID/Path

Original comment by jayhurle...@gmail.com on 26 Apr 2013 at 9:13

GoogleCodeExporter commented 8 years ago
Is here any progress, I have the same issue as described. How can I change the 
permissions for the java executables on a 64Bit Windows 7. I changed the 
permission for java.exe but it still returns null. while(hiddevice == null) 
{...open(); } no success as well, so any ideas?

Original comment by saunamei...@googlemail.com on 8 May 2013 at 9:48

GoogleCodeExporter commented 8 years ago
I am experiencing this issue on Win 7 64 bit. Is there a solution on the 
horizon?

Original comment by spam3a...@gmail.com on 17 Jul 2013 at 9:19

GoogleCodeExporter commented 8 years ago
I also cannot get it to work on Windows 8 64bit.
I have a special keyboard being developed and I needed to test some extra LEDs.
Any solution

Original comment by peter.fe...@gmail.com on 12 Aug 2013 at 11:31

GoogleCodeExporter commented 8 years ago
I experience the same problem with listDevices - although HIDManager is created 
successfully, listDevices throws NullPointerException. 64Bit Win7.

Original comment by igor.a.e...@gmail.com on 14 Aug 2013 at 3:51

GoogleCodeExporter commented 8 years ago
I can't get the list of HID devices too. it throws NullPointerException in win7 
64Bit. Any solution ?

Original comment by zulfy.ad...@gmail.com on 28 Aug 2013 at 2:09

GoogleCodeExporter commented 8 years ago
Same problem on win 7 64. I can find device but open() function always return 
null. 

Original comment by Nickolay...@gmail.com on 4 Feb 2014 at 9:01

GoogleCodeExporter commented 8 years ago
I had the same problem on a raspberry pi. Since I tried to execute the code in 
su mode it works fine for me

Original comment by k...@nandro.nl on 9 Feb 2014 at 9:01

GoogleCodeExporter commented 8 years ago
I have the same issue right now. This is really strange since I worked the last 
5 months on a project which makes use of this library and it worked so far. I'm 
getting the NullPointerException when I try to open a device. But I can get the 
list of available HID Devices.

I'm working on Windows7 64-Bit. The code I'm using right now is the same code 
of that time when it was working. The only thing I changed was just formating 
my harddrive and re-installing Windows 7. 

Has anyone a workaround for this issue?
Thank you in advance!

Original comment by tolg...@gmail.com on 11 Apr 2014 at 6:02

GoogleCodeExporter commented 8 years ago
Ok I solved the problem by using angryelectron's patch:
http://angryelectron.com/javahidapi-nihardwareservice/

Original comment by tolg...@gmail.com on 14 Apr 2014 at 7:49

GoogleCodeExporter commented 8 years ago
Is angryelectron's patch still working for you? My java program is running fine 
on Linux but does not like Windows. It's also not throwing an exception which 
surprises me. However, after checking the contents of my HIDDevice after 
openByPath() its contents are null. This makes me believe the device is getting 
blocked in some form for read and write activity. Like mentioned above, I can 
see the list of devices including the one I'm trying to access. 

I used the jar files angryelectron provided. It's an awesome library, but 
Windows is being a pain. 

Original comment by Hemiman...@comcast.net on 29 May 2014 at 1:29

GoogleCodeExporter commented 8 years ago
 I'm having the same problem on windows 7 embedded 32bits and windows 7 32bits. It lists well my devices, also first write and read works when running my software as administrator but then the device is like blocked and I get null pointer exceptions.

Runs like a charm on windows 8 32/64 bits

Original comment by romain.r...@gmail.com on 2 Mar 2015 at 12:27

GoogleCodeExporter commented 8 years ago
I am having the same problem on Win 8.1 64bit. I tried to use hidapi-rw-1.1.1. 
version, but without any success. On Win 8.1 64bit openByPath() returns null 
for all devices. 

When I ran the same project on Win 7 64bit, 
HIDDeviceInfo[] deviceInfos = manager.listDevices() returns null;

Is there anything in Windows that can be set to make it work? Thank you.

Original comment by petr.cze...@gmail.com on 23 Jul 2015 at 2:12

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I am dealing with the same Problem right now. I'm working on a Linux.
I tried doing 

    System.loadLibrary();

and 

    ClassPathLibraryLoader.loadNativeHIDLibrary();

I still get a NullPointer when I open the HIDDevice.
I'm just exploring the JavaHidApi right now and my code looks like this:

    System.loadLibrary("hidapi-jni-32");
    //  ClassPathLibraryLoader.loadNativeHIDLibrary();
        HIDManager hm = HIDManager.getInstance();
        HIDDeviceInfo[] dvl = hm.listDevices();
        System.out.println(dvl.length + " Devices found:");
        for (HIDDeviceInfo dv : dvl) {
            System.out.println("----------------------");
            System.out.print("Manufacturer: " + dv.getManufacturer_string()
                    + " | ");
            System.out.print("Vendor_ID: " + dv.getVendor_id() + " | ");
            System.out.print("Product_ID: " + dv.getProduct_id() + "  \n");

            HIDDevice dev = hm.openById(dv.getVendor_id(), dv.getProduct_id(),
                    null);
}

My output:

*3 Devices found:
----------------------
Manufacturer: null | Vendor_ID: 2362 | Product_ID: 9488  

Exception in thread "main" java.lang.NullPointerException
    at Main.testDevices.main(testDevices.java:38)*

Could anybody help me what I am doing wrong?

Original comment by gasser...@gmail.com on 19 Aug 2015 at 9:31