Hello,
I'm still trying to send data to a HID device but it doesn't work. I
don't have any errors or exceptions but the syncSubmit method never
ends and if I use the asynchSubmit method, the actual lentgh is always
null. I'm sure it's possible to send data to the device because
there's a software given with the device which does that. I've checked
the packets sent by this software to the device with an usb monitor
and I tried to send the same.
Does anyone knows the problem?
Thanks.
Here is my code :
public static void main(String argv[]){
try{
UsbServices services = UsbHostManager.getUsbServices();
UsbHub virtualRootUsbHub = services.getRootUsbHub();
List LL_DevList =
getUsbDevicesWithId(virtualRootUsbHub,
(short)0x4242, (short)0xee01);
UsbDevice LCl_Device = (UsbDevice)LL_DevList.get(0);
UsbInterface LCl_UsbInterface =
LCl_Device.getActiveUsbConfiguration().getUsbInterface((byte)0);
UsbInterfacePolicy LCl_uiP = new UsbInterfacePolicy()
{
public boolean forceClaim (UsbInterface
LCl_Interface)
{
return true;
}
};
try
{
LCl_UsbInterface.claim(LCl_uiP);
}catch(UsbException LCl_Exception){
System.out.println("Could not claim interface
to drive majook : "+
LCl_Exception.getMessage());
}
UsbInterface LCl_UsbActiveInterface =
LCl_UsbInterface.getActiveSetting();
byte LN_EndpointOutAdress = (byte)0x04;
UsbEndpoint LCl_UsbEndpointOut =
LCl_UsbActiveInterface.getUsbEndpoint(LN_EndpointOutAdress);
UsbPipe LCl_UsbPipeOut =
LCl_UsbEndpointOut.getUsbPipe();
try
{
LCl_UsbPipeOut.open();
}catch (UsbException e){
System.out.println("Could not open
endpoint to communicate with
majook : "+ e.getMessage());
}
byte[] LT_WriteData = new byte[64];
for (int i=0; i< 64; i++)
{
LT_WriteData[i]=(byte)0x00;
}
LT_WriteData[1] = (byte)0x30;
try
{
LCl_UsbPipeOut.syncSubmit(LT_WriteData);
}catch(UsbException LCl_UsbException){
System.out.println("Unable to submit
data buffer to majook : " +
LCl_UsbException.getMessage());
}
try
{
LCl_UsbPipeOut.abortAllSubmissions();
LCl_UsbPipeOut.close();
}catch (UsbException LCl_Exception){
System.out.println("Could not open
endpoint to communicate with
majook : "+ LCl_Exception.getMessage())
}
}
}catch(UsbException LCl_Exception){
}
}
public static List getUsbDevicesWithId(UsbDevice usbDevice, short
vendorId, short productId)
{
List list = new ArrayList();
if (vendorId == usbDevice.getUsbDeviceDescriptor().idVendor() &&
productId ==
usbDevice.getUsbDeviceDescriptor().idProduct())
list.add(usbDevice);
if (usbDevice.isUsbHub()) {
List devices =
((UsbHub)usbDevice).getAttachedUsbDevices();
for (int i=0; i<devices.size(); i++)
list.addAll(getUsbDevicesWithId((UsbDevice)devices.get(i),
vendorId, productId));
}
return list;
}
}
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel