"
Dependencies: SDFileSystem mbed
Fork of SD_ReadWrite_K64 by
Diff: SD.cpp
- Revision:
- 3:a9c142f24ede
- Parent:
- 2:b441f859191d
--- a/SD.cpp Tue May 16 13:36:53 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -#pragma once -#include "SD.h" -#include "SDFileSystem.h" -#include <string> -#include <sstream> -#include <string> -SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); //mosi, miso, sclk, cs -Serial pc(USBTX, USBRX); - -namespace VivesCityGame{ - std::string SD::read(void){ - FILE *fp1 =fopen("/sd/test.json", "r"); - if(fp1==NULL) { - error("Could not open file for read!\r\n"); - } else { - printf("Reading from SD card...\r\n"); - while((c=fgetc(fp1)) && c!=EOF) { - words[n]=c; - n++; - } - } - fclose(fp1); - ss << words; - ss >> s; - return s; - } - void SD::writen(){ - while(pc.readable()) { - pc.gets(buffer, 2); - if(buffer=="") { - printf("Niks doorgestuurd"); - } else { - strcat(received, buffer); - ontvangen = 1; - } - } - if(ontvangen){ - ontvangen = 0; - FILE *fp = fopen("/sd/test.json", "w");; //w overwrite's, a appands to file - if(fp == NULL) { - error("Could not open file for write!\r\n"); - }else{ - printf("Writing to SD card...\r\n"); - fprintf(fp, received); - fclose(fp); - } - } -} -} \ No newline at end of file