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:
- 8:30aa615d4508
- Parent:
- 7:7892fcd8a1ad
- Child:
- 9:5e1764ff5dfa
--- a/SDShell.cpp Wed May 08 04:08:16 2013 +0000 +++ b/SDShell.cpp Wed May 08 06:16:46 2013 +0000 @@ -87,7 +87,7 @@ { _cmdline[i] = 0; // clearing the next loc before using it is faster than memset c = _com->getc(); // get a char - if (c == '\r') // process on "enter" + if ((c == '\r') || (c == '\n')) // process on "enter" { done = 1; } @@ -298,21 +298,14 @@ char *SDShell::bcat(char *cmd) { - char buf[2] = {NULL}; + uint8_t buf[4] = {NULL}; FILE *fp= fopen(_newpath, "rb"); if (fp != NULL) { while (!feof(fp)) { - uint32_t size = fread(_buf, 1, 1, fp); - if (size == 1) - { - _com->putc(_buf[0]); - } - else - { - WARN("size != 1"); - } + fread(buf, 1, 1, fp); + _com->putc(buf[0]); } fclose(fp); }