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:
- 6:743600852c66
- Parent:
- 5:3417ba8cb1e4
- Child:
- 7:7892fcd8a1ad
--- a/SDShell.cpp Mon May 06 04:04:18 2013 +0000 +++ b/SDShell.cpp Mon May 06 04:09:32 2013 +0000 @@ -304,12 +304,18 @@ { while (!feof(fp)) { - fread(_buf, 1, 1, fp); - buf[1] = btoa(_buf[0]); - buf[0] = btoa(_buf[0]>>4); - //_com->printf("%c%c", buf[0], buf[1]); - _com->putc(buf[0]); - _com->putc(buf[1]); + uint32_t size = fread(_buf, 1, 16, fp); + _com->putc('{'); + for(int i=0; i<size; i++) + { + buf[1] = btoa(_buf[i]); + buf[0] = btoa(_buf[i]>>4); + //_com->printf("%c%c", buf[0], buf[1]); + _com->putc(buf[0]); + _com->putc(buf[1]); + } + _com->putc('}'); + _com->putc('\n'); } fclose(fp); }