|
|
@ -185,6 +185,36 @@ bool FeiTeServoMotor::read_detailed_status(uint8_t id, detailed_status_t* detail |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool FeiTeServoMotor::read_voltage(uint8_t id, int32_t* val) { |
|
|
|
zlock_guard l(m_mutex); |
|
|
|
uint8_t buf[2]; |
|
|
|
bool suc = read_u8(id, kRegServoCurrentVoltage, buf[0]); |
|
|
|
*val = buf[0]; |
|
|
|
return suc; |
|
|
|
} |
|
|
|
bool FeiTeServoMotor::read_temperature(uint8_t id, int32_t* val) { |
|
|
|
zlock_guard l(m_mutex); |
|
|
|
uint8_t buf[2]; |
|
|
|
bool suc = read_u8(id, kRegServoCurrentTemp, buf[0]); |
|
|
|
*val = buf[0]; |
|
|
|
return suc; |
|
|
|
} |
|
|
|
bool FeiTeServoMotor::read_error_state(uint8_t id, int32_t* val) { |
|
|
|
zlock_guard l(m_mutex); |
|
|
|
uint8_t buf[2]; |
|
|
|
bool suc = read_u8(id, kRegServoStatus, buf[0]); |
|
|
|
*val = buf[0]; |
|
|
|
return suc; |
|
|
|
} |
|
|
|
bool FeiTeServoMotor::read_electric_current(uint8_t id, int32_t* val) { |
|
|
|
zlock_guard l(m_mutex); |
|
|
|
uint16_t buf; |
|
|
|
bool suc = read_u16(id, kRegServoCurrentCurrent, buf); |
|
|
|
*val = buf * 6.5; |
|
|
|
return suc; |
|
|
|
} |
|
|
|
|
|
|
|
void FeiTeServoMotor::dump_status(status_t* status) { |
|
|
|
ZLOGI(TAG, "===========status==========="); |
|
|
|
ZLOGI(TAG, "= status->pos :%d", status->pos); |
|
|
@ -320,11 +350,11 @@ bool FeiTeServoMotor::write_reg(uint8_t id, bool async, uint8_t add, uint8_t* da |
|
|
|
uint8_t checksum = checksum_packet((uint8_t*)cmd_header, txpacketlen); |
|
|
|
m_txbuf[txpacketlen - 1] = checksum; |
|
|
|
if (!tx_and_rx(m_txbuf, txpacketlen, m_rxbuf, rxpacketlen, OVERTIME)) { |
|
|
|
ZLOGE(TAG, "%d write_reg fail,overtime",id); |
|
|
|
ZLOGE(TAG, "%d write_reg fail,overtime", id); |
|
|
|
return false; |
|
|
|
} |
|
|
|
if (!(receipt_header->header == 0xffff && receipt_header->id == id)) { |
|
|
|
ZLOGE(TAG, "%d write_reg fail,receipt header error",id); |
|
|
|
ZLOGE(TAG, "%d write_reg fail,receipt header error", id); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|