mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
MIT License
4.83k stars 1.58k forks source link

Failed to receive binary data with Android #372

Closed ghost closed 3 years ago

ghost commented 3 years ago

What I want to do is sending 42 bytes binary data from mbed LPC1768 to my Android smartphone. The code I use is as follows.

usbIoManager = new SerialInputOutputManager(port,musbListener);
final ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(usbIoManager);

As you can see, a serial port listener is set. "musbListener" implements SerialInputOutputManager.Listener. The callback function (a musbListener's method) is as shown below.

@Override
public void onNewData(final byte[] DataBuff) {
    Log.d("DataBuff",DataBuff.toString());
    final float[] Data = decode(DataBuff);
    ...
}

Let's see Logcat.

D/SerialInputOutputManager: Read data len=14 I expect for Android to receive full 42 bytes data, but only 14 bytes are received.

Please tell me what I should do to solve this problem.

kai-morich commented 3 years ago

please check FAQ 1 and 2

ghost commented 3 years ago

Thank you.