Closed boraylog closed 3 years ago
Very likely your write timeout is to short for the amount of data. See https://github.com/mik3y/usb-serial-for-android/wiki/FAQ#How_to_set_timeout_in_codereadcodecodewritecode_methods
What is your baud rate, data length and device type? Please provide full exception including call stack.
You pasted a code snippet, but not the exception type + callstack. You can print to logcat with e.printStackTrace();
or if you don't catch it at all, it will be shown after app crash in Android Studio logcat window.
What is your device type? Should be something like CH340, FT232, ...
thank you very much. I found that the set array is out of bounds. thanks again.
try { val data: ByteArray? = HexUtils.toByteArray(address) usbSerialPort.write(data, 5000) } catch (e: Exception) { ToastUtils.showShort("fail message!-->${e.message}") } fail message!--> length=1000;index=1000 thanks