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
Diff: main.cpp
- Revision:
- 3:61e7dda0c14d
- Parent:
- 2:43801dc371d0
- Child:
- 4:6e9a233c748d
--- a/main.cpp Wed Dec 16 05:39:37 2020 +0000 +++ b/main.cpp Wed Dec 16 06:30:01 2020 +0000 @@ -3,42 +3,49 @@ Serial pc(SERIAL_TX, SERIAL_RX); Serial device(PA_9,PA_10); -void doppler(){ //データを取得し、出力する関数 - while(1){ +void doppler() //データを取得し、出力する関数 +{ + int data[10] = {0}; + int flag = 0; + while(1) { char c = device.getc(); - if(c == 0x00) - ; - if(c == 0xfd){ //FD(終了コマンドがきたら終了 - break; - } - else{ - printf("%02hhx ",c); + if(c == 0x00) + ; + if(c == 0xfd) { //FD(終了コマンドがきたら終了 + for(int i = 0; i < flag; i++) + printf("%d ", data[i]); + break; + } + else{ + printf("%02hhx ",c); + data[flag] = (c >> 4)&0xf; + data[flag + 1] = c&0xf; + flag += 2; } } } - -int main() -{ - device.baud(9600); - pc.baud(921600); - while(1) { - char c = device.getc(); + + int main() { + device.baud(9600); + pc.baud(921600); + while(1) { + char c = device.getc(); + + if(c == 0xfe) { //FEコマンドがきたらdataが始まる - if(c == 0xfe) { //FEコマンドがきたらdataが始まる - - while(1) { - c = device.getc(); - if(c == 0x00){ //サブコマンドがきたらデータ部分を読み取り始める - - doppler(); - printf("\r\n"); - break; + while(1) { + c = device.getc(); + if(c == 0x00) { //サブコマンドがきたらデータ部分を読み取り始める + + doppler(); + printf("\r\n"); + break; } - + + } } } } -}