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:
3:ebb4893f033d
Parent:
2:4f0affdb7db9
Child:
4:8b8fa59d0015

File content as of revision 3:ebb4893f033d:

#include "mbed.h"

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


class SimpleShell {
public:  
    SimpleShell();

    void run();
    void attach(Callback<void()> cb, char *command);
    Callback<void()> findCommand();  
    
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