Simple embedded shell with runtime pluggable commands.

Dependents:   DataBus2018

Implements a simple unix-like shell for embedded systems with a pluggable command architecture.

Committer:
shimniok
Date:
Sun Dec 02 17:20:15 2018 +0000
Revision:
4:8b8fa59d0015
Parent:
3:ebb4893f033d
Child:
6:4da092220ba8
Initial implementation of command lookup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:49820d5a38c9 1 #include "mbed.h"
shimniok 0:49820d5a38c9 2
shimniok 2:4f0affdb7db9 3 typedef struct {
shimniok 2:4f0affdb7db9 4 char *command;
shimniok 2:4f0affdb7db9 5 Callback<void()> cb;
shimniok 2:4f0affdb7db9 6 } command_entry_t;
shimniok 2:4f0affdb7db9 7
shimniok 2:4f0affdb7db9 8
shimniok 0:49820d5a38c9 9 class SimpleShell {
shimniok 0:49820d5a38c9 10 public:
shimniok 0:49820d5a38c9 11 SimpleShell();
shimniok 0:49820d5a38c9 12
shimniok 3:ebb4893f033d 13 void run();
shimniok 1:998a7ed04f10 14 void attach(Callback<void()> cb, char *command);
shimniok 3:ebb4893f033d 15 Callback<void()> findCommand();
shimniok 0:49820d5a38c9 16
shimniok 0:49820d5a38c9 17 private:
shimniok 4:8b8fa59d0015 18 static const int MAXBUF=32;
shimniok 2:4f0affdb7db9 19 static const int MAXLOOKUP=32;
shimniok 0:49820d5a38c9 20 void printPrompt(void);
shimniok 0:49820d5a38c9 21 void readCommand();
shimniok 2:4f0affdb7db9 22 command_entry_t lookup[MAXLOOKUP];
shimniok 2:4f0affdb7db9 23 int lookupEnd;
shimniok 0:49820d5a38c9 24 char cmd[MAXBUF];
shimniok 0:49820d5a38c9 25 char _cwd[MAXBUF];
shimniok 0:49820d5a38c9 26 }; // class