SD card parse delimiters
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
Revision 1:2d4f37839b50, committed 2016-04-28
- Comitter:
- deronmai
- Date:
- Thu Apr 28 00:48:45 2016 +0000
- Parent:
- 0:bdbd3d6fc5d5
- Commit message:
- sdfile commit
Changed in this revision
4DGL-uLCD-SE.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Thu Apr 28 00:48:45 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/4180_1/code/4DGL-uLCD-SE/#2cb1845d7681
--- a/main.cpp Fri Dec 07 11:25:01 2012 +0000 +++ b/main.cpp Thu Apr 28 00:48:45 2016 +0000 @@ -1,19 +1,85 @@ #include "mbed.h" #include "SDFileSystem.h" + +#include "uLCD_4DGL.h" -SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board +uLCD_4DGL uLCD(p28,p27,p29); + +SDFileSystem sd(p11, p12, p13, p14, "sd"); // the pinout on the mbed Cool Components workshop board int main() { - printf("Hello World!\n"); - - mkdir("/sd/mydir", 0777); + //printf("Hello World!\n"); + + //mkdir("/sd/mydir", 0777); + char c; + FILE *fp = fopen("/sd/mydir/sdtest.txt", "r"); + if(fp == NULL) { + error("Could not open file for read\n"); + } + int count = 0; + int i; + char arr_time[8] = ""; + char hour[3], min[3]; + int arrival_hour; + int arrival_min; + char r_time[8] = ""; + int ready_time = 0; + char start_add[32] = ""; // start location address + char dest_add[32] = ""; // destination address - FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); - if(fp == NULL) { - error("Could not open file for write\n"); + while (!feof(fp)){ // while not end of file + c=fgetc(fp); // get a character/byte from the file + uLCD.printf("%c",c); + if (c == '@') { + count++; // specifies what data (eg. arrival time, ready time, etc) + i = 0; + } + else { + //uLCD.printf("%d",count); + switch (count) { + case 0: // arrival time + arr_time[i] = c; + i++; + break; + case 1: // ready time (min) + r_time[i] = c; + i++; + break; + case 2: // start address + start_add[i] = c; + i++; + break; + case 3: // destination address + dest_add[i] = c; + i++; + break; + default: + error("too many & detected\n"); + break; + } + + //uLCD.printf("Read from file %02x\n\r",c); // and show it in hex format + } } - fprintf(fp, "Hello fun SD Card World!"); + memcpy( hour, &arr_time[0], 2 ); + memcpy( min, &arr_time[3], 2 ); + + arrival_hour = atoi(hour); + arrival_min = atoi(min); + uLCD.printf("\narrival hour is %d\n",arrival_hour); + uLCD.printf("arrival min is %d\n",arrival_min); + + ready_time = atoi(r_time); + //uLCD.printf("\nString ready time is %s",r_time); + uLCD.printf("Ready Time is %d\n",ready_time); + uLCD.printf("start address is %s\n", start_add); + uLCD.printf("dest address is %s\n", dest_add); + + + + + //fprintf(fp, "Hello fun SD Card World!"); fclose(fp); - printf("Goodbye World!\n"); + //printf("Goodbye World!\n"); }