| 122 | } |
| 123 | |
| 124 | void JsonConsole::readInputFromSerial() FL_NOEXCEPT { |
| 125 | if (!mReadAvailableCallback || !mReadCallback) { |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | // Read available characters |
| 130 | while (mReadAvailableCallback() > 0) { |
| 131 | int ch = mReadCallback(); |
| 132 | if (ch == -1) { |
| 133 | break; // No more data |
| 134 | } |
| 135 | |
| 136 | char c = static_cast<char>(ch); |
| 137 | |
| 138 | if (c == '\n' || c == '\r') { |
| 139 | // End of command - execute it |
| 140 | if (!mInputBuffer.empty()) { |
| 141 | executeCommand(mInputBuffer); |
| 142 | mInputBuffer.clear(); |
| 143 | } |
| 144 | } else if (c == '\b' || c == 127) { // Backspace or DEL |
| 145 | if (!mInputBuffer.empty()) { |
| 146 | mInputBuffer = mInputBuffer.substring(0, mInputBuffer.size() - 1); |
| 147 | } |
| 148 | } else if (c >= 32 && c <= 126) { // Printable ASCII |
| 149 | mInputBuffer.write(c); |
| 150 | } |
| 151 | // Ignore other control characters |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | void JsonConsole::parseCommand(const fl::string& command) FL_NOEXCEPT { |
| 156 | FL_WARN("JsonConsole::parseCommand: Parsing command '" << command.c_str() << "'"); |