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:
- 1:a8772ca26d1b
- Parent:
- 0:d0f3991839ec
- Child:
- 2:d6dc5c2224cc
--- a/main.cpp Tue Jul 16 12:10:30 2019 +0000
+++ b/main.cpp Tue Jul 30 11:12:09 2019 +0000
@@ -2,67 +2,70 @@
#include "MU2.h"
#include "SDFileSystem.h"
#include "GPS.h"
-#include <string>
-#include <stdio.h>
-#include <string.h>
+
+MU2 MuPort(p9,p10);
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+GPS gps(p13,p14);
+DigitalIn flight(p21); //フライトピン
+DigitalOut FIRE(p26); //溶断
+
+DigitalOut myled(LED1);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
int main()
{
-
- MU2 MuPort(p9,p10);
- SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
-//(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd")
- GPS gps(p13,p14);
- char Message1[128];
- //char Message2[128];
+ //Serial pc(USBTX,USBRX);
+ //pc.baud(9600);
+
+
+ wait(3);
- Serial pc(USBTX,USBRX);
- pc.baud(9600);
-
- FILE* fp;
+ //FILE* fp1=fopen("/sd/cansat/log1.txt", "w");
+ FILE* fp2;
+
+ //fprintf(fp1, "cansat start\r\n");
- while(1) {
- fp = fopen("/sd/gps/gpsdata.txt", "a");//FILEポインタの宣言
- if(fp == NULL) {
- error("Could not open file for write\n");
+ while(1) { //溶断機構
+ if (flight==1) {
+ wait(2);
}
- //char Message[]="12345678901234567890";
- if(gps.getGPGGA()) {
- int len1=strlen(gps.GPSMessage);
+ else {
+ //FIRE=1;
+ myled=1;
+ wait(20);
+ FIRE=0;
+ myled=0;
+ break;
+ }
+ }
+
+
+
- for(int n=0; n<len1+1; n++) {
-
- Message1[n]= gps.GPSMessage[n];
- }
+ while(1) {
- MuPort.send(Message1);
- fprintf(fp, "%s\n", Message1);
- fclose(fp);
+ //MuPort.send(testmessage);
+
- } else {
- /*
- int len2=strlen(gps.eGPSMessage);
-
- char Message2[128];
- for(int n=0; n<len2+1; n++) {
- Message2[n]= gps.eGPSMessage[n];
- }*/
- char errorMessage[] ="Could not get GPS data!";
+ 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);
+ }
- //pc.printf("Could not get GPS data!");
-
-
- MuPort.send(errorMessage);
- fprintf(fp, "%s\n", errorMessage);
- fclose(fp);
-
- }
wait(1);
-
}
}
\ No newline at end of file