Simple embedded shell with runtime pluggable commands.
Implements a simple unix-like shell for embedded systems with a pluggable command architecture.
Diff: SimpleShell.cpp
- Revision:
- 13:a29fb89018e1
- Parent:
- 12:ecf3fc049bca
- Child:
- 14:75b5918090ae
--- a/SimpleShell.cpp Thu Dec 13 09:19:51 2018 +0000 +++ b/SimpleShell.cpp Thu Dec 13 23:26:34 2018 +0000 @@ -1,5 +1,6 @@ #include "SimpleShell.h" #include <ctype.h> +#include <string> #define ESC 0x1b #define UP 0x41 @@ -17,9 +18,10 @@ SimpleShell::SimpleShell() { lookupEnd = 0; + // Built-in shell commands attach(callback(this, &SimpleShell::help), "help"); - // TODO: cd + attach(callback(this, &SimpleShell::pwd), "pwd"); } @@ -33,13 +35,22 @@ } +void SimpleShell::pwd() +{ + puts(_cwd); + return; +} + + void SimpleShell::run() { bool done=false; Callback<void()> cb; //int status; // TODO implement command status return + std::string x; - strcpy(_cwd, "/log"); + // Set current working directory + strncpy(_cwd, "/log", MAXBUF); printf("Type help for assistance.\n"); help();