|
|
@ -6,18 +6,18 @@ using namespace std; |
|
|
|
|
|
|
|
#define PROCESS_PACKET_BEGIN(var_cmdid, var_moduleType) \
|
|
|
|
int32_t* param __attribute__((__unused__)) = (int32_t*)data; \ |
|
|
|
int paramNum __attribute__((__unused__)) = (len - sizeof(cmd_header_t)) / sizeof(int32_t); \ |
|
|
|
int paramNum __attribute__((__unused__)) = (len - sizeof(zcr_cmd_header_t)) / sizeof(int32_t); \ |
|
|
|
if (cmdid == var_cmdid) { \ |
|
|
|
auto* mod = dynamic_cast<var_moduleType*>(module); \ |
|
|
|
if (mod == nullptr) { \ |
|
|
|
m_cancmder->sendErrorAck(rxcmd, err::koperation_not_support); \ |
|
|
|
m_cancmder->sendErrorAck(rxcmd, err::koperation_not_support); \ |
|
|
|
return; \ |
|
|
|
} |
|
|
|
|
|
|
|
#define CHECK_PARAM_NUM(num) \
|
|
|
|
if (paramNum != num) { \ |
|
|
|
#define CHECK_PARAM_NUM(num) \
|
|
|
|
if (paramNum != num) { \ |
|
|
|
m_cancmder->sendErrorAck(rxcmd, err::kcmd_param_num_error); \ |
|
|
|
return; \ |
|
|
|
return; \ |
|
|
|
} |
|
|
|
|
|
|
|
#define PROCESS_PACKET_XX_END(ackNum) \
|
|
|
@ -58,12 +58,18 @@ using namespace std; |
|
|
|
#define PROCESS_PACKET_32(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 3, 2, param[0], param[1], param[2], &ack[1], &ack[2])
|
|
|
|
#define PROCESS_PACKET_33(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 3, 3, param[0], param[1], param[2], &ack[1], &ack[2], &ack[3])
|
|
|
|
|
|
|
|
#define PROCESS_PACKET_40(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 4, 0, param[0], param[1], param[2], param[3])
|
|
|
|
#define PROCESS_PACKET_41(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 4, 1, param[0], param[1], param[2], param[3], &ack[1])
|
|
|
|
#define PROCESS_PACKET_42(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 4, 2, param[0], param[1], param[2], param[3], &ack[1], &ack[2])
|
|
|
|
#define PROCESS_PACKET_43(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 4, 3, param[0], param[1], param[2], param[3], &ack[1], &ack[2], &ack[3])
|
|
|
|
|
|
|
|
|
|
|
|
void ZIProtocolParser::initialize(IZCanCmder* cancmder) { |
|
|
|
m_cancmder = cancmder; |
|
|
|
m_cancmder->registerListener(this); |
|
|
|
} |
|
|
|
void ZIProtocolParser::registerModule(uint16_t id, ZIModule* module) { m_modulers[id] = module; } |
|
|
|
void ZIProtocolParser::onRceivePacket(cmd_header_t* rxcmd, uint8_t* data, int32_t len) { |
|
|
|
void ZIProtocolParser::onRceivePacket(zcr_cmd_header_t* rxcmd, uint8_t* data, int32_t len) { |
|
|
|
uint16_t submoduleid = rxcmd->submoduleid; |
|
|
|
auto it = m_modulers.find(submoduleid); |
|
|
|
if (it == m_modulers.end()) { |
|
|
@ -96,6 +102,12 @@ void ZIProtocolParser::onRceivePacket(cmd_header_t* rxcmd, uint8_t* data, int32_ |
|
|
|
PROCESS_PACKET_30(kmotor_move_by, ZIMotor, motor_move_by); |
|
|
|
PROCESS_PACKET_30(kmotor_move_to, ZIMotor, motor_move_to); |
|
|
|
PROCESS_PACKET_20(kmotor_move_to_with_torque, ZIMotor, motor_move_to_with_torque); |
|
|
|
PROCESS_PACKET_30(kmotor_rotate_acctime, ZIMotor, motor_rotate_acctime); |
|
|
|
PROCESS_PACKET_30(kmotor_move_by_acctime, ZIMotor, motor_move_by_acctime); |
|
|
|
PROCESS_PACKET_30(kmotor_move_to_acctime, ZIMotor, motor_move_to_acctime); |
|
|
|
PROCESS_PACKET_40(kmotor_move_to_zero_forward, ZIMotor, motor_move_to_zero_forward); |
|
|
|
PROCESS_PACKET_40(kmotor_move_to_zero_backward, ZIMotor, motor_move_to_zero_backward); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* xymotor * |
|
|
|
*******************************************************************************/ |
|
|
|