Waiting for debugger to connect...
Program started.
Serial1.Open
astream.Initialize
astream.Close
java.lang.NegativeArraySizeException: -1
at jssc.SerialNativeInterface.readBytes(Native Method)
at jssc.SerialPort.readBytes(SerialPort.java:437)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:165)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:157)
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:216)
at java.base/java.lang.Thread.run(Thread.java:834)
Serial1.Close
This warning does not cause the application to stop.
But it fails to catch the error for treatment using try catch.
This warning appears when the astream is closed.
This warning appears even though the serial port is not receiving data or sending data.
B4X:
Log("astream.Close")
astream.Close
Sleep(1000)
Log("Serial1.Close")
Serial1.Close
It seems that this warning is not considered an error, so it is not caught with these subroutines:
B4X:
Sub AStream_Error
Log("AStream_Error")
Log(LastException)
End Sub
Sub AStream_Terminated
Log("AStream_Terminated")
End Sub
Does anyone know how to prevent this error from appearing in the LOG?
Reference: [B4X] AsyncStreams Tutorial
Errors
The Error event will be raised if there is any error. You can use LastException to find the reason for the error. In most cases you will want to close the connection when an error occurs.