Issue of serial reading on Java felhr85 library

I am sending a serial byte array(len=8) from Arduino but it reads only 4 bytes. I tried 2 different ways to read serial byte array using felhr85 library but the results are the same. How can I fix this issue?

First One ;

private Handler mHandler;
public static final int MESSAGE_FROM_SERIAL_PORT = 0;
private UsbSerialInterface.UsbReadCallback mCallback = new UsbSerialInterface.UsbReadCallback() {
    public void onReceivedData(byte[] arg0) {
        try {
            String data = new String(arg0, "UTF-8");
            if (mHandler != null)
                mHandler.obtainMessage(MESSAGE_FROM_SERIAL_PORT, data).sendToTarget();
        } catch (UnsupportedEncodingException e) {

Second One;

UsbSerialInterface.UsbReadCallback mCallBack = (arg0) -> {
  String data = null;
      data = new String(arg0, "UTF-8");
  }catch (UnsupportedEncodingException e){

code from Arduino books.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.