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.
Fork of Scarlet_relay by
Revision 3:92c039aed84a, committed 2018-09-22
- Comitter:
- taknokolat
- Date:
- Sat Sep 22 06:55:34 2018 +0000
- Parent:
- 2:f975d9cb584d
- Commit message:
- a;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f975d9cb584d -r 92c039aed84a main.cpp --- a/main.cpp Tue Sep 18 02:20:23 2018 +0000 +++ b/main.cpp Sat Sep 22 06:55:34 2018 +0000 @@ -1,36 +1,49 @@ #include "mbed.h" //#include "Serial.h" -RawSerial pc(PA_2,PA_3,57600); -//RawSerial uart1(PB_6,PB_7,57600); +RawSerial pc(PA_2,PA_3,115200); +//RawSerial pc(PB_6,PB_7,115200); //Serial MySerial1(PA_2,PA_3); - + char g_landingcommand; void ISR_Serial_Rx() { - - - // シリアルの受信処理 - - char data=pc.getc(); - - + static char SFbuf[16]; + static int bufcounter=0; + + + SFbuf[bufcounter] = pc.getc(); + + + + if(SFbuf[0]=='S'&&bufcounter<5) bufcounter++; + + if(bufcounter==5 && SFbuf[4]=='F'){ + g_landingcommand = SFbuf[1]; + pc.printf("S"); + pc.printf("%c",g_landingcommand); + pc.printf("A"); + pc.printf("A"); + pc.printf("F"); + wait_ms(31); + bufcounter = 0; + memset(SFbuf, 0, strlen(SFbuf)); + } + else if(bufcounter>=5 ){ + //pc.printf("Communication Falsed.\r\n"); + bufcounter = 0; + memset(SFbuf, 0, strlen(SFbuf)); + } + +} - - // メイン処理 - pc.printf("%c",data); - - - - -} int main() { - + // シリアル通信受信の割り込みイベント登録 pc.attach(ISR_Serial_Rx, Serial::RxIrq);