← All projects

UART Command Shell

Live

EMBEDDED · C++17 · HEAP-FREE

An on-device serial debug shell that runs on constrained targets — no heap, no std::function, no exceptions.

What it is

A command interpreter for embedded devices you can talk to over a UART. It reads a line of input, parses and validates it, and dispatches to the right handler — the kind of debug/diagnostic console real firmware needs on the bench. The whole thing is built to embedded constraints: it never touches the heap, avoids std::function, and reports outcomes with explicit Status codes instead of exceptions.

How it works

Why it's built this way

Every design choice maps to an embedded reality. string_view avoids allocation; function pointers keep the dispatch table small and predictable; explicit Status return codes replace exceptions (which are often banned in safety-critical firmware). It's a compact demonstration of writing modern, clean C++ that still respects the tight budget of a microcontroller.

enum class Status { Ok, Empty, UnknownCommand, BadArguments }; // register a handler — no heap, no std::function shell.register_command("echo", &handle_echo); // dispatch a received line, get an explicit status back Status s = shell.execute("set speed 50");