明石高専ロボ研 mbedライブラリ
Dependents: MDD_L432KC USB2RS485 pathtracking odometry ... more
Diff: scrp_slave.cpp
- Revision:
- 12:7f0b6e7b9626
- Parent:
- 11:eaf2e3166d20
diff -r eaf2e3166d20 -r 7f0b6e7b9626 scrp_slave.cpp --- a/scrp_slave.cpp Fri Feb 26 18:19:21 2021 +0000 +++ b/scrp_slave.cpp Sat Feb 27 04:16:16 2021 +0000 @@ -42,12 +42,12 @@ wait_data_[i] = false; stx_flag_[i] = false; id_ok_[i] = false; - get_responce_[i] = false; + get_response_[i] = false; } for(int i = 1;i<256;++i){ procs_[i] = NULL; } - responceFunc_ = NULL; + responseFunc_ = NULL; all_receive_ = false; serial_[0] = &port1; if(interrupt_){ @@ -93,8 +93,8 @@ check(1); } -void ScrpSlave::attachResponce(void (*func)(uint8_t id, uint8_t cmd, int16_t responce)){ - responceFunc_ = func; +void ScrpSlave::attachResponse(void (*func)(uint8_t id, uint8_t cmd, int16_t response)){ + responseFunc_ = func; } void ScrpSlave::addCMD(uint8_t cmd, bool (*proc)(int rx_data, int& tx_data)){ @@ -124,7 +124,7 @@ } if(flag){ wait_data_[port] = true;//データ返信待ち - get_responce_[port] = false; + get_response_[port] = false; } uint8_t tx_dataL = tx_data; uint8_t tx_dataH = tx_data >> 8; @@ -153,11 +153,11 @@ } } -bool ScrpSlave::getResponce(uint8_t port){ +bool ScrpSlave::getResponse(uint8_t port){ if(port > 1 || (port == 1 && mode_ < 2)){ return false; } - return get_responce_[port]; + return get_response_[port]; } bool ScrpSlave::isWaiting(uint8_t port){ @@ -173,7 +173,7 @@ return -1; } //データがあるか確認。 - if(get_responce_[port]){ + if(get_response_[port]){ return rx_data_[port]; }else{ return -1; @@ -213,13 +213,13 @@ rx_data_[port] = (int16_t)(tmp_data_[port][2] + ((int16_t)tmp_data_[port][3] << 8)); if(wait_data_[port]){//データ返信待ち時 wait_data_[port] = false; - get_responce_[port] = true; - if(responceFunc_ != NULL){ - responceFunc_(rx_id,rx_cmd,rx_data_[port]); + get_response_[port] = true; + if(responseFunc_ != NULL){ + responseFunc_(rx_id,rx_cmd,rx_data_[port]); } return; - }else if(get_responce_[port]){ - get_responce_[port] = false; + }else if(get_response_[port]){ + get_response_[port] = false; } rx_cmd_ = rx_cmd;//メンバ変数に保存 bool broadcast = (tmp_data_[port][0] == 255);