LPC's HardwareSerial lacks readStringUntil(), so read the line manually.
| 55 | |
| 56 | // LPC's HardwareSerial lacks readStringUntil(), so read the line manually. |
| 57 | int readLineNative(char delimiter, char* out, int outLen) FL_NOEXCEPT { |
| 58 | if (outLen <= 0) { |
| 59 | return 0; |
| 60 | } |
| 61 | const unsigned long timeoutMs = 1000UL; |
| 62 | unsigned long start = fl::millis(); |
| 63 | int len = 0; |
| 64 | while (true) { |
| 65 | if (!Serial.available()) { |
| 66 | if (fl::millis() - start >= timeoutMs) { |
| 67 | break; |
| 68 | } |
| 69 | fl::yield(); |
| 70 | continue; |
| 71 | } |
| 72 | const int value = Serial.read(); |
| 73 | if (value < 0) { |
| 74 | break; |
| 75 | } |
| 76 | const char c = static_cast<char>(value); |
| 77 | if (c == delimiter) { |
| 78 | break; |
| 79 | } |
| 80 | if (len < outLen - 1) { |
| 81 | out[len++] = c; |
| 82 | } |
| 83 | start = fl::millis(); |
| 84 | } |
| 85 | out[len] = '\0'; |
| 86 | return len; |
| 87 | } |
| 88 | |
| 89 | bool flush(u32 timeoutMs) FL_NOEXCEPT { |
| 90 | (void)timeoutMs; |