LPC1347 USB4Java

341 views Asked by At

How to send and read data byte from a LPC1347 with HID configuration using Java and USB4Java library?

I can identify the device with the following properties:

private static short VENDORID = 0x1fc9;// 8137
private static short PRODUCTID = 0x2000;// 8192

The endpoints on the LPC1347 are :

private static short HID_ENDPOINT_OUT = 0x01;
private static short HID_ENDPOINT_IN = 0x81;

In my code I used the following:

UsbEndpoint endpoint = iface.getUsbEndpoint((byte) 0x55);
UsbPipe pipe = endpoint.getUsbPipe();
pipe.open();
try {
// read
byte[] data = new byte[8];
int received = pipe.syncSubmit(data);
System.out.println(received + " bytes received");
} finally {
pipe.close();
}   

And I receive the following error :

USB error 1: Transfer error on interrupt endpoint: Input/Output Error

Also in the LPC1347 is setted the following : extern uint8_t InReport[23]; extern uint8_t OutReport[23];

For the first byte I use to read the report(INPUT_REPORT) 0x55 and to write (OUTPUT REPORT) 0xAA.

1

There are 1 answers

0
user3211082 On

I cannot see that you have claimed the interface before you sent data. Try this:

iface.claim(new UsbInterfacePolicy()
    {            
        @Override
        public boolean forceClaim(UsbInterface usbInterface)
        {
            return true;
        }
    });

Then you can insert your code. And in the end of all you should release the interface (I would do in a finally-clause):

iface.release();