Redesigned UART command parser with word-based commands.
More...
Redesigned UART command parser with word-based commands.
◆ UartCommandParser()
| UartCommandParser::UartCommandParser |
( |
uart_port_t | uart_port | ) |
|
|
inline |
Construct a UART command parser bound to a specific UART port.
Configures the UART driver for non-blocking reads and line-based parsing. On ESP32-C6, UART0 is often already configured by the console; this constructor tolerates that case.
- Parameters
-
| uart_port | UART port to use (e.g. UART_NUM_0). |
◆ ParseCommand()
| bool UartCommandParser::ParseCommand |
( |
const std::vector< std::string > & | tokens, |
|
|
ParsedCommand & | cmd ) |
|
inlineprivatenoexcept |
Convert tokens into a structured ParsedCommand.
- Parameters
-
| tokens | Token vector as returned by Tokenize(). |
| cmd | Output structured command. |
- Returns
- true if parsing succeeded; false otherwise.
◆ ParseCommandType()
| CommandType UartCommandParser::ParseCommandType |
( |
const std::string & | token | ) |
|
|
inlineprivatenoexcept |
Map a verb token (first token) to a CommandType.
- Parameters
-
| token | Lowercase verb token (e.g. "set", "start"). |
- Returns
- Parsed command type. Unknown verbs map to HELP.
◆ ProcessCommand()
Parse and execute a single command line.
- Parameters
-
| line | Null-terminated command line. |
| motion | Motion controller to operate on. |
- Returns
- true if the command executed successfully; false otherwise.
- Note
- This function routes to the
Handle* command handlers.
◆ ProcessUartCommands()
Poll the UART for input and process complete lines.
Reads any currently buffered bytes (non-blocking) and accumulates them into a line buffer. When a newline is received, the line is executed via ProcessCommand().
- Parameters
-
| motion | Motion controller to operate on. |
- Warning
- This runs in a polling task. Keep per-call work bounded.
◆ Tokenize()
| std::vector< std::string > UartCommandParser::Tokenize |
( |
const char * | line | ) |
|
|
inlineprivatenoexcept |
Split a command line into tokens.
- Splits on whitespace
- Preserves quoted substrings (double quotes)
- Parameters
-
| line | Null-terminated command line string. |
- Returns
- Token vector (may be empty).
◆ line_buffer_
| char UartCommandParser::line_buffer_[256] |
|
private |
◆ line_buffer_pos_
| size_t UartCommandParser::line_buffer_pos_ |
|
private |
◆ RX_BUF_SIZE
| constexpr size_t UartCommandParser::RX_BUF_SIZE = 256 |
|
staticconstexprprivate |
◆ rx_buffer_
| char UartCommandParser::rx_buffer_[256] |
|
private |
◆ uart_port_
| uart_port_t UartCommandParser::uart_port_ |
|
private |
The documentation for this class was generated from the following file: