MCPcopy Create free account
hub / github.com/FastLED/FastLED / readBytes

Method readBytes

src/fl/system/serial.cpp.hpp:179–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179size_t SerialPort::readBytes(u8* buffer, size_t length) {
180 if (!buffer || length == 0) {
181 return 0;
182 }
183
184 size_t count = 0;
185 u32 startTime = fl::millis();
186
187 while (count < length && (fl::millis() - startTime < mTimeoutMs)) {
188 if (available() > 0) {
189 int c = read();
190 if (c != -1) {
191 buffer[count++] = static_cast<u8>(c);
192 startTime = fl::millis(); // Reset timeout on successful read
193 }
194 }
195 }
196
197 return count;
198}
199
200size_t SerialPort::readBytesUntil(char delimiter, u8* buffer, size_t length) {
201 if (!buffer || length == 0) {

Callers 1

FL_TEST_FILEFunction · 0.45

Calls 3

millisFunction · 0.50
availableFunction · 0.50
readFunction · 0.50

Tested by 1

FL_TEST_FILEFunction · 0.36