Simple embedded shell with runtime pluggable commands.

Dependents:   DataBus2018

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

SimpleShell.h

Committer:
shimniok
Date:
2018-12-02
Revision:
2:4f0affdb7db9
Parent:
1:998a7ed04f10
Child:
3:ebb4893f033d

File content as of revision 2:4f0affdb7db9:

#include "mbed.h"

typedef struct {
    char *command;
    Callback<void()> cb;
} command_entry_t;


class SimpleShell {
public:  
    SimpleShell();

    void attach(Callback<void()> cb, char *command);
    
//    void registerCommand(char *commandString, char *helpText, Callback<void(float)> cb);
    void run();
    
private:
    static const int MAXBUF=128;
    static const int MAXLOOKUP=32;
    void printPrompt(void);
    void readCommand();
    command_entry_t lookup[MAXLOOKUP];
    int lookupEnd;
    char cmd[MAXBUF];
    char _cwd[MAXBUF];
}; // class