B4X:
			
		
		
		#AdditionalJar: purejavahidapi
#AdditionalJar: jna-4.0.0
   Dim hdi As JavaObject
    hdi.InitializeStatic("purejavahidapi.HidDeviceInfo")
    'initial PureJavaHidApi
    Dim jo As JavaObject
    jo.InitializeStatic("purejavahidapi.PureJavaHidApi")
    'list all usb hid
    Dim lst As List
    lst = jo.RunMethodJO("enumerateDevices", Null)
    'open usb hid
    Dim obj As JavaObject
    obj.InitializeStatic("purejavahidapi.HidDeviceInfo")
    Dim tmp As Boolean
    Dim PD As Long ,VD As Long
    tmp=False
    For i=0 To lst.Size-1
        Log("lst:" & lst.Get(i))
        'ListView1.Items.Add("lst:"  & lst.Get(i))
        obj = lst.Get(i)
        PD=obj.RunMethod("getProductId",Null)
        VD=obj.RunMethod("getVendorId",Null)
        If  PD=0x1001 And VD=0x6816 Then
           tmp=True
           Exit
        End If
      
    Next
    If tmp=False Then
        fx.Msgbox(MainForm, "没有发现设备!", "警告")
        Return
    End If
  
    Dim getPath As String
    getPath = obj.RunMethod("getPath",Null)
    getPath=getPath.Trim
    Log(getPath)
    Dim hd As JavaObject
    hd.InitializeStatic("purejavahidapi.HidDevice")
    hd = jo.RunMethod("openDevice",  Array As String(getPath))
			
				B4X:
			
		
		
		Waiting for debugger to connect...
Program started.
lst:purejavahidapi.windows.HidDeviceInfo@10c98a4
lst:purejavahidapi.windows.HidDeviceInfo@1f3046d
lst:purejavahidapi.windows.HidDeviceInfo@936f4f
\\?\hid#vid_6816&pid_1001#7&5dc41fe&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Error occurred on line: 59 (Main)
java.lang.RuntimeException: Method: openDevice not matched.
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:129)
    at b4j.example.main._appstart(main.java:200)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:625)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    at b4j.example.main.start(main.java:38)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)some about purejavahidapi
https://github.com/nyholku/purejavahidapi/commit/4388fde3328ef5e8eb7d13ef82c91a79741f0b0a
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		 
 
		 
			 
 
		 
 
		