teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Mon Dec 10 12:29:37 2018 +0000
Revision:
24:c5945aaae777
Parent:
23:79e20be4bc5b
Child:
25:f3a6e7eec9c3
2018/12/10  dbg etc

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
MasashiNomura 22:24c9c2dedca9 28 if(gf_State != SLEEP && gf_State != WAKEUP){
MasashiNomura 22:24c9c2dedca9 29 //リード系
MasashiNomura 22:24c9c2dedca9 30 if (strcmp(g_CmdBuf , "re" )==0 ){gf_Print.bf.e1=true; gf_Print.bf.e2=true;}
MasashiNomura 22:24c9c2dedca9 31 else if (strcmp(g_CmdBuf , "re1" )==0 ){gf_Print.bf.e1=true;}
MasashiNomura 22:24c9c2dedca9 32 else if (strcmp(g_CmdBuf , "re2" )==0 ){gf_Print.bf.e2=true;}
MasashiNomura 22:24c9c2dedca9 33 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;}//リードモーター
MasashiNomura 22:24c9c2dedca9 34 else if (strcmp(g_CmdBuf , "rm1" )==0 ){gf_Print.bf.m1=true;}//リードモーター1
MasashiNomura 22:24c9c2dedca9 35 else if (strcmp(g_CmdBuf , "rm2" )==0 ){gf_Print.bf.m2=true;}//リードモーター2
MasashiNomura 22:24c9c2dedca9 36 else if (strcmp(g_CmdBuf , "rm3" )==0 ){gf_Print.bf.m3=true;}//リードモーター3
MasashiNomura 22:24c9c2dedca9 37 else if (strcmp(g_CmdBuf , "rm4" )==0 ){gf_Print.bf.m4=true;}//リードモーター4
MasashiNomura 22:24c9c2dedca9 38 else if (strcmp(g_CmdBuf , "rg" )==0 ){gf_Print.bf.gy=true;}//リードジャイロ
MasashiNomura 22:24c9c2dedca9 39 else if (strcmp(g_CmdBuf , "ry" )==0 ){gf_Print.bf.yaw=true;}//リード姿勢角ヨー
MasashiNomura 22:24c9c2dedca9 40 else if (strcmp(g_CmdBuf , "rimu")==0 ){gf_Print.bf.yaw=true;gf_Print.bf.gy=true;}//リードIMU
MasashiNomura 22:24c9c2dedca9 41 else if (strcmp(g_CmdBuf , "rs" )==0 ){ }//リードスイッチ
MasashiNomura 22:24c9c2dedca9 42 else if (strcmp(g_CmdBuf , "rfb" )==0 ){gf_Print.bf.fb=true;}//PID制御フィードバック結果
MasashiNomura 22:24c9c2dedca9 43 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;}//パラメータ全表示
MasashiNomura 22:24c9c2dedca9 44 else if (strcmp(g_CmdBuf , "rpP" )==0 ){gf_Print.bf.pp=true;}//パラメータアウターPゲイン表示
MasashiNomura 22:24c9c2dedca9 45 else if (strcmp(g_CmdBuf , "rpp" )==0 ){gf_Print.bf.p=true;}//パラメータPゲイン表示
MasashiNomura 22:24c9c2dedca9 46 else if (strcmp(g_CmdBuf , "rpi" )==0 ){gf_Print.bf.i=true;}//パラメータIゲイン表示
MasashiNomura 22:24c9c2dedca9 47 else if (strcmp(g_CmdBuf , "rpd" )==0 ){gf_Print.bf.d=true;}//パラメータDゲイン表示
MasashiNomura 22:24c9c2dedca9 48
MasashiNomura 22:24c9c2dedca9 49 //設定系
MasashiNomura 22:24c9c2dedca9 50 else if (strcmp(g_CmdBuf , "se1" )==0 ){gf_AxReq[0].bf.req=true; gf_AxReq[0].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 51 else if (strcmp(g_CmdBuf , "se2" )==0 ){gf_AxReq[1].bf.req=true; gf_AxReq[1].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 52 else if (strcmp(g_CmdBuf , "sm1" )==0 ){gf_MtReq[0].bf.req=true; gf_MtReq[0].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 53 else if (strcmp(g_CmdBuf , "sm2" )==0 ){gf_MtReq[1].bf.req=true; gf_MtReq[1].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 54 else if (strcmp(g_CmdBuf , "sm3" )==0 ){gf_MtReq[2].bf.req=true; gf_MtReq[2].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 55 else if (strcmp(g_CmdBuf , "sm4" )==0 ){gf_MtReq[3].bf.req=true; gf_MtReq[3].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 56
MasashiNomura 22:24c9c2dedca9 57 //キャリブレーション
MasashiNomura 22:24c9c2dedca9 58 else if (strcmp(g_CmdBuf , "calyaw")==0 ){gf_Cal.bf.yaw=true;}//
MasashiNomura 22:24c9c2dedca9 59 else if (strcmp(g_CmdBuf , "calgyro")==0 ){gf_Cal.bf.gy=true;}//
MasashiNomura 22:24c9c2dedca9 60 else if (strcmp(g_CmdBuf , "calimu")==0 ){gf_Cal.bf.gy=true;gf_Cal.bf.yaw=true;}//
MasashiNomura 22:24c9c2dedca9 61
MasashiNomura 22:24c9c2dedca9 62 //チェック系
MasashiNomura 22:24c9c2dedca9 63
MasashiNomura 22:24c9c2dedca9 64 //連続モニタ
MasashiNomura 22:24c9c2dedca9 65 else if (strcmp(g_CmdBuf , "mg" )==0 ){gf_Print.bf.gy=true;gf_Mon.bf.gy=true;}//リードジャイロ
MasashiNomura 22:24c9c2dedca9 66 else if (strcmp(g_CmdBuf , "my" )==0 ){gf_Print.bf.yaw=true;gf_Mon.bf.yaw=true;}//リード姿勢角ヨー
MasashiNomura 22:24c9c2dedca9 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
MasashiNomura 22:24c9c2dedca9 68 else if (strcmp(g_CmdBuf , "mfb" )==0 ){gf_Print.bf.fb=true;gf_Mon.bf.fb=true;}//PID制御フィードバック結果
MasashiNomura 22:24c9c2dedca9 69 else if (strcmp(g_CmdBuf , "kill")==0 ){gf_Mon.flg=0;}//モニタ停止
MasashiNomura 22:24c9c2dedca9 70
MasashiNomura 24:c5945aaae777 71 // 開発、デバッグ用コマンド
MasashiNomura 23:79e20be4bc5b 72 else if (strcmp(g_CmdBuf , "stat")==0 ){gf_Print.bf.stat=true;}//ステート表示
MasashiNomura 23:79e20be4bc5b 73 else if (strcmp(g_CmdBuf , "sstatf")==0 ){setStateF((enmHbState)atoi(&g_CmdBuf[arg2pos]));}//ステート強制遷移
MasashiNomura 24:c5945aaae777 74 else if (strcmp(g_CmdBuf , "spidpp")==0 ){g_PidPara.PP = atof(&g_CmdBuf[arg2pos]);gf_PidParaUpdate=true;}//PIDの係数 Pp設定
MasashiNomura 24:c5945aaae777 75 else if (strcmp(g_CmdBuf , "spidp")==0 ){g_PidPara.P = atof(&g_CmdBuf[arg2pos]);gf_PidParaUpdate=true;}//PIDの係数 P設定
MasashiNomura 24:c5945aaae777 76 else if (strcmp(g_CmdBuf , "spidi")==0 ){g_PidPara.I = atof(&g_CmdBuf[arg2pos]);gf_PidParaUpdate=true;}//PIDの係数 I設定
MasashiNomura 24:c5945aaae777 77 else if (strcmp(g_CmdBuf , "spidd")==0 ){g_PidPara.D = atof(&g_CmdBuf[arg2pos]);gf_PidParaUpdate=true;}//PIDの係数 D設定
MasashiNomura 24:c5945aaae777 78 else if (strcmp(g_CmdBuf , "spidimax")==0 ){g_PidPara.IMax = atof(&g_CmdBuf[arg2pos]);gf_PidParaUpdate=true;}//PIDの係数 積分上限値設定
MasashiNomura 24:c5945aaae777 79 else if (strcmp(g_CmdBuf , "spidimin")==0 ){g_PidPara.IMin = atof(&g_CmdBuf[arg2pos]);gf_PidParaUpdate=true;}//PIDの係数 積分下限値設定
MasashiNomura 23:79e20be4bc5b 80
MasashiNomura 23:79e20be4bc5b 81
MasashiNomura 22:24c9c2dedca9 82 //何にも引っ掛からない
MasashiNomura 22:24c9c2dedca9 83 else {sp.printf("command missmatch\r\n"); };
MasashiNomura 22:24c9c2dedca9 84 } else if(gf_State == SLEEP){
MasashiNomura 22:24c9c2dedca9 85 if (strcmp(g_CmdBuf , "sarm" )==0 ){gf_Armed = true;}//アーミングフラグセット テスト用
MasashiNomura 23:79e20be4bc5b 86 else if (strcmp(g_CmdBuf , "dbg" )==0 ){if(gf_Dbg != true) gf_Dbg = true;}//デバッグタスク起動
MasashiNomura 24:c5945aaae777 87 else if (strcmp(g_CmdBuf , "stat")==0 ){gf_Print.bf.stat=true;}//ステート表示
MasashiNomura 23:79e20be4bc5b 88 else if (strcmp(g_CmdBuf , "sstatf")==0 ){setStateF((enmHbState)atoi(&g_CmdBuf[arg2pos]));}//ステート強制遷移
MasashiNomura 22:24c9c2dedca9 89 //何にも引っ掛からない
MasashiNomura 22:24c9c2dedca9 90 else {sp.printf("command missmatch\r\n"); };
MasashiNomura 22:24c9c2dedca9 91 }
MasashiNomura 22:24c9c2dedca9 92 // //リード系
MasashiNomura 22:24c9c2dedca9 93 // if (strcmp(g_CmdBuf , "re" )==0 ){gf_Print.bf.e1=true; gf_Print.bf.e2=true;}
MasashiNomura 22:24c9c2dedca9 94 // else if (strcmp(g_CmdBuf , "re1" )==0 ){gf_Print.bf.e1=true;}
MasashiNomura 22:24c9c2dedca9 95 // else if (strcmp(g_CmdBuf , "re2" )==0 ){gf_Print.bf.e2=true;}
MasashiNomura 22:24c9c2dedca9 96 // 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;}//リードモーター
MasashiNomura 22:24c9c2dedca9 97 // else if (strcmp(g_CmdBuf , "rm1" )==0 ){gf_Print.bf.m1=true;}//リードモーター1
MasashiNomura 22:24c9c2dedca9 98 // else if (strcmp(g_CmdBuf , "rm2" )==0 ){gf_Print.bf.m2=true;}//リードモーター2
MasashiNomura 22:24c9c2dedca9 99 // else if (strcmp(g_CmdBuf , "rm3" )==0 ){gf_Print.bf.m3=true;}//リードモーター3
MasashiNomura 22:24c9c2dedca9 100 // else if (strcmp(g_CmdBuf , "rm4" )==0 ){gf_Print.bf.m4=true;}//リードモーター4
MasashiNomura 22:24c9c2dedca9 101 // else if (strcmp(g_CmdBuf , "rg" )==0 ){gf_Print.bf.gy=true;}//リードジャイロ
MasashiNomura 22:24c9c2dedca9 102 // else if (strcmp(g_CmdBuf , "ry" )==0 ){gf_Print.bf.yaw=true;}//リード姿勢角ヨー
MasashiNomura 22:24c9c2dedca9 103 // else if (strcmp(g_CmdBuf , "rimu")==0 ){gf_Print.bf.yaw=true;gf_Print.bf.gy=true;}//リードIMU
MasashiNomura 22:24c9c2dedca9 104 // else if (strcmp(g_CmdBuf , "rs" )==0 ){ }//リードスイッチ
MasashiNomura 22:24c9c2dedca9 105 // else if (strcmp(g_CmdBuf , "rfb" )==0 ){gf_Print.bf.fb=true;}//PID制御フィードバック結果
MasashiNomura 22:24c9c2dedca9 106 // 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;}//パラメータ全表示
MasashiNomura 22:24c9c2dedca9 107 // else if (strcmp(g_CmdBuf , "rpP" )==0 ){gf_Print.bf.pp=true;}//パラメータアウターPゲイン表示
MasashiNomura 22:24c9c2dedca9 108 // else if (strcmp(g_CmdBuf , "rpp" )==0 ){gf_Print.bf.p=true;}//パラメータPゲイン表示
MasashiNomura 22:24c9c2dedca9 109 // else if (strcmp(g_CmdBuf , "rpi" )==0 ){gf_Print.bf.i=true;}//パラメータIゲイン表示
MasashiNomura 22:24c9c2dedca9 110 // else if (strcmp(g_CmdBuf , "rpd" )==0 ){gf_Print.bf.d=true;}//パラメータDゲイン表示
takeru0x1103 18:5aa48aec9cae 111
MasashiNomura 22:24c9c2dedca9 112 // //設定系
MasashiNomura 22:24c9c2dedca9 113 // else if (strcmp(g_CmdBuf , "se1" )==0 ){gf_AxReq[0].bf.req=true; gf_AxReq[0].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 114 // else if (strcmp(g_CmdBuf , "se2" )==0 ){gf_AxReq[1].bf.req=true; gf_AxReq[1].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 115 // else if (strcmp(g_CmdBuf , "sm1" )==0 ){gf_MtReq[0].bf.req=true; gf_MtReq[0].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 116 // else if (strcmp(g_CmdBuf , "sm2" )==0 ){gf_MtReq[1].bf.req=true; gf_MtReq[1].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 117 // else if (strcmp(g_CmdBuf , "sm3" )==0 ){gf_MtReq[2].bf.req=true; gf_MtReq[2].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 118 // else if (strcmp(g_CmdBuf , "sm4" )==0 ){gf_MtReq[3].bf.req=true; gf_MtReq[3].bf.val=(UINT16)atoi(&g_CmdBuf[arg2pos]);}
MasashiNomura 22:24c9c2dedca9 119 // else if (strcmp(g_CmdBuf , "sarm" )==0 ){gf_Armed = true;}//アーミングフラグセット
takeru0x1103 18:5aa48aec9cae 120
MasashiNomura 22:24c9c2dedca9 121 // //
MasashiNomura 22:24c9c2dedca9 122 // // else if (strcmp(g_CmdBuf , "dbg" )==0 ){}
takeru0x1103 21:78302ecdb661 123
MasashiNomura 22:24c9c2dedca9 124 // //キャリブレーション
MasashiNomura 22:24c9c2dedca9 125 // else if (strcmp(g_CmdBuf , "calyaw")==0 ){gf_Cal.bf.yaw=true;}//
MasashiNomura 22:24c9c2dedca9 126 // else if (strcmp(g_CmdBuf , "calgyro")==0 ){gf_Cal.bf.gy=true;}//
MasashiNomura 22:24c9c2dedca9 127 // else if (strcmp(g_CmdBuf , "calimu")==0 ){gf_Cal.bf.gy=true;gf_Cal.bf.yaw=true;}//
takeru0x1103 18:5aa48aec9cae 128
MasashiNomura 22:24c9c2dedca9 129 // //チェック系
takeru0x1103 18:5aa48aec9cae 130
MasashiNomura 22:24c9c2dedca9 131 // //連続モニタ
MasashiNomura 22:24c9c2dedca9 132 // else if (strcmp(g_CmdBuf , "mg" )==0 ){gf_Print.bf.gy=true;gf_Mon.bf.gy=true;}//リードジャイロ
MasashiNomura 22:24c9c2dedca9 133 // else if (strcmp(g_CmdBuf , "my" )==0 ){gf_Print.bf.yaw=true;gf_Mon.bf.yaw=true;}//リード姿勢角ヨー
MasashiNomura 22:24c9c2dedca9 134 // 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
MasashiNomura 22:24c9c2dedca9 135 // else if (strcmp(g_CmdBuf , "mfb" )==0 ){gf_Print.bf.fb=true;gf_Mon.bf.fb=true;}//PID制御フィードバック結果
MasashiNomura 22:24c9c2dedca9 136 // else if (strcmp(g_CmdBuf , "kill")==0 ){gf_Mon.flg=0;}//モニタ停止
takeru0x1103 21:78302ecdb661 137
MasashiNomura 22:24c9c2dedca9 138 // //何にも引っ掛からない
MasashiNomura 22:24c9c2dedca9 139 // else {sp.printf("command missmatch\r\n"); };
takeru0x1103 18:5aa48aec9cae 140
takeru0x1103 18:5aa48aec9cae 141 //バッファクリア
takeru0x1103 19:4b0fe9a5ec38 142 memset(&g_CmdBuf[0] , 0x00 , sizeof(g_CmdBuf) );
takeru0x1103 19:4b0fe9a5ec38 143
takeru0x1103 18:5aa48aec9cae 144 //フラグ下す
takeru0x1103 18:5aa48aec9cae 145 gf_CmdPrs = false;
takeru0x1103 18:5aa48aec9cae 146 }
takeru0x1103 18:5aa48aec9cae 147
takeru0x1103 18:5aa48aec9cae 148