'initial HidDeviceInfo
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)
For i=0 To lst.Size-1
Log("lst:" & lst.Get(i))
ListView1.Items.Add("lst:" & lst.Get(i))
Next
'open usb hid
Dim obj As JavaObject
obj.InitializeStatic("purejavahidapi.HidDeviceInfo")
obj = lst.Get(i-1)
Dim getPath As String
getPath = obj.RunMethod("getPath",Null)
Log("----------------------- HidDeviceInfo -----------------------")
Log("obj:" & obj)
Log("hdi" & hdi)
Log("getProductId:" & obj.RunMethod("getProductId",Null))
Log("getProductString:" & obj.RunMethod("getProductString",Null))
Log("getReleaseNumber:" & obj.RunMethod("getReleaseNumber",Null))
Log("getSerialNumberString:" & obj.RunMethod("getSerialNumberString",Null))
Log("getUsagePage:" & obj.RunMethod("getUsagePage",Null))
Log("getVendorId:" & obj.RunMethod("getVendorId",Null))
Log("getManufacturerString:" & obj.RunMethod("getManufacturerString",Null))
Dim hd As JavaObject
hd.InitializeStatic("purejavahidapi.HidDevice")
hd = jo.RunMethod("openDevice", Array As String(getPath))
Log("----------------------- HidDevice -----------------------")
Log("hd:" & hd)
Log("getHidDeviceInfo:" & hd.RunMethod("getHidDeviceInfo",Null))
Log("getPath:" & getPath)
' send data to hid
Dim data(64) As Byte
Dim s As String
Dim bc As ByteConverter
s="0001020304050607080910111213141516171819202122232425262728293031323334353637383940414243444546474849 5051525354555657585960616263"
data = bc.HexToBytes(s)
Log("----------------------- Send Data -----------------------")
Log("s:" & s)
Log("data.Length:" & data.Length)
Dim ival As Int
ival = hd.RunMethod("setFeatureReport", Array As Object( data, 64 ))
Log("ival:" & ival)