Important note for Windows
The following short example will show you how to use LibusbJava in your Java-Project. The following code describes the required steps to do a bulk transfer to your device.
Context useCtx = null; Device usbDev = null; try { useCtx = new Context(); /* 1 */ } catch (LibusbException e) { System.out.println("Init failed:"); e.printStackTrace(); } System.out.println("Search Device:"); try { usbDev = Device.search(useCtx, 0x8235, 0x100); /* 2 */ } catch (LibusbException e) { System.out.println("Error occured: search"); e.printStackTrace(); } if(usbDev == null) return; try { usbDev.open(); /* 4 */ usbDev.claimInterface(0); /* 5 */ byte[] data = {(byte)0x40, (byte)0x80, (byte)0x12, (byte)0x16}; int res = usbDev.bulkTransfer(2, data, data.length, 0); /* 6 */ if(res == data.length){ System.out.println("Bulk tranfer 1 successful."); } else{ System.out.println("Bulk transfer 1 failed."); } usbDev.reset(); res = 0; res = usbDev.bulkTransfer(2, data, data.length, 0); /* 6 */ if(res == data.length){ System.out.println("Bulk tranfer 2 successful."); } else{ System.out.println("Bulk transfer 2 failed."); } usbDev.releaseInterface(0); /* 7 */ usbDev.close(); /* 8 */ System.out.println("Device closed."); } catch (LibusbException e) { System.out.println("Error occured: transfer"); e.printStackTrace(); }