Closed NortacYWang closed 1 year ago
Thank you Kai, I have tried to setReaderBufferSize in SerialInputOutputManager, but still got no data.
I also tried the read code in the example:
try {
byte[] buffer = new byte[8192];
int len = usbSerialPort.read(buffer, READ_WAIT_MILLIS);
receive(Arrays.copyOf(buffer, len));
} catch (IOException e) {
// when using read with timeout, USB bulkTransfer returns -1 on timeout _and_ errors
// like connection loss, so there is typically no exception thrown here on error
status("connection lost: " + e.getMessage());
disconnect();
}
but still no data received. btw I have tried the android usb serial terminal to test, it did return the string "invalid command". and I am using ReactNative with this library
Thank you (maybe someone can suggest me a RN library? )
I have fixed this by override onNewData function in SerialInputOutputManager.Listener
instead of using usbSerialPort.read
after write to usb immediately
I am trying to retrieve the data from USB, the command is when USB received string "SA+SAQ", it will return related data(string) to the android device.
I have coded the write and read like this:
connect part
I got "OK" which means the usb is connected,
write and read part
the texto always returns empty , even the usb is coded when invalid command received, it will return string "invalid".
can anyone give me some suggestions? I have worked for this project for several days.. got no clue
Thank you very much