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.cpp
- Revision:
- 13:6c520cfc50b2
- Parent:
- 12:8dbe4f4c1216
--- a/SDShell.cpp Fri May 17 19:04:09 2013 +0000 +++ b/SDShell.cpp Mon May 27 15:00:05 2013 +0000 @@ -325,14 +325,21 @@ char *SDShell::bcat(char *cmd) { - uint8_t buf[4] = {NULL}; + //uint8_t buf[4] = {NULL}; + memset(_buf, 0, 512); FILE *fp= fopen(_newpath, "rb"); if (fp != NULL) { while (!feof(fp)) { - fread(buf, 1, 1, fp); - _com->putc(buf[0]); + //fread(buf, 1, 1, fp); + //_com->putc(buf[0]); + fread(_buf, 1, 512, fp); + //_com->write(_buf, 512); + for(int i=0; i<512; i++) + { + _com->putc(_buf[i]); + } } fclose(fp); } @@ -385,11 +392,6 @@ return (char *)OK; } -//fseek(fp, 0L, SEEK_END); -//sz = ftell(fp); -//You can then seek back to the beginning: -//fseek(fp, 0L, SEEK_SET); - char *SDShell::du(char *cmd) { uint32_t file_size = 0; @@ -398,11 +400,6 @@ FILE *fp= fopen(_newpath, "rb"); if (fp != NULL) { -// while (!feof(fp)) -// { -// uint32_t tmp = fread(_buf, 1, 512, fp); -// file_size += tmp; -// } fseek(fp, 0L, SEEK_END); file_size = ftell(fp); fseek(fp, 0L, SEEK_SET);