FastLED 3.10.8
Loading...
Searching...
No Matches

◆ readString()

fl::string fl::SerialPort::readString ( )

Read all available bytes into a string.

Returns
String containing all available data (up to timeout)

Reads characters from serial until no more data is available or timeout expires.

Definition at line 138 of file serial.cpp.hpp.

138 {
139 fl::string result;
140 u32 startTime = fl::millis();
141
142 while (fl::millis() - startTime < mTimeoutMs) {
143 if (available() > 0) {
144 int c = read();
145 if (c != -1) {
146 result += static_cast<char>(c);
147 startTime = fl::millis(); // Reset timeout on successful read
148 }
149 }
150 }
151
152 return result;
153}
int read() FL_NO_EXCEPT
Read next byte from serial input.
int available() FL_NO_EXCEPT
Check how many bytes are available to read.
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References available(), fl::FL_NO_EXCEPT, fl::millis(), mTimeoutMs, and read().

+ Here is the call graph for this function: