gps
Dependencies: SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
main.cpp@1:6ea35a0ac85d, 2016-02-29 (annotated)
- Committer:
- Nike3221
- Date:
- Mon Feb 29 11:23:34 2016 +0000
- Revision:
- 1:6ea35a0ac85d
- Parent:
- 0:bdbd3d6fc5d5
- Child:
- 2:51d1db448212
gps
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
mbed_official | 0:bdbd3d6fc5d5 | 2 | #include "SDFileSystem.h" |
Nike3221 | 1:6ea35a0ac85d | 3 | |
Nike3221 | 1:6ea35a0ac85d | 4 | Ticker timer; |
mbed_official | 0:bdbd3d6fc5d5 | 5 | SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board |
Nike3221 | 1:6ea35a0ac85d | 6 | Serial gps_line(p28, p27); // tx, rx |
Nike3221 | 1:6ea35a0ac85d | 7 | Serial pc(USBTX, USBRX); // tx, rx |
Nike3221 | 1:6ea35a0ac85d | 8 | DigitalOut myled1(LED1); |
Nike3221 | 1:6ea35a0ac85d | 9 | DigitalOut myled2(LED2); |
Nike3221 | 1:6ea35a0ac85d | 10 | DigitalOut myled3(LED3); |
Nike3221 | 1:6ea35a0ac85d | 11 | DigitalOut myled4(LED4); |
Nike3221 | 1:6ea35a0ac85d | 12 | char gpsc2[200]; |
Nike3221 | 1:6ea35a0ac85d | 13 | int gpsc3; |
Nike3221 | 1:6ea35a0ac85d | 14 | int a,b; |
Nike3221 | 1:6ea35a0ac85d | 15 | int ido; |
Nike3221 | 1:6ea35a0ac85d | 16 | int old_ido,old_kei; |
Nike3221 | 1:6ea35a0ac85d | 17 | FILE *gpsc; |
Nike3221 | 1:6ea35a0ac85d | 18 | |
Nike3221 | 1:6ea35a0ac85d | 19 | void kakiko() |
Nike3221 | 1:6ea35a0ac85d | 20 | { |
Nike3221 | 1:6ea35a0ac85d | 21 | |
Nike3221 | 1:6ea35a0ac85d | 22 | b=0; |
Nike3221 | 1:6ea35a0ac85d | 23 | mkdir("/sd/gps1", 0777);//************************************************************************* |
Nike3221 | 1:6ea35a0ac85d | 24 | myled1 = myled2 = myled3 = myled4 = 1; |
Nike3221 | 1:6ea35a0ac85d | 25 | FILE *gps_date = fopen("/sd/gps1/gps1.txt", "a"); |
Nike3221 | 1:6ea35a0ac85d | 26 | |
Nike3221 | 1:6ea35a0ac85d | 27 | if(gps_date == NULL) { |
Nike3221 | 1:6ea35a0ac85d | 28 | error("Could not open file for write\n"); |
Nike3221 | 1:6ea35a0ac85d | 29 | } |
Nike3221 | 1:6ea35a0ac85d | 30 | while(b!=50){ |
Nike3221 | 1:6ea35a0ac85d | 31 | fputc(gps_line.getc(),gps_date); |
Nike3221 | 1:6ea35a0ac85d | 32 | b++; } |
Nike3221 | 1:6ea35a0ac85d | 33 | fclose(gps_date);//**************************************************************************************** |
Nike3221 | 1:6ea35a0ac85d | 34 | |
Nike3221 | 1:6ea35a0ac85d | 35 | myled1 = myled2 = myled3 = myled4 = 0; |
Nike3221 | 1:6ea35a0ac85d | 36 | printf("Goodbye World!\n"); |
Nike3221 | 1:6ea35a0ac85d | 37 | } |
mbed_official | 0:bdbd3d6fc5d5 | 38 | |
mbed_official | 0:bdbd3d6fc5d5 | 39 | int main() { |
Nike3221 | 1:6ea35a0ac85d | 40 | |
Nike3221 | 1:6ea35a0ac85d | 41 | gps_line.baud(9600); |
Nike3221 | 1:6ea35a0ac85d | 42 | timer.attach(&kakiko,2.0); |
Nike3221 | 1:6ea35a0ac85d | 43 | int i=0; |
Nike3221 | 1:6ea35a0ac85d | 44 | printf("Hello World!\n"); |
mbed_official | 0:bdbd3d6fc5d5 | 45 | |
Nike3221 | 1:6ea35a0ac85d | 46 | for(a=30;a<200;a++) |
Nike3221 | 1:6ea35a0ac85d | 47 | {gpsc2[a]= gps_line.getc(); |
Nike3221 | 1:6ea35a0ac85d | 48 | pc.printf("%c",gpsc2[a]); |
Nike3221 | 1:6ea35a0ac85d | 49 | |
Nike3221 | 1:6ea35a0ac85d | 50 | if(gpsc2[a-21]=='P') |
Nike3221 | 1:6ea35a0ac85d | 51 | {if(gpsc2[a-20]=='G') |
Nike3221 | 1:6ea35a0ac85d | 52 | {if(gpsc2[a-19]=='G') |
Nike3221 | 1:6ea35a0ac85d | 53 | {ido=gpsc2[a-4]*1000+gpsc2[a-3]*100+gpsc2[a-1]*10+gpsc2[a]*1; |
Nike3221 | 1:6ea35a0ac85d | 54 | pc.printf("cc%dcc",ido); |
Nike3221 | 1:6ea35a0ac85d | 55 | |
Nike3221 | 1:6ea35a0ac85d | 56 | mkdir("/sd/ido1", 0777);//************************************************************************* |
Nike3221 | 1:6ea35a0ac85d | 57 | myled1 = myled2 = myled3 = myled4 = 1; |
Nike3221 | 1:6ea35a0ac85d | 58 | FILE *idof = fopen("/sd/ido1/ido1.txt", "a"); |
Nike3221 | 1:6ea35a0ac85d | 59 | |
Nike3221 | 1:6ea35a0ac85d | 60 | if(idof == NULL) { |
Nike3221 | 1:6ea35a0ac85d | 61 | error("Could not open file for write\n"); |
Nike3221 | 1:6ea35a0ac85d | 62 | } |
Nike3221 | 1:6ea35a0ac85d | 63 | |
Nike3221 | 1:6ea35a0ac85d | 64 | fprintf(idof,"%d\n",ido); |
Nike3221 | 1:6ea35a0ac85d | 65 | |
Nike3221 | 1:6ea35a0ac85d | 66 | fclose(idof);//**************************************************************************************** |
Nike3221 | 1:6ea35a0ac85d | 67 | myled1 = myled2 = myled3 = myled4 = 0; |
Nike3221 | 1:6ea35a0ac85d | 68 | }}} |
Nike3221 | 1:6ea35a0ac85d | 69 | if(a>=50) |
Nike3221 | 1:6ea35a0ac85d | 70 | {a=25;} |
Nike3221 | 1:6ea35a0ac85d | 71 | old_ido=ido; |
Nike3221 | 1:6ea35a0ac85d | 72 | |
Nike3221 | 1:6ea35a0ac85d | 73 | |
Nike3221 | 1:6ea35a0ac85d | 74 | }//for |
Nike3221 | 1:6ea35a0ac85d | 75 | |
mbed_official | 0:bdbd3d6fc5d5 | 76 | } |