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"); }
SDShell.h@0:618e98bf18ce, 2013-04-26 (annotated)
- Committer:
- sam_grove
- Date:
- Fri Apr 26 06:31:03 2013 +0000
- Revision:
- 0:618e98bf18ce
- Child:
- 1:514f321aa528
Allow sd card to be accessed through a Serial class. Implementing basic UNIX commands
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 0:618e98bf18ce | 1 | |
sam_grove | 0:618e98bf18ce | 2 | #ifndef SDSHELL_H |
sam_grove | 0:618e98bf18ce | 3 | #define SDSHELL_H |
sam_grove | 0:618e98bf18ce | 4 | |
sam_grove | 0:618e98bf18ce | 5 | #include "mbed.h" |
sam_grove | 0:618e98bf18ce | 6 | #include "SDFileSystem.h" |
sam_grove | 0:618e98bf18ce | 7 | #include "CommHandler.h" |
sam_grove | 0:618e98bf18ce | 8 | |
sam_grove | 0:618e98bf18ce | 9 | class SDShell |
sam_grove | 0:618e98bf18ce | 10 | { |
sam_grove | 0:618e98bf18ce | 11 | private: |
sam_grove | 0:618e98bf18ce | 12 | Serial *_com; |
sam_grove | 0:618e98bf18ce | 13 | SDFileSystem *_storage; |
sam_grove | 0:618e98bf18ce | 14 | CommHandler _cmds; |
sam_grove | 0:618e98bf18ce | 15 | |
sam_grove | 0:618e98bf18ce | 16 | char _cwd[32]; |
sam_grove | 0:618e98bf18ce | 17 | char _path_to_file[64]; |
sam_grove | 0:618e98bf18ce | 18 | |
sam_grove | 0:618e98bf18ce | 19 | #define SHELL_RXBUF_SIZE 64 |
sam_grove | 0:618e98bf18ce | 20 | #define SHELL_RXBUF_MASK (SHELL_RXBUF_SIZE-1) |
sam_grove | 0:618e98bf18ce | 21 | struct |
sam_grove | 0:618e98bf18ce | 22 | { |
sam_grove | 0:618e98bf18ce | 23 | volatile uint32_t loc; |
sam_grove | 0:618e98bf18ce | 24 | char data[SHELL_RXBUF_SIZE]; |
sam_grove | 0:618e98bf18ce | 25 | }_rxbuf; |
sam_grove | 0:618e98bf18ce | 26 | |
sam_grove | 0:618e98bf18ce | 27 | char *ls(char *); |
sam_grove | 0:618e98bf18ce | 28 | char *cd(char *); |
sam_grove | 0:618e98bf18ce | 29 | char *pwd(char *); |
sam_grove | 0:618e98bf18ce | 30 | char *head(char *); |
sam_grove | 0:618e98bf18ce | 31 | char *cat(char *); |
sam_grove | 0:618e98bf18ce | 32 | char *mkdir(char *); |
sam_grove | 0:618e98bf18ce | 33 | char *touch(char *); |
sam_grove | 0:618e98bf18ce | 34 | char *remove(char *); |
sam_grove | 0:618e98bf18ce | 35 | char *resolvePath(char *string); |
sam_grove | 0:618e98bf18ce | 36 | |
sam_grove | 0:618e98bf18ce | 37 | public: |
sam_grove | 0:618e98bf18ce | 38 | SDShell(); |
sam_grove | 0:618e98bf18ce | 39 | |
sam_grove | 0:618e98bf18ce | 40 | void init(void); |
sam_grove | 0:618e98bf18ce | 41 | |
sam_grove | 0:618e98bf18ce | 42 | void shell(Serial &com, SDFileSystem &storage, char *cwd); |
sam_grove | 0:618e98bf18ce | 43 | |
sam_grove | 0:618e98bf18ce | 44 | }; |
sam_grove | 0:618e98bf18ce | 45 | |
sam_grove | 0:618e98bf18ce | 46 | #endif |
sam_grove | 0:618e98bf18ce | 47 |