ใช้สื่อสารกันระหว่าง Brain และ Motion
Dependencies: Fork_Boss_Communication_Robot
Dependents: Program_BEAR_Protocol SwitchMode MPU9250AHRS-PGear_Stabilizer SwitchMode ... more
Diff: BEAR_Protocol.cpp
- Revision:
- 11:b34eababcf56
- Parent:
- 10:2398eeafa967
- Child:
- 12:6296cb35f853
diff -r 2398eeafa967 -r b34eababcf56 BEAR_Protocol.cpp --- a/BEAR_Protocol.cpp Fri Jan 22 02:25:26 2016 +0000 +++ b/BEAR_Protocol.cpp Fri Jan 22 10:21:37 2016 +0000 @@ -817,21 +817,21 @@ -uint8_t Bear_Communicate::setBodyLength(uint8_t id,float body_length) +uint8_t Bear_Communicate::setBodyWidth(uint8_t id,float body_width) { - uint8_t IntBodyLength[2],FloatBodyLength[2]; - FloatSep(body_length,IntBodyLength,FloatBodyLength); + uint8_t IntBodyWidth[2],FloatBodyWidth[2]; + FloatSep(body_width,IntBodyWidth,FloatBodyWidth); ANDANTE_PROTOCOL_PACKET package; package.robotId = id; package.length = 7; package.instructionErrorId = WRITE_DATA; - package.parameter[0]=BODY_LENGTH; - package.parameter[1]=IntBodyLength[0]; - package.parameter[2]=IntBodyLength[1]; - package.parameter[3]=FloatBodyLength[0]; - package.parameter[4]=FloatBodyLength[1]; + package.parameter[0]=BODY_WIDTH; + package.parameter[1]=IntBodyWidth[0]; + package.parameter[2]=IntBodyWidth[1]; + package.parameter[3]=FloatBodyWidth[0]; + package.parameter[4]=FloatBodyWidth[1]; rs485_dirc=1; wait_us(RS485_DELAY); @@ -841,16 +841,16 @@ -uint8_t Bear_Communicate::getBodyLength(uint8_t id,float *body_length) +uint8_t Bear_Communicate::getBodyWidth(uint8_t id,float *body_width) { - uint8_t IntBodyLength[2],FloatBodyLength[2]; + uint8_t IntBodyWidth[2],FloatBodyWidth[2]; float int_buffer,float_buffer; ANDANTE_PROTOCOL_PACKET package; package.robotId = id; package.length = 3; package.instructionErrorId = READ_DATA; - package.parameter[0]=BODY_LENGTH; + package.parameter[0]=BODY_WIDTH; rs485_dirc=1; @@ -861,13 +861,13 @@ wait_us(RS485_DELAY); uint8_t status=com->receiveCommunicatePacket(&package); if(status == ANDANTE_ERRBIT_NONE) { - IntBodyLength[0]=package.parameter[0]; - IntBodyLength[1]=package.parameter[1]; - FloatBodyLength[0]=package.parameter[2]; - FloatBodyLength[1]=package.parameter[3]; - int_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(IntBodyLength); - float_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(FloatBodyLength)/FLOAT_CONVERTER; - *body_length=int_buffer+float_buffer; + IntBodyWidth[0]=package.parameter[0]; + IntBodyWidth[1]=package.parameter[1]; + FloatBodyWidth[0]=package.parameter[2]; + FloatBodyWidth[1]=package.parameter[3]; + int_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(IntBodyWidth); + float_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(FloatBodyWidth)/FLOAT_CONVERTER; + *body_width=int_buffer+float_buffer; } return status; }