A UNIX emulation shell to access the underlying SDCard FileSystem through a terminal interface

Dependents:   Waldo_Embed_V2

Information

SDShell does not change the com baudrate. Access is made using the baud as initialized by the Serial object when passed into the SDShell object

Example

#include "mbed.h"
#include "SDFileSystem.h"
#include "SDShell.h"

Serial com(USBTX, USBRX);
SDFileSystem sd(p11, p12, p13, p14, "sd");
SDShell emulate;

int main()
{
    emulate.init();
    emulate.shell(com, sd, "/sd");
}

SDShell.h

Committer:
sam_grove
Date:
2013-04-26
Revision:
0:618e98bf18ce
Child:
1:514f321aa528

File content as of revision 0:618e98bf18ce:


#ifndef SDSHELL_H
#define SDSHELL_H

#include "mbed.h"
#include "SDFileSystem.h"
#include "CommHandler.h"

class SDShell
{
private:
    Serial       *_com;
    SDFileSystem *_storage;
    CommHandler   _cmds;
    
    char _cwd[32];
    char _path_to_file[64];
    
    #define SHELL_RXBUF_SIZE 64
    #define SHELL_RXBUF_MASK (SHELL_RXBUF_SIZE-1)
    struct
    {
        volatile uint32_t loc;
        char data[SHELL_RXBUF_SIZE];
    }_rxbuf;
        
    char *ls(char *);
    char *cd(char *);
    char *pwd(char *);
    char *head(char *);
    char *cat(char *);
    char *mkdir(char *);
    char *touch(char *);
    char *remove(char *);
    char *resolvePath(char *string);

public:
    SDShell();
    
    void init(void);
    
    void shell(Serial &com, SDFileSystem &storage, char *cwd);
    
};

#endif