A UNIX emulation shell to access the underlying SDCard FileSystem through a terminal interface
Information
Dependencies not included with library:
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"); }
Diff: SDShell.h
- Revision:
- 0:618e98bf18ce
- Child:
- 1:514f321aa528
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDShell.h Fri Apr 26 06:31:03 2013 +0000 @@ -0,0 +1,47 @@ + +#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 +