Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbedTimer SDFileSystem MU2 GPS
Diff: main.cpp
- Revision:
- 3:4f1bac105598
- Parent:
- 2:d6dc5c2224cc
- Child:
- 4:0d087e3f731d
diff -r d6dc5c2224cc -r 4f1bac105598 main.cpp
--- a/main.cpp Sat Aug 03 11:07:03 2019 +0000
+++ b/main.cpp Mon Aug 05 07:44:41 2019 +0000
@@ -1,16 +1,19 @@
#include "mbed.h"
#include "MU2.h"
#include "SDFileSystem.h"
+#include "inletclose.h"
//#include "GPS.h"
-MU2 MuPort(p9,p10);
-SDFileSystem sd(p5, p6, p7, p8, "sd");
+MU2 MuPort(p27,p28);
+SDFileSystem sd(p11, p12, p13, p14, "sd");
//GPS gps(p13,p14);
-Serial gps(p13,p14); //tx, rx
+Serial gps(p9,p10); //tx, rx
+
+Inlet inlet(p26,p15,p16);//モーター出力,感圧センサー1入力,感圧センサー2入力
-DigitalIn flight(p21); //フライトピン
-DigitalOut FIRE(p26); //溶断
+//DigitalIn flight(p21); //フライトピン
+DigitalOut FIRE(p24); //溶断
DigitalOut myled(LED1);
DigitalOut myled3(LED3);
@@ -22,81 +25,119 @@
wait(3);
//FILE* fp1= fopen("/sd/cansat/log3.txt", "w");
- FILE* fp2= fopen("/sd/cansat/gpsdata10.csv", "w");
-
+ FILE* fp2= fopen("/sd/cansat/gpsdata11.csv", "w");
+
/*if(fp1 == NULL || fp2 == NULL)
-{
+ {
(fp1 == NULL) ? fprintf(stderr, "fname1 open error.\n") : fclose(fp1);
(fp2 == NULL) ? fprintf(stderr, "fname2 open error.\n") : fclose(fp2);
return -1;
-}*/
+ }*/
-
+//溶断機構部分
//fprintf(fp1, "CanSat start!\r\n");
- while(1) { //溶断機構
- if (flight==1) {
- wait(2);
- }
-
- else {
- //fprintf(fp1, "Fire!!\r\n");
- //FIRE=1;
- myled=1;//テストようにLED光らせてる
- wait(5);//溶断にかかる時間TBD秒
- //FIRE=0;
- myled=0;
- break;
- }
- }
-
-
+ //fprintf(fp1, "Fire!!\r\n");
+ //FIRE=1;
+ myled=1;//テストようにLED光らせてる
+ wait(5);//溶断にかかる時間TBD秒
+ //FIRE=0;
+ myled=0;
+
+//溶断機構終わり
gps.baud(9600);
char recvGPS=0;
char getGPS[128];
int i=0;
-
+ int timer=0;
+ int count=0;
+
//fprintf(fp1, "GPS start!\r\n");
-
-
-
- while(1) {
- if(gps.readable()) {
-
-
+ while(1)
+ {
+ if(gps.readable())
+ {
recvGPS=gps.getc();
getGPS[i]=recvGPS;
- if(getGPS[i]=='\n') {
+ if(getGPS[i]=='\n')
+ {
- if((getGPS[5]=='G')&&(getGPS[6]=='A')) {
-
- MuPort.send(getGPS);
-
+ if((getGPS[5]=='G')&&(getGPS[6]=='A'))
+ {
+ if(count==10)
+ {
+ MuPort.send(getGPS);
+
/*if(fp == NULL) {
error("Could not open file for write\n");
}*/
-
+
fprintf(fp2, "%s\n",getGPS);
//fclose(fp);
- wait(1);
-
+
+ count=0;
+ }
+ wait(0.1);
}
i=0;
-
}
-
i++;
-
+ timer++;
+ if(timer>150)//落下開始してからTBD秒後whileを抜ける.
+ {
+ break;
+ }
+ count++;
}
// wait(1);
//fclose(fp);
}
+
+ while(1)
+ {
+ if(gps.readable())
+ {
+ recvGPS=gps.getc();
+ getGPS[i]=recvGPS;
+
+ if(getGPS[i]=='\n')
+ {
+
+ if((getGPS[5]=='G')&&(getGPS[6]=='A'))
+ {
+ if(count==10)
+ {
+ MuPort.send(getGPS);
+
+ /*if(fp == NULL) {
+ error("Could not open file for write\n");
+ }*/
+
+ fprintf(fp2, "%s\n",getGPS);
+ //fclose(fp);
+ count=0;
+ }
+ wait(0.1);
+ }
+
+ i=0;
+ }
+ i++;
+ inlet.Close(0.9);
+ count++;
+ }
+
+ // wait(1);
+ //fclose(fp);
+ }
+
+
//fclose(fp1);
fclose(fp2);