- Set the descriptors in the firmware:
- Generate INF with WinJavaInf.exe
- Programming the microcontroller and connect.
- Install Driver.
- Create New Java Project in Eclipse
- Copy "usbJava.jar in folder project and Add to Build Path.
- Create new Class:
public class UsbJava {
public static void main(String[] args) {
String szPath = "";
try{
szPath = USBDevice.getAttachedDevicePath(0);
System.out.println("Device Path of Device at index 0 = "+ szPath);
USBDevice myUSB = new USBDevice(szPath);
System.out.println("connected?"+myUSB.deviceIsConnected());
}catch (Exception e) {
e.printStackTrace();
}
}
}
USBDevice class sentence for simple read-write :
writePipeBulkInterrupt(int IntIndex,int EndpointIndex, byte[] bufferData,int iArrayOffset,int iNumBytes)
readPipeBulkInterrupt(int IntIndex, int EndpointIndex, byte[] bufferData,int iArrayOffset,int iNumBytes)
Warning: Endpoint number is not equal to EndpointIndex
readPipeBulkInterrupt(int IntIndex, int EndpointIndex, byte[] bufferData,int iArrayOffset,int iNumBytes)
Warning: Endpoint number is not equal to EndpointIndex