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:
- 2:d6dc5c2224cc
- Parent:
- 1:a8772ca26d1b
- Child:
- 3:4f1bac105598
--- a/main.cpp Tue Jul 30 11:12:09 2019 +0000
+++ b/main.cpp Sat Aug 03 11:07:03 2019 +0000
@@ -1,11 +1,13 @@
#include "mbed.h"
#include "MU2.h"
#include "SDFileSystem.h"
-#include "GPS.h"
+//#include "GPS.h"
MU2 MuPort(p9,p10);
SDFileSystem sd(p5, p6, p7, p8, "sd");
-GPS gps(p13,p14);
+//GPS gps(p13,p14);
+Serial gps(p13,p14); //tx, rx
+
DigitalIn flight(p21); //フライトピン
DigitalOut FIRE(p26); //溶断
@@ -16,16 +18,22 @@
int main()
{
- //Serial pc(USBTX,USBRX);
- //pc.baud(9600);
-
-
+
wait(3);
- //FILE* fp1=fopen("/sd/cansat/log1.txt", "w");
- FILE* fp2;
+ //FILE* fp1= fopen("/sd/cansat/log3.txt", "w");
+ FILE* fp2= fopen("/sd/cansat/gpsdata10.csv", "w");
- //fprintf(fp1, "cansat start\r\n");
+ /*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) {
@@ -33,39 +41,66 @@
}
else {
+ //fprintf(fp1, "Fire!!\r\n");
//FIRE=1;
- myled=1;
- wait(20);
- FIRE=0;
+ myled=1;//テストようにLED光らせてる
+ wait(5);//溶断にかかる時間TBD秒
+ //FIRE=0;
myled=0;
break;
}
}
-
-
-
- while(1) {
-
- //MuPort.send(testmessage);
- if(gps.getGPGGA()) {
- MuPort.send(gps.GPSMessage);
- //pc.printf("%s\r\n",gps.GPSMessage);
- fp2 = fopen("/sd/cansat/gpsdata3.csv", "w");//FILEポインタの宣言
- //myled3=1;
- if(fp2 == NULL) {
- error("Could not open file for write\n");
- //myled4=1;
- }
- fprintf(fp2, "%s\n", gps.GPSMessage);
- fclose(fp2);
- }
+ gps.baud(9600);
+ char recvGPS=0;
+ char getGPS[128];
+ int i=0;
+
+ //fprintf(fp1, "GPS start!\r\n");
+
- wait(1);
+ while(1) {
+ if(gps.readable()) {
+
+
+ recvGPS=gps.getc();
+ getGPS[i]=recvGPS;
+
+ if(getGPS[i]=='\n') {
+
+ if((getGPS[5]=='G')&&(getGPS[6]=='A')) {
+
+ MuPort.send(getGPS);
+
+ /*if(fp == NULL) {
+ error("Could not open file for write\n");
+ }*/
+
+ fprintf(fp2, "%s\n",getGPS);
+ //fclose(fp);
+ wait(1);
+ }
+
+ i=0;
+
+ }
+
+ i++;
+
+ }
+
+ // wait(1);
+ //fclose(fp);
}
-}
\ No newline at end of file
+ //fclose(fp1);
+ fclose(fp2);
+
+}
+
+
+