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:
- 12:8dbe4f4c1216
- Parent:
- 10:f269775edfdf
- Child:
- 13:6c520cfc50b2
--- a/SDShell.cpp Tue May 14 23:22:29 2013 +0000 +++ b/SDShell.cpp Fri May 17 19:04:09 2013 +0000 @@ -385,6 +385,11 @@ 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; @@ -393,11 +398,14 @@ FILE *fp= fopen(_newpath, "rb"); if (fp != NULL) { - while (!feof(fp)) - { - uint32_t tmp = fread(_buf, 1, 512, fp); - file_size += tmp; - } +// 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); fclose(fp); _com->printf("%d %s\n", file_size, _newpath); }