pulls data from SD and parses 1 line

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
nlougen33
Date:
Thu Nov 10 21:53:02 2016 +0000
Commit message:
:)

Changed in this revision

4DGL-uLCD-SE.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 956fa5e51717 4DGL-uLCD-SE.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/4DGL-uLCD-SE.lib	Thu Nov 10 21:53:02 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/4180_1/code/4DGL-uLCD-SE/#2cb1845d7681
diff -r 000000000000 -r 956fa5e51717 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Thu Nov 10 21:53:02 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
diff -r 000000000000 -r 956fa5e51717 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 10 21:53:02 2016 +0000
@@ -0,0 +1,83 @@
+//SD Import from scratch 
+
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "uLCD_4DGL.h"
+uLCD_4DGL uLCD(p28,p27,p29);
+SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+ 
+const int MAX_CHARS_PER_LINE = 17;
+const int MAX_TOKENS_PER_LINE = 4; 
+const char* const DELIMITER = " "; 
+
+int main() {
+    // file reading object
+    FILE *fp = fopen("/sd/mydir/sdtest.txt", "r");
+    char mytext[15];
+//    fread(mytext, 15, 1, fp);
+ //   uLCD.printf("%s", mytext);
+    char buf[MAX_CHARS_PER_LINE];
+   // read each line of file 
+    //while (!feof(fp)) // while not end of file
+    while (fgets(buf, sizeof(buf), fp)) 
+     {  
+        // read an entire line into memory 
+        //fgets(buf,MAX_CHARS_PER_LINE,fp); //need to check this out 
+        
+        //parse line into blank-delimited tokens
+        int n=0; // for-loop index
+        
+       // array to store memory addresses of the tokens in buf
+       const char* token[MAX_TOKENS_PER_LINE] = {}; // initialize to 0
+        
+        char * pch;
+        //printf ("Splitting string \"%s\" into tokens:\n",str);
+        uLCD.printf("original buf: %s\n", buf);
+        pch = strtok (buf," ");
+        while (pch != NULL)
+        {
+            uLCD.printf("%s\n",pch);
+            pch = strtok (NULL, " ");
+        }
+        
+       // parse line 
+       /*
+       token[0]=strtok(buf,DELIMITER); //reminder token 
+       {
+      for (n = 1; n < MAX_TOKENS_PER_LINE; n++)
+      {
+        token[n] = strtok(, DELIMITER); // subsequent tokens
+        if (!token[n]) break; // no more tokens
+      }
+    }*/
+   
+    // process  the tokens
+    /*
+    for (int i = 0; i < n; i++) // n = #of tokens
+
+        uLCD.printf("%s",token[i]);
+    */
+   fclose(fp);
+  }
+}
+       
+        
+
+ //   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);
+
+ 
+
+    
+    
\ No newline at end of file
diff -r 000000000000 -r 956fa5e51717 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 10 21:53:02 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file