You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Utility code in tpp_LoRa.cpp utilizes the available() method and self-implemented timers to timeout serial I/O communications. There is nothing wrong with this approach. However, the Serial I/O library has these features built-in and the code could be cleaned up accordingly. Specifically, Serial.readString() reads in a string from the serial I/O port. The readString() method has an automatic timeout on it and will return whatever is in the serial buffer (including nothing) when it times out. The default timeout is 1 second (1000 ms). However, this can be changed by using the setTimeout() method. The argument to setTimeout() is a number of milliseconds for the timeout, i.e. Serial.setTimeout(10) sets a 10 ms timeout for the readString() method on the Serial port.
In addition to readString, the library has another method called readStringUntil(). The argument is a char -- the character that will terminate the read and return the string when it is detected. If the termination character is not received within the timeout period, the string will be returned upon timeout.
Utility code in tpp_LoRa.cpp utilizes the available() method and self-implemented timers to timeout serial I/O communications. There is nothing wrong with this approach. However, the Serial I/O library has these features built-in and the code could be cleaned up accordingly. Specifically, Serial.readString() reads in a string from the serial I/O port. The readString() method has an automatic timeout on it and will return whatever is in the serial buffer (including nothing) when it times out. The default timeout is 1 second (1000 ms). However, this can be changed by using the setTimeout() method. The argument to setTimeout() is a number of milliseconds for the timeout, i.e. Serial.setTimeout(10) sets a 10 ms timeout for the readString() method on the Serial port.
In addition to readString, the library has another method called readStringUntil(). The argument is a char -- the character that will terminate the read and return the string when it is detected. If the termination character is not received within the timeout period, the string will be returned upon timeout.
Reference: https://www.arduino.cc/reference/en/language/functions/communication/serial/
The text was updated successfully, but these errors were encountered: