2021千草のl432(センサー)側プログラム
Dependencies: BufferedSerial SDFileSystem mbed
Diff: main.cpp
- Revision:
- 6:c9e732e94d7f
- Parent:
- 5:15559c6d6a5f
--- a/main.cpp Sat Sep 10 06:11:36 2022 +0000 +++ b/main.cpp Sat Sep 10 10:17:09 2022 +0000 @@ -25,12 +25,14 @@ int sig=0; Ticker comm; char str[10]; +char NichromeCom[11]={0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; int getSignal(); //f303からのコマンドを受け取る関数 //void JY901(); //JY901が取得した生データをSDに書き込む関数 void getGPS(); //GPSデータを取得し、f303に送信する関数 void StandbyCommand(); void MakeFile(); +void writeNichrome(); int main() { @@ -38,14 +40,14 @@ unsigned char CalibMag[5]={0xFF,0xAA,0x01,0x02,0x00}; unsigned char SetHeight[5]={0xFF,0xAA,0x01,0x03,0x00}; unsigned char ExitCalib[5]={0xFF,0xAA,0x01,0x00,0x00}; - comm.attach(StandbyCommand,1); //割り込みで1秒ごとにf303からのコマンドを取得 + comm.attach(StandbyCommand,0.4); //割り込みで1秒ごとにf303からのコマンドを取得 /********************** //センサーのsleepモードを終わらせて、キャリブレーションを開始する関数 *****************/ jy901.write(CalibGyroAcc,5); - wait(30); + wait(45); jy901.write(CalibMag,5); wait(30); jy901.write(SetHeight,5); @@ -67,12 +69,21 @@ //printf("StandbyCommand start\r\n"); sig=getSignal(); switch(sig) { - case 2: + + /*case 1: //ニクロム線作動 + fputc("0x55",fp); + printf("Nichrome ON!!\r\n"); + for(int i=0; i<10;i++){ + fputc("0x00",fp); + } + break;*/ + + case 2: //フライトピン //comm.detach(); MakeFile(); break; - case 3: + case 3: //ブザー作動 comm.detach(); while(1) { getGPS(); @@ -84,14 +95,17 @@ void MakeFile() { mkdir("/sd/2021MR", 0777); - FILE *fp = fopen("/sd/2021MR/chigusa.bin", "w"); + FILE *fp = fopen("/sd/2021MR/chigusa.bin", "wb"); if(fp == NULL) { error("Could not open file for write\n"); } while(sig!=3) { fputc(jy901.getc(),fp); - //JY901(); + if(sig==1){ + fwrite(&NichromeCom,sizeof(NichromeCom[0]),sizeof(NichromeCom),fp); + sig=2; + } } fclose(fp); } @@ -246,6 +260,4 @@ } j++; } - - } \ No newline at end of file