teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
takeru0x1103
Date:
Wed Dec 05 01:43:55 2018 +0000
Revision:
20:0394e15412c3
Parent:
19:4b0fe9a5ec38
Child:
21:78302ecdb661
1205_?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takeru0x1103 18:5aa48aec9cae 1 #include <string.h>
takeru0x1103 18:5aa48aec9cae 2 #include <stdio.h>
takeru0x1103 18:5aa48aec9cae 3 #include "globalFlags.h"
takeru0x1103 18:5aa48aec9cae 4 #include "hbCommand.h"
takeru0x1103 18:5aa48aec9cae 5
takeru0x1103 18:5aa48aec9cae 6 //-------------------------------------------------------------
takeru0x1103 19:4b0fe9a5ec38 7 //シリアルコマンド解析
takeru0x1103 18:5aa48aec9cae 8 //-------------------------------------------------------------
takeru0x1103 18:5aa48aec9cae 9 void commandParse(){
takeru0x1103 18:5aa48aec9cae 10 //フラグが立ってなければ何もしないで終わる
takeru0x1103 18:5aa48aec9cae 11 if(gf_CmdPrs==false){
takeru0x1103 18:5aa48aec9cae 12 return;
takeru0x1103 18:5aa48aec9cae 13 }
takeru0x1103 18:5aa48aec9cae 14 //フラグを落として以降の処理をする
takeru0x1103 18:5aa48aec9cae 15 gf_CmdPrs=false;
takeru0x1103 18:5aa48aec9cae 16
takeru0x1103 18:5aa48aec9cae 17 //第二引数の開始位置
takeru0x1103 18:5aa48aec9cae 18 UCHAR arg2pos=0;
takeru0x1103 18:5aa48aec9cae 19 while (1) {
takeru0x1103 19:4b0fe9a5ec38 20 if(g_CmdBuf[arg2pos]==NULL){
takeru0x1103 18:5aa48aec9cae 21 arg2pos++;
takeru0x1103 18:5aa48aec9cae 22 break;
takeru0x1103 18:5aa48aec9cae 23 }else{
takeru0x1103 18:5aa48aec9cae 24 arg2pos++;
takeru0x1103 18:5aa48aec9cae 25 }
takeru0x1103 18:5aa48aec9cae 26 }
takeru0x1103 18:5aa48aec9cae 27
takeru0x1103 18:5aa48aec9cae 28 //リード系
takeru0x1103 19:4b0fe9a5ec38 29 if (strcmp(g_CmdBuf , "re" )==0 ){gf_Print.bf.e1=true; gf_Print.bf.e2=true;}
takeru0x1103 20:0394e15412c3 30 else if (strcmp(g_CmdBuf , "re1" )==0 ){gf_Print.bf.e1=true;}
takeru0x1103 20:0394e15412c3 31 else if (strcmp(g_CmdBuf , "re2" )==0 ){gf_Print.bf.e2=true;}
takeru0x1103 20:0394e15412c3 32 else if (strcmp(g_CmdBuf , "rm" )==0 ){gf_Print.bf.m1=true;gf_Print.bf.m2=true;gf_Print.bf.m3=true;gf_Print.bf.m4=true;}//リードモーター
takeru0x1103 20:0394e15412c3 33 else if (strcmp(g_CmdBuf , "rm1" )==0 ){gf_Print.bf.m1=true;}//リードモーター1
takeru0x1103 20:0394e15412c3 34 else if (strcmp(g_CmdBuf , "rm2" )==0 ){gf_Print.bf.m2=true;}//リードモーター2
takeru0x1103 20:0394e15412c3 35 else if (strcmp(g_CmdBuf , "rm3" )==0 ){gf_Print.bf.m3=true;}//リードモーター3
takeru0x1103 20:0394e15412c3 36 else if (strcmp(g_CmdBuf , "rm4" )==0 ){gf_Print.bf.m4=true;}//リードモーター4
takeru0x1103 19:4b0fe9a5ec38 37 else if (strcmp(g_CmdBuf , "rg" )==0 ){gf_Print.bf.gy=true;}//リードジャイロ
takeru0x1103 19:4b0fe9a5ec38 38 else if (strcmp(g_CmdBuf , "ry" )==0 ){gf_Print.bf.yaw=true;}//リード姿勢角ヨー
takeru0x1103 19:4b0fe9a5ec38 39 else if (strcmp(g_CmdBuf , "rimu")==0 ){gf_Print.bf.yaw=true;gf_Print.bf.gy=true;}//リードIMU
takeru0x1103 19:4b0fe9a5ec38 40 else if (strcmp(g_CmdBuf , "rs" )==0 ){ }//リードスイッチ
takeru0x1103 19:4b0fe9a5ec38 41 else if (strcmp(g_CmdBuf , "rfb" )==0 ){gf_Print.bf.fb=true;}//PID制御フィードバック結果
takeru0x1103 19:4b0fe9a5ec38 42 else if (strcmp(g_CmdBuf , "rp" )==0 ){gf_Print.bf.pp=true;gf_Print.bf.p=true;gf_Print.bf.i=true;gf_Print.bf.d=true;}//パラメータ全表示
takeru0x1103 19:4b0fe9a5ec38 43 else if (strcmp(g_CmdBuf , "rpP" )==0 ){gf_Print.bf.pp=true;}//パラメータアウターPゲイン表示
takeru0x1103 19:4b0fe9a5ec38 44 else if (strcmp(g_CmdBuf , "rpp" )==0 ){gf_Print.bf.p=true;}//パラメータPゲイン表示
takeru0x1103 19:4b0fe9a5ec38 45 else if (strcmp(g_CmdBuf , "rpi" )==0 ){gf_Print.bf.i=true;}//パラメータIゲイン表示
takeru0x1103 19:4b0fe9a5ec38 46 else if (strcmp(g_CmdBuf , "rpd" )==0 ){gf_Print.bf.d=true;}//パラメータDゲイン表示
takeru0x1103 18:5aa48aec9cae 47
takeru0x1103 18:5aa48aec9cae 48 //設定系
takeru0x1103 19:4b0fe9a5ec38 49 else if (strcmp(g_CmdBuf , "se1" )==0 ){gf_AxReq[0].bf.req=true; gf_AxReq[0].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
takeru0x1103 19:4b0fe9a5ec38 50 else if (strcmp(g_CmdBuf , "se2" )==0 ){gf_AxReq[1].bf.req=true; gf_AxReq[1].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
takeru0x1103 19:4b0fe9a5ec38 51 else if (strcmp(g_CmdBuf , "sm1" )==0 ){gf_MtReq[0].bf.req=true; gf_MtReq[0].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
takeru0x1103 19:4b0fe9a5ec38 52 else if (strcmp(g_CmdBuf , "sm2" )==0 ){gf_MtReq[1].bf.req=true; gf_MtReq[1].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
takeru0x1103 19:4b0fe9a5ec38 53 else if (strcmp(g_CmdBuf , "sm3" )==0 ){gf_MtReq[2].bf.req=true; gf_MtReq[2].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
takeru0x1103 19:4b0fe9a5ec38 54 else if (strcmp(g_CmdBuf , "sm4" )==0 ){gf_MtReq[3].bf.req=true; gf_MtReq[3].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
takeru0x1103 18:5aa48aec9cae 55
takeru0x1103 18:5aa48aec9cae 56 //キャリブレーション
takeru0x1103 19:4b0fe9a5ec38 57 else if (strcmp(g_CmdBuf , "calyaw")==0 ){gf_Cal.bf.yaw=true;}//
takeru0x1103 19:4b0fe9a5ec38 58 else if (strcmp(g_CmdBuf , "calgyro")==0 ){gf_Cal.bf.gy=true;}//
takeru0x1103 19:4b0fe9a5ec38 59 else if (strcmp(g_CmdBuf , "calimu")==0 ){gf_Cal.bf.gy=true;gf_Cal.bf.yaw=true;}//
takeru0x1103 18:5aa48aec9cae 60
takeru0x1103 18:5aa48aec9cae 61 //チェック系
takeru0x1103 20:0394e15412c3 62 else if (strcmp(g_CmdBuf , "chkmot")==0 ){gf.push(CHK_MOT);}//モーターチェック
takeru0x1103 18:5aa48aec9cae 63
takeru0x1103 18:5aa48aec9cae 64 //連続モニタ
takeru0x1103 19:4b0fe9a5ec38 65 else if (strcmp(g_CmdBuf , "mg" )==0 ){gf_Print.bf.gy=true;gf_Mon.bf.gy=true;}//リードジャイロ
takeru0x1103 19:4b0fe9a5ec38 66 else if (strcmp(g_CmdBuf , "my" )==0 ){gf_Print.bf.yaw=true;gf_Mon.bf.yaw=true;}//リード姿勢角ヨー
takeru0x1103 19:4b0fe9a5ec38 67 else if (strcmp(g_CmdBuf , "mimu")==0 ){gf_Print.bf.yaw=true;gf_Print.bf.gy=true;gf_Mon.bf.yaw=true;gf_Mon.bf.gy=true;}//リードIMU
takeru0x1103 19:4b0fe9a5ec38 68 else if (strcmp(g_CmdBuf , "mfb" )==0 ){gf_Print.bf.fb=true;gf_Mon.bf.fb=true;}//PID制御フィードバック結果
takeru0x1103 19:4b0fe9a5ec38 69 else if (strcmp(g_CmdBuf , "kill")==0 ){gf_Mon.flg=0;}//モニタ停止
takeru0x1103 19:4b0fe9a5ec38 70 else {sp.printf("command missmatch\r\n"); };
takeru0x1103 18:5aa48aec9cae 71
takeru0x1103 18:5aa48aec9cae 72 //バッファクリア
takeru0x1103 19:4b0fe9a5ec38 73 memset(&g_CmdBuf[0] , 0x00 , sizeof(g_CmdBuf) );
takeru0x1103 19:4b0fe9a5ec38 74
takeru0x1103 18:5aa48aec9cae 75 //フラグ下す
takeru0x1103 18:5aa48aec9cae 76 gf_CmdPrs = false;
takeru0x1103 18:5aa48aec9cae 77 }
takeru0x1103 18:5aa48aec9cae 78
takeru0x1103 18:5aa48aec9cae 79