gps
Dependencies: SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
main.cpp
- Committer:
- Nike3221
- Date:
- 2016-02-29
- Revision:
- 2:51d1db448212
- Parent:
- 1:6ea35a0ac85d
File content as of revision 2:51d1db448212:
#include "mbed.h" #include "SDFileSystem.h" Ticker timer; SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board Serial gps_line(p28, p27); // tx, rx Serial pc(USBTX, USBRX); // tx, rx DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); DigitalOut myled4(LED4); char gpsc2[200]; int a,b; int ido; int old_ido,old_kei; FILE *gpsc; void kakiko() { b=0; mkdir("/sd/gps1", 0777);//************************************************************************* myled1 = myled2 = myled3 = myled4 = 1; FILE *gps_date = fopen("/sd/gps1/gps1.txt", "a"); if(gps_date == NULL) { error("Could not open file for write\n"); } while(b!=50){ fputc(gps_line.getc(),gps_date); b++; } fclose(gps_date);//**************************************************************************************** myled1 = myled2 = myled3 = myled4 = 0; printf("Goodbye World!\n"); } int main() { gps_line.baud(9600); timer.attach(&kakiko,2.0); int i=0; printf("Hello World!\n"); for(a=30;a<200;a++) {gpsc2[a]= gps_line.getc(); pc.printf("%c",gpsc2[a]); if(gpsc2[a-21]=='P') {if(gpsc2[a-20]=='G') {if(gpsc2[a-19]=='G') {ido=gpsc2[a-4]*1000+gpsc2[a-3]*100+gpsc2[a-1]*10+gpsc2[a]*1; pc.printf("cc%dcc",ido); mkdir("/sd/ido1", 0777);//************************************************************************* myled1 = myled2 = myled3 = myled4 = 1; FILE *idof = fopen("/sd/ido1/ido1.txt", "a"); if(idof == NULL) { error("Could not open file for write\n"); } fprintf(idof,"%d\n",ido); fclose(idof);//**************************************************************************************** myled1 = myled2 = myled3 = myled4 = 0; }}} if(a>=50) {a=25;} old_ido=ido; }//for }