K64F based data logger for GPS (ublox MAX M8Q) & 6 Axis Sensor (FXOS8700Q) - Outputs to SD + UDP - Uses FRDM K64F + ublox "Cellular and positioning shield" (3G version)
Dependencies: MAX_M8Q_Capture EthernetInterface FXOS8700Q SDFileSystem eCompass_FPU_Lib mbed-rtos mbed
Diff: sd.cpp
- Revision:
- 0:77857a36b4ff
- Child:
- 2:bcd60a69583f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sd.cpp Fri Mar 27 08:35:29 2015 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" +#include "SDFileSystem.h" +//#include "main.h" + +int sd_append(char*); + +SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS +FILE *fp; +//Serial pc(USBTX, USBRX); +char buffer[1024]; + +double utc = 123456.34; +double mg = 123.4; +double la = 12345.67; + +int sd_append(char* CSVOutput) { + printf("Initializing \n"); + wait(2); + + fp = fopen("/sd/metaData.csv", "r"); + if (fp != NULL) { + fclose(fp); + //remove("/sd/hello.txt"); + printf("Could not open file\n"); + } + + + printf("\r\nAppending data to the sd card \r\n"); + fp = fopen("/sd/metaData.csv", "a"); + if (fp == NULL) { + printf("Unable to write the file \r\n"); + } else { + fprintf(fp, "%s", CSVOutput); + fclose(fp); + printf("File successfully written! \r\n"); + } + +/* + printf("\nReading data from the SD card. \r\n"); + fp = fopen("/sd/metaData.csv", "r"); + if (fp != NULL) { + int size = fread(buffer, sizeof(char), 1024, fp); + printf("Number of data read: %d, text from hello.txt file: %s \r\n", size, buffer); + fclose(fp); + } + //printf("End of Lab 4. \n"); +*/ + return 0; +}