Simple embedded shell with runtime pluggable commands.
Implements a simple unix-like shell for embedded systems with a pluggable command architecture.
SimpleShell.h
- Committer:
- shimniok
- Date:
- 2018-12-12
- Revision:
- 6:4da092220ba8
- Parent:
- 4:8b8fa59d0015
- Child:
- 7:b58450c94d32
File content as of revision 6:4da092220ba8:
#ifndef __SIMPLESHELL_H #define __SIMPLESHELL_H #include "mbed.h" /** SimpleShell * A simple, flexible, embedded shell with dynamically added shell commands. */ class SimpleShell { public: /// Create a new shell instance SimpleShell(); /// Call this to run the shell in a thread void run(); /** Attaches a shell command * @param cb is the callback function that implements the command * @param command is the string used to invoke the command in the shell */ void attach(Callback<void()> cb, char *command); /** finds and eturns the callback for a command * @return Callback to a function returning void */ Callback<void()> findCommand(); private: typedef struct { char *command; Callback<void()> cb; } command_entry_t; static const int MAXBUF=32; static const int MAXLOOKUP=32; void printPrompt(void); void readCommand(); command_entry_t lookup[MAXLOOKUP]; int lookupEnd; char cmd[MAXBUF]; char _cwd[MAXBUF]; }; // class #endif