diff --git a/components/errorcode/errorcode.hpp b/components/errorcode/errorcode.hpp index f3f12aa..5d25a53 100644 --- a/components/errorcode/errorcode.hpp +++ b/components/errorcode/errorcode.hpp @@ -68,6 +68,7 @@ typedef enum { kcommon_error_not_found_y_zero_point = ERROR_CODE(50000, 6), // 未找到零点 kcommon_error_x_leave_away_zero_point_fail = ERROR_CODE(50000, 7), // 离开零点失败 kcommon_error_y_leave_away_zero_point_fail = ERROR_CODE(50000, 8), // 离开零点失败 + kcommon_error_operation_not_support = ERROR_CODE(50000, 9), // 操作不支持 } error_t; } // namespace err diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index a77cd3a..635369c 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -313,7 +313,7 @@ void StepMotorCtrlModule::_motor_move_by(int32_t dpos, int32_t maxv, int32_t acc m_stepM1->setDeceleration(dec); m_stepM1->moveBy(dpos, maxv); } -void StepMotorCtrlModule::_motor_stop(int32_t dec = -1) { +void StepMotorCtrlModule::_motor_stop(int32_t dec) { ZLOGI(TAG, "m%d _motor_stop %d", m_id, dec); if (dec > 0) { m_stepM1->setDeceleration(dec); @@ -331,4 +331,4 @@ void StepMotorCtrlModule::forward_kinematics(int32_t x, int32_t& motor_pos) { if (m_x_shaft) x = -x; x -= m_zero_shift_x; motor_pos = x; -} \ No newline at end of file +} diff --git a/components/step_motor_ctrl_module/step_motor_speed_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_speed_ctrl_module.cpp new file mode 100644 index 0000000..a178a19 --- /dev/null +++ b/components/step_motor_ctrl_module/step_motor_speed_ctrl_module.cpp @@ -0,0 +1,165 @@ +#include "step_motor_speed_ctrl_module.hpp" + +#include "sdk/components/errorcode/errorcode.hpp" +using namespace iflytop; +using namespace iflytop::zcr; +#define TAG "StepMotorSpeedCtrlModule" +void StepMotorSpeedCtrlModule::initialize(int id, IStepperMotor *stepM1) { + m_id = id; + m_stepM1 = stepM1; + + m_lock.init(); + m_thread.init("StepMotorSpeedCtrlModule", 1024, osPriorityNormal); +} + +int32_t StepMotorSpeedCtrlModule::set_acc(uint8_t act, int32_t &acc) { + zlock_guard l(m_lock); + ZLOGI(TAG, "set_acc act:%d acc:%d", act, acc); + if (act == 0) { // read + acc = m_cfg_acc; + } else if (act == 1) { // set + m_cfg_acc = acc; + } else { + return err::kcommon_error_operation_not_support; + } + return 0; +} + +int32_t StepMotorSpeedCtrlModule::set_dec(uint8_t act, int32_t &dec) { + zlock_guard l(m_lock); + ZLOGI(TAG, "set_dec act:%d dec:%d", act, dec); + if (act == 0) { // read + dec = m_cfg_dec; + } else if (act == 1) { // set + m_cfg_dec = dec; + } else { + return err::kcommon_error_operation_not_support; + } + return 0; +} +int32_t StepMotorSpeedCtrlModule::set_break_dec(uint8_t act, int32_t &dec) { + zlock_guard l(m_lock); + ZLOGI(TAG, "set_break_dec act:%d dec:%d", act, dec); + if (act == 0) { // read + dec = m_cfg_break_dec; + } else if (act == 1) { // set + m_cfg_break_dec = dec; + } else { + return err::kcommon_error_operation_not_support; + } + return 0; +} +int32_t StepMotorSpeedCtrlModule::set_max_speed(uint8_t act, int32_t &speed) { + zlock_guard l(m_lock); + ZLOGI(TAG, "set_max_speed act:%d speed:%d", act, speed); + if (act == 0) { // read + speed = m_cfg_max_speed; + } else if (act == 1) { // set + m_cfg_max_speed = abs(speed); + } else { + return err::kcommon_error_operation_not_support; + } + return 0; +} +int32_t StepMotorSpeedCtrlModule::set_distance_scale(uint8_t act, float &distance_scale) { + zlock_guard l(m_lock); + ZLOGI(TAG, "set_distance_scale act:%d distance_scale:%f", act, distance_scale); + if (act == 0) { // read + distance_scale = m_cfg_distance_scale; + } else if (act == 1) { // set + m_cfg_distance_scale = distance_scale; + } else { + return err::kcommon_error_operation_not_support; + } + return 0; +} +int32_t StepMotorSpeedCtrlModule::set_shaft(uint8_t act, bool &shaft) { + zlock_guard l(m_lock); + ZLOGI(TAG, "set_shaft act:%d shaft:%d", act, shaft); + if (act == 0) { // read + shaft = m_x_shaft; + } else if (act == 1) { // set + m_x_shaft = shaft; + m_stepM1->setMotorShaft(shaft); + } else { + return err::kcommon_error_operation_not_support; + } + return 0; +} + +int32_t StepMotorSpeedCtrlModule::enable(bool venable) { + zlock_guard l(m_lock); + ZLOGI(TAG, "enable venable:%d", venable); + m_stepM1->enable(venable); + return 0; +} +int32_t StepMotorSpeedCtrlModule::stop() { + zlock_guard l(m_lock); + ZLOGI(TAG, "stop"); + m_thread.stop(); + m_stepM1->stop(); + return 0; +} +int32_t StepMotorSpeedCtrlModule::brake() { + zlock_guard l(m_lock); + ZLOGI(TAG, "brake"); + m_thread.stop(); + m_stepM1->setDeceleration(m_cfg_break_dec); + m_stepM1->rotate(0); + return 0; +} +int32_t StepMotorSpeedCtrlModule::rotate(int32_t velocity, int32_t acc, int32_t dec) { + zlock_guard l(m_lock); + ZLOGI(TAG, "rotate velocity:%d acc:%d dec:%d", velocity, acc, dec); + if (acc <= 0) acc = m_cfg_acc; + if (dec <= 0) dec = m_cfg_dec; + if (abs(velocity) > m_cfg_max_speed) { + ZLOGW(TAG, "velocity:%d > m_cfg_max_speed:%d", velocity, m_cfg_max_speed); + velocity = m_cfg_max_speed; + } + + m_stepM1->setAcceleration(acc); + m_stepM1->setDeceleration(dec); + m_stepM1->rotate(velocity); + return 0; +} +int32_t StepMotorSpeedCtrlModule::rotate_auto_stop(int32_t velocity, int32_t duration, int32_t acc, int32_t dec, + function callback) { + zlock_guard l(m_lock); + ZLOGI(TAG, "rotate_auto_stop velocity:%d duration:%d acc:%d dec:%d", velocity, duration, acc, dec); + + if (duration < 0) { + ZLOGW(TAG, "duration:%d < 0", duration); + return err::kcommon_error_param_out_of_range; + } + + if (acc <= 0) acc = m_cfg_acc; + if (dec <= 0) dec = m_cfg_dec; + if (abs(velocity) > m_cfg_max_speed) { + ZLOGW(TAG, "velocity:%d > m_cfg_max_speed:%d", velocity, m_cfg_max_speed); + velocity = m_cfg_max_speed; + } + + m_thread.stop(); + m_thread.start([this, duration, acc, dec, velocity, callback]() { + m_stepM1->setAcceleration(acc); + m_stepM1->setDeceleration(dec); + m_stepM1->rotate(velocity); + + int32_t startticket = zos_get_tick(); + bool reachtime = false; + + while (!m_thread.getExitFlag()) { + if (zos_haspassedms(startticket) > duration) { + reachtime = true; + m_stepM1->stop(); + break; + } + osDelay(1); + } + if (callback) callback(reachtime, zos_haspassedms(startticket)); + m_stepM1->stop(); + return; + }); + return 0; +} \ No newline at end of file diff --git a/components/step_motor_ctrl_module/step_motor_speed_ctrl_module.hpp b/components/step_motor_ctrl_module/step_motor_speed_ctrl_module.hpp new file mode 100644 index 0000000..1eec07f --- /dev/null +++ b/components/step_motor_ctrl_module/step_motor_speed_ctrl_module.hpp @@ -0,0 +1,44 @@ +#pragma once +// +#include "sdk/os/zos.hpp" +#include "sdk\components\tmc\basic\tmc_ic_interface.hpp" +#include "sdk\components\zcancmder\zcanreceiver.hpp" + +namespace iflytop { +class StepMotorSpeedCtrlModule { + public: + private: + IStepperMotor *m_stepM1; + int m_id = 0; + + ZThread m_thread; + + zmutex m_lock; + + int32_t m_cfg_acc = 350; + int32_t m_cfg_dec = 350; + int32_t m_cfg_break_dec = 350; + int32_t m_cfg_max_speed = 1000; + + float m_cfg_distance_scale = 853.3333f; // 步进电机 step/s 转换成 rpm + + bool m_x_shaft = false; + + public: + void initialize(int id, IStepperMotor *stepM1); + + int32_t set_acc(uint8_t act, int32_t &acc); + int32_t set_dec(uint8_t act, int32_t &dec); + int32_t set_break_dec(uint8_t act, int32_t &dec); + int32_t set_max_speed(uint8_t act, int32_t &speed); + int32_t set_distance_scale(uint8_t act, float &distance_scale); + int32_t set_shaft(uint8_t act, bool &shaft); + + int32_t enable(bool venable); + int32_t stop(); + int32_t brake(); + int32_t rotate(int32_t velocity, int32_t acc, int32_t dec); + int32_t rotate_auto_stop(int32_t velocity, int32_t duration, int32_t acc, int32_t dec, + function callback); +}; +} // namespace iflytop \ No newline at end of file diff --git a/components/zcancmder/cmd/basic.hpp b/components/zcancmder/cmd/basic.hpp new file mode 100644 index 0000000..aa12b28 --- /dev/null +++ b/components/zcancmder/cmd/basic.hpp @@ -0,0 +1,101 @@ +#pragma once +#include + +#define ZPACKET_STRUCT(ordername, type, ...) \ + typedef struct { \ + __VA_ARGS__ \ + } ordername##_##type##_t + +#define ZPACKET_CMD_ACK(ordername, cmdpara, ackpara) \ + typedef struct { \ + cmdpara \ + } ordername##_##cmd##_t; \ + typedef struct { \ + ackpara \ + } ordername##_##ack##_t + +#define ZPACKET_CMD_ACK_AND_REPORT(ordername, cmdpara, ackpara, reportpara) \ + typedef struct { \ + cmdpara \ + } ordername##_##cmd##_t; \ + typedef struct { \ + ackpara \ + } ordername##_##ack##_t; \ + typedef struct { \ + reportpara \ + } ordername##_##report##_t + +#define PROCESS_PACKET(ordername, varid) \ + if (rxcmd->iscmd(ordername)) { \ + auto* cmd = rxcmd->get_data_as(); \ + auto* ack = (ordername##_##ack##_t*)m_txbuf; \ + auto cmdheader = rxcmd->get_cmdheader(); \ + uint32_t errorcode = 0; \ + if (cmd->id == varid) { \ + ack->id = cmd->id; + +#define END_PROCESS_PACKET() \ + if (errorcode == 0) { \ + m_cancmder->sendAck(rxcmd->get_cmdheader(), m_txbuf, sizeof(*ack)); \ + } else { \ + m_cancmder->sendErrorAck(rxcmd->get_cmdheader(), errorcode); \ + } \ + } \ + return; \ + } +#define CMD(x) x +#define ACK(x) x +#define REPORT(x) x +namespace iflytop { +namespace zcr { + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; + +typedef float f32; +typedef double f64; + +#pragma pack(push, 1) +typedef struct { + uint16_t packetindex; + uint16_t cmdid; + uint8_t subcmdid; + uint8_t packetType; + uint8_t data[]; +} Cmdheader_t; +#pragma pack(pop) + +typedef enum { + kpt_cmd = 0, + kpt_ack = 1, + kpt_error_ack = 2, + kpt_cmd_exec_status_report = 3, +} PacketType_t; + +typedef enum { + kset_cmd_type_read = 0, + kset_cmd_type_set = 1, +} SetCmdOperationType_t; + +typedef enum { + kMotorStopType_stop = 0, + kMotorStopType_break = 1, +} MotorStopType_t; + +#define CMDID(cmdid, subcmdid) ((cmdid << 8) + subcmdid) + +typedef enum { + kmodule_statu_idle, + kmodule_statu_work, + kmodule_statu_exception, +} module_statu_type_t; + +} // namespace zcr +} // namespace iflytop diff --git a/components/zcancmder/cmd/basic_bean.hpp b/components/zcancmder/cmd/basic_bean.hpp deleted file mode 100644 index 98890f7..0000000 --- a/components/zcancmder/cmd/basic_bean.hpp +++ /dev/null @@ -1,148 +0,0 @@ -#pragma once -#include "sdk/os/zos.hpp" -/******************************************************************************* - * MARCO * - *******************************************************************************/ -#define ZPACKET_STRUCT(ordername, type, ...) \ - typedef struct { \ - __VA_ARGS__ \ - } ordername##_##type##_t - -#define PROCESS_PACKET(ordername, varid) \ - if (rxcmd->iscmd(ordername)) { \ - auto* cmd = rxcmd->get_data_as(); \ - auto* ack = (ordername##_##ack##_t*)m_txbuf; \ - auto cmdheader = rxcmd->get_cmdheader(); \ - uint32_t errorcode = 0; \ - if (cmd->id == varid) { \ - ack->id = cmd->id; - -#define END_PROCESS_PACKET() \ - if (errorcode == 0) { \ - m_cancmder->sendAck(rxcmd->get_cmdheader(), m_txbuf, sizeof(*ack)); \ - } else { \ - m_cancmder->sendErrorAck(rxcmd->get_cmdheader(), errorcode); \ - } \ - } \ - return; \ - } - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; - -typedef float f32; -typedef double f64; - -/******************************************************************************* - * STRUCT * - *******************************************************************************/ -namespace iflytop { -namespace zcr { -#pragma pack(push, 1) -typedef struct { - uint16_t packetindex; - uint16_t cmdid; - uint8_t subcmdid; - uint8_t packetType; - uint8_t data[]; -} Cmdheader_t; -#pragma pack(pop) - -typedef enum { - kpt_cmd = 0, - kpt_ack = 1, - kpt_error_ack = 2, - kpt_cmd_exec_status_report = 3, -} PacketType_t; - -#define CMDID(cmdid, subcmdid) ((cmdid << 8) + subcmdid) - -typedef enum { - kcmd_ping = CMDID(0, 0), - kcmd_read_io = CMDID(1, 0), - kcmd_set_io = CMDID(2, 0), - kcmd_readadc_raw = CMDID(3, 0), - - kcmd_m211887_operation = CMDID(1000, 0), // 维萨拉臭氧传感器 - kcmd_read_presure_sensor = CMDID(1001, 0), // 压力传感器 - kcmd_triple_warning_light_ctl = CMDID(1002, 0), // 三色警示灯控制 - kcmd_high_power_electrical_ctl = CMDID(1003, 0), // 大功率电源控制 - kcmd_peristaltic_pump_ctl = CMDID(1004, 0), // 液泵控制 - kcmd_read_huacheng_pressure_sensor = CMDID(1005, 0), // 华诚压力传感器 - - /******************************************************************************* - * 1006 * - *******************************************************************************/ - kcmd_xy_robot_ctrl_enable = CMDID(1006, 0), // 机器人使能 - kcmd_xy_robot_ctrl_stop = CMDID(1006, 1), // 机器人停止 - kcmd_xy_robot_ctrl_move_to_zero = CMDID(1006, 2), // 机器人回零 - kcmd_xy_robot_ctrl_move_to_zero_with_calibrate = CMDID(1006, 3), // 机器人回零并标定 - kcmd_xy_robot_ctrl_move_to = CMDID(1006, 4), // 机器人移动到指定位置 - kcmd_xy_robot_ctrl_move_by = CMDID(1006, 5), // 机器人移动指定距离 - kcmd_xy_robot_ctrl___p1 = CMDID(1006, 6), // 占位指令 - kcmd_xy_robot_ctrl_break = CMDID(1006, 7), // 机器人刹车 - - kcmd_xy_robot_ctrl_read_status = CMDID(1006, 50), // 读取机器人状态 - kcmd_xy_robot_ctrl_read_io = CMDID(1006, 51), // 读取机器人IO - - kcmd_xy_robot_ctrl_set_robottype = CMDID(1006, 100), // 机器人类型 - kcmd_xy_robot_ctrl_set_current_pos = CMDID(1006, 101), // 设置当前位置 - kcmd_xy_robot_ctrl_set_distance_scale = CMDID(1006, 102), // 设置距离比例 - kcmd_xy_robot_ctrl_set_ihold_irun_iholddelay = CMDID(1006, 103), // 设置电流 - kcmd_xy_robot_ctrl_set_acc = CMDID(1006, 104), // 设置加速度 - kcmd_xy_robot_ctrl_set_dec = CMDID(1006, 105), // 设置减速度 - kcmd_xy_robot_ctrl_set_speed = CMDID(1006, 106), // 设置位置模式速度 - kcmd_xy_robot_ctrl_set_shaft = CMDID(1006, 107), // 设置轴是否反向 - kcmd_xy_robot_ctrl_set_runtozero_max_distance = CMDID(1006, 108), // 设置回零最大距离 - kcmd_xy_robot_ctrl_set_runtozero_speed = CMDID(1006, 109), // 设置回零速度 - kcmd_xy_robot_ctrl_set_runtozero_dec = CMDID(1006, 110), // 设置回零减速度 - kcmd_xy_robot_ctrl_set_runtozero_leave_away_zero_distance = CMDID(1006, 111), // 设置离零点距离 - kcmd_xy_robot_ctrl_set_zero_shift = CMDID(1006, 112), // 设置零点偏移 - kcmd_xy_robot_ctrl_set_break_dec = CMDID(1006, 113), // 设置刹车减速度 - - /******************************************************************************* - * 1007:单轴步进电机控制 * - *******************************************************************************/ - - kcmd_step_motor_ctrl_enable = CMDID(1007, 0), // 步进电机使能 - kcmd_step_motor_ctrl_stop = CMDID(1007, 1), // 步进电机停止 - kcmd_step_motor_ctrl_move_to_zero = CMDID(1007, 2), // 步进电机回零 - kcmd_step_motor_ctrl_move_to_zero_with_calibrate = CMDID(1007, 3), // 步进电机回零并标定 - kcmd_step_motor_ctrl_move_to = CMDID(1007, 4), // 步进电机移动到指定位置 - kcmd_step_motor_ctrl_move_by = CMDID(1007, 5), // 步进电机移动指定距离 - kcmd_step_motor_ctrl_rotate = CMDID(1007, 6), // 步进电机rotate - kcmd_step_motor_ctrl_break = CMDID(1007, 7), // 步进电机刹车 - - kcmd_step_motor_ctrl_read_status = CMDID(1007, 50), // 读取机器人状态 - kcmd_step_motor_ctrl_read_io = CMDID(1007, 51), // 读取机器人IO - - kcmd_step_motor_ctrl___p1 = CMDID(1007, 100), // 占位指令 - kcmd_step_motor_ctrl_set_current_pos = CMDID(1007, 101), // 设置当前位置 - kcmd_step_motor_ctrl_set_distance_scale = CMDID(1007, 102), // 设置距离比例 - kcmd_step_motor_ctrl_set_ihold_irun_iholddelay = CMDID(1007, 103), // 设置电流 - kcmd_step_motor_ctrl_set_acc = CMDID(1007, 104), // 设置加速度 - kcmd_step_motor_ctrl_set_dec = CMDID(1007, 105), // 设置减速度 - kcmd_step_motor_ctrl_set_speed = CMDID(1007, 106), // 设置位置模式速度 - kcmd_step_motor_ctrl_set_shaft = CMDID(1007, 107), // 设置轴是否反向 - kcmd_step_motor_ctrl_set_runtozero_max_distance = CMDID(1007, 108), // 设置回零最大距离 - kcmd_step_motor_ctrl_set_runtozero_speed = CMDID(1007, 109), // 设置回零速度 - kcmd_step_motor_ctrl_set_runtozero_dec = CMDID(1007, 110), // 设置回零减速度 - kcmd_step_motor_ctrl_set_runtozero_leave_away_zero_distance = CMDID(1007, 111), // 设置离零点距离 - kcmd_step_motor_ctrl_set_zero_shift = CMDID(1007, 112), // 设置零点偏移 - kcmd_step_motor_ctrl_set_break_dec = CMDID(1007, 113), // 设置断电减速度 - -#if 1 - -#endif - -} CmdID_t; - -} // namespace zcr -} // namespace iflytop diff --git a/components/zcancmder/cmd/basic_cmd.hpp b/components/zcancmder/cmd/basic_cmd.hpp deleted file mode 100644 index 5a4559d..0000000 --- a/components/zcancmder/cmd/basic_cmd.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -#include "basic_bean.hpp" -#include "sdk/os/zos.hpp" - -namespace iflytop { -namespace zcr { - -#pragma pack(push, 1) -typedef struct { - uint8_t boardid; -} kcmd_ping_t; - -typedef struct { - uint8_t boardid; -} kcmd_ping_ack_t; - -typedef struct { - uint8_t ioid; -} kcmd_read_io_t; - -typedef struct { - uint8_t ioid; - uint8_t val; -} kcmd_read_io_ack_t; - -typedef struct { - uint8_t ioid; - uint8_t val; -} kcmd_set_io_t; - -typedef struct { - uint8_t ioid; - uint8_t val; -} kcmd_set_io_ack_t; - -typedef struct { - uint8_t sensorid; -} kcmd_readadc_raw_t; - -typedef struct { - uint8_t sensorid; - uint8_t __p; // padding - int32_t val; -} kcmd_readadc_raw_ack_t; - -#pragma pack(pop) - -} // namespace zcr -} // namespace iflytop diff --git a/components/zcancmder/cmd/c1006_module_cmd.hpp b/components/zcancmder/cmd/c1006_module_cmd.hpp deleted file mode 100644 index b42d630..0000000 --- a/components/zcancmder/cmd/c1006_module_cmd.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once -#include - -#include "basic_bean.hpp" -namespace iflytop { -namespace zcr { - -/******************************************************************************* - * 1006 * - *******************************************************************************/ -#pragma pack(push, 1) -/******************************************************************************* - * CMD * - *******************************************************************************/ -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_enable, /* */ cmd, u8 id; u8 enable;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_stop, /* */ cmd, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to_zero, /* */ cmd, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, /* */ cmd, u8 id; u8 _pad; s32 x; s32 y;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to, /* */ cmd, u8 id; u8 _pad; s32 x; s32 y;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_by, /* */ cmd, u8 id; u8 _pad; s32 dx; s32 dy;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl___p1, /* */ cmd, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_break, /* */ cmd, u8 id; u8 _pad;); - -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_read_status, /* */ cmd, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_read_io, /* */ cmd, u8 id; u8 _pad;); - -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_robottype, /* */ cmd, u8 id; u8 _pad; u8 zero_robottype;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_current_pos, /* */ cmd, u8 id; u8 _pad; s32 x; s32 y;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_distance_scale, /* */ cmd, u8 id; u8 _pad; f32 distance_scale;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_ihold_irun_iholddelay, /* */ cmd, u8 id; u8 _pad; u8 ihold; u8 irun; u16 iholddelay;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_acc, /* */ cmd, u8 id; u8 _pad; s32 acc;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_dec, /* */ cmd, u8 id; u8 _pad; s32 dec;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_speed, /* */ cmd, u8 id; u8 _pad; s32 speed;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_shaft, /* */ cmd, u8 id; u8 _pad; u8 x_shaft; u8 y_shaft;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_max_distance, /* */ cmd, u8 id; u8 _pad; s32 maxX; s32 maxY;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_speed, /* */ cmd, u8 id; u8 _pad; s32 speed;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_dec, /* */ cmd, u8 id; u8 _pad; s32 dec;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_leave_away_zero_distance, /* */ cmd, u8 id; u8 _pad; s32 distance;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_zero_shift, /* */ cmd, u8 id; u8 _pad; s32 x_shift; s32 y_shift;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_break_dec, /* */ cmd, u8 id; u8 _pad; s32 dec;); - -/******************************************************************************* - * ACK * - *******************************************************************************/ - -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_enable, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_stop, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to_zero, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_by, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl___p1, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_break, /* */ ack, u8 id; u8 _pad;); - -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_read_status, /* */ ack, u8 id; u8 _pad; u8 module_statu; s32 x; s32 y;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_read_io, /* */ ack, u8 id; u8 _pad; u8 xzero, yzero; u8 xend, yend;); - -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_robottype, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_current_pos, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_distance_scale, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_ihold_irun_iholddelay, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_acc, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_dec, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_speed, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_shaft, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_max_distance, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_speed, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_dec, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_runtozero_leave_away_zero_distance, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_zero_shift, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_set_break_dec, /* */ ack, u8 id; u8 _pad;); - -/******************************************************************************* - * status_report * - *******************************************************************************/ - -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to_zero, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 dx; s32 dy;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 zero_shift_x; - s32 zero_shift_y;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_to, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 tox; s32 toy;); -ZPACKET_STRUCT(kcmd_xy_robot_ctrl_move_by, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 tox; s32 toy;); - -#pragma pack(pop) - -} // namespace zcr -} // namespace iflytop diff --git a/components/zcancmder/cmd/c1007_module_cmd.hpp b/components/zcancmder/cmd/c1007_module_cmd.hpp deleted file mode 100644 index fd7aa6f..0000000 --- a/components/zcancmder/cmd/c1007_module_cmd.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -#include - -#include "basic_bean.hpp" -namespace iflytop { -namespace zcr { - -/******************************************************************************* - * 1007 * - *******************************************************************************/ -#pragma pack(push, 1) -ZPACKET_STRUCT(kcmd_step_motor_ctrl_enable, /* */ cmd, u8 id; u8 enable;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_stop, /* */ cmd, u8 id;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to_zero, /* */ cmd, u8 id;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to_zero_with_calibrate, /* */ cmd, u8 id;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to, /* */ cmd, u8 id; s32 pos;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_by, /* */ cmd, u8 id; s32 distance;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_rotate, /* */ cmd, u8 id; s32 angle;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_break, /* */ cmd, u8 id;); - -ZPACKET_STRUCT(kcmd_step_motor_ctrl_read_status, /* */ cmd, u8 id;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_read_io, /* */ cmd, u8 id;); - -ZPACKET_STRUCT(kcmd_step_motor_ctrl___p1, /* */ cmd, u8 id;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_current_pos, /* */ cmd, u8 id; s32 pos;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_distance_scale, /* */ cmd, u8 id; s32 scale;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_ihold_irun_iholddelay, /* */ cmd, u8 id; u8 ihold; u8 irun; u8 iholddelay;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_acc, /* */ cmd, u8 id; s32 acc;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_dec, /* */ cmd, u8 id; s32 dec;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_speed, /* */ cmd, u8 id; s32 speed;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_shaft, /* */ cmd, u8 id; u8 shaft;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_max_distance, /* */ cmd, u8 id; s32 max_distance;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_speed, /* */ cmd, u8 id; s32 speed;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_dec, /* */ cmd, u8 id; s32 dec;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_leave_away_zero_distance, /* */ cmd, u8 id; s32 distance;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_zero_shift, /* */ cmd, u8 id; s32 x_shift; s32 y_shift;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_break_dec, /* */ cmd, u8 id; s32 dec;); - -/******************************************************************************* - * ACK * - *******************************************************************************/ -ZPACKET_STRUCT(kcmd_step_motor_ctrl_enable, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_stop, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to_zero, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to_zero_with_calibrate, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_by, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_rotate, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_break, /* */ ack, u8 id; u8 _pad;); - -ZPACKET_STRUCT(kcmd_step_motor_ctrl_read_status, /* */ ack, u8 id; u8 _pad; u8 module_statu; s32 pos; s32 velocity;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_read_io, /* */ ack, u8 id; u8 _pad; u8 zeroio; u8 endio;); - -ZPACKET_STRUCT(kcmd_step_motor_ctrl___p1, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_current_pos, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_distance_scale, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_ihold_irun_iholddelay, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_acc, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_dec, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_speed, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_shaft, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_max_distance, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_speed, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_dec, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_runtozero_leave_away_zero_distance, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_zero_shift, /* */ ack, u8 id; u8 _pad;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_set_break_dec, /* */ ack, u8 id; u8 _pad;); - -/******************************************************************************* - * status_report * - *******************************************************************************/ -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to_zero, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 ddistance;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to_zero_with_calibrate, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 zero_shift;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_to, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 npos;); -ZPACKET_STRUCT(kcmd_step_motor_ctrl_move_by, /* */ status_report, u8 id; u8 _pad; s32 exec_status; s32 ddistance;); - -#pragma pack(pop) - -} // namespace zcr -} // namespace iflytop diff --git a/components/zcancmder/cmd/cmd.hpp b/components/zcancmder/cmd/cmd.hpp index 3587d62..f4ce84f 100644 --- a/components/zcancmder/cmd/cmd.hpp +++ b/components/zcancmder/cmd/cmd.hpp @@ -1,8 +1,547 @@ #pragma once -#include "sdk/os/zos.hpp" -// -#include "basic_bean.hpp" -// -#include "basic_cmd.hpp" -#include "c1006_module_cmd.hpp" +#include +#include "basic.hpp" +namespace iflytop { +namespace zcr { + +typedef enum { + kcmd_ping = CMDID(0, 0), + kcmd_read_io = CMDID(1, 0), + kcmd_set_io = CMDID(2, 0), + kcmd_readadc_raw = CMDID(3, 0), + + kcmd_m211887_operation = CMDID(1000, 0), // 维萨拉臭氧传感器 + kcmd_read_presure_sensor = CMDID(1001, 0), // 压力传感器 + kcmd_triple_warning_light_ctl = CMDID(1002, 0), // 三色警示灯控制 + kcmd_high_power_electrical_ctl = CMDID(1003, 0), // 大功率电源控制 + kcmd_peristaltic_pump_ctl = CMDID(1004, 0), // 液泵控制 + kcmd_read_huacheng_pressure_sensor = CMDID(1005, 0), // 华诚压力传感器 + + /******************************************************************************* + * |Module_1006:XYRobot机器人控制模组 * + *******************************************************************************/ + kcmd_xy_robot_ctrl_enable = CMDID(1006, 0), // 机器人使能 + kcmd_xy_robot_ctrl_stop = CMDID(1006, 1), // 机器人停止 + kcmd_xy_robot_ctrl_move_to_zero = CMDID(1006, 2), // 机器人回零 + kcmd_xy_robot_ctrl_move_to_zero_with_calibrate = CMDID(1006, 3), // 机器人回零并标定 + kcmd_xy_robot_ctrl_move_to = CMDID(1006, 4), // 机器人移动到指定位置 + kcmd_xy_robot_ctrl_move_by = CMDID(1006, 5), // 机器人移动指定距离 + + kcmd_xy_robot_ctrl_read_version = CMDID(1006, 50), // 读取模块型号版本信息 + kcmd_xy_robot_ctrl_read_status = CMDID(1006, 51), // 读取模块精简状态信息 + kcmd_xy_robot_ctrl_read_debug_info = CMDID(1006, 52), // 读取模块详细状态信息 + + kcmd_xy_robot_ctrl_set_run_param = CMDID(1006, 100), // 设置运行参数 + kcmd_xy_robot_ctrl_set_warning_limit_param = CMDID(1006, 101), // 设置控制限制参数 + kcmd_xy_robot_ctrl_set_run_to_zero_param = CMDID(1006, 102), // 设置归零参数 + + /******************************************************************************* + * |Module_1007:步进电机控制模组 * + *******************************************************************************/ + kcmd_step_motor_ctrl_enable = CMDID(1007, 0), // 使能 + kcmd_step_motor_ctrl_stop = CMDID(1007, 1), // 停止 + kcmd_step_motor_ctrl_move_to_zero = CMDID(1007, 2), // 回零 + kcmd_step_motor_ctrl_move_to_zero_with_calibrate = CMDID(1007, 3), // 回零并校准 + kcmd_step_motor_ctrl_move_to = CMDID(1007, 4), // 移动到 + kcmd_step_motor_ctrl_move_by = CMDID(1007, 5), // 相对移动 + kcmd_step_motor_ctrl_rotate = CMDID(1007, 6), // 相对移动 + + kcmd_step_motor_ctrl_read_version = CMDID(1007, 50), // 读取模块型号版本信息 + kcmd_step_motor_ctrl_read_status = CMDID(1007, 51), // 读取模块精简状态信息 + kcmd_step_motor_ctrl_read_debug_info = CMDID(1007, 52), // 读取模块详细状态信息 + + kcmd_step_motor_ctrl_set_run_param = CMDID(1007, 100), // 设置运行参数 + kcmd_step_motor_ctrl_set_warning_limit_param = CMDID(1007, 101), // 设置警告限制参数 + kcmd_step_motor_ctrl_set_run_to_zero_param = CMDID(1007, 102), // 设置归零参数 + + /******************************************************************************* + * |Module_1008:舵机 * + *******************************************************************************/ + kcmd_mini_servo_ctrl_enable = CMDID(1008, 0), // 使能 + kcmd_mini_servo_ctrl_stop = CMDID(1008, 1), // 停止 + kcmd_mini_servo_ctrl_position_calibrate = CMDID(1008, 2), // 校准 + kcmd_mini_servo_ctrl_rotate = CMDID(1008, 3), // 速度模式 + kcmd_mini_servo_ctrl_move_to = CMDID(1008, 4), // 位置模式舵机 + kcmd_mini_servo_ctrl_move_by = CMDID(1008, 5), // 位置模式舵机 + kcmd_mini_servo_ctrl_run_with_torque = CMDID(1008, 6), // 开环扭矩模式 + kcmd_mini_servo_ctrl_move_by_nolimit = CMDID(1008, 7), // 相对移动,位置模式无限制,移动不受最大位置和最小位置限制,但无法读取到当前位置 + + kcmd_mini_servo_ctrl_read_version = CMDID(1008, 50), // 读取模块型号版本信息 + kcmd_mini_servo_ctrl_read_status = CMDID(1008, 51), // 读取模块精简状态信息 + kcmd_mini_servo_ctrl_read_debug_info = CMDID(1008, 52), // 读取模块详细状态信息 + + kcmd_mini_servo_ctrl_set_run_param = CMDID(1008, 100), // 位置限制 最大位置,最小位置 + kcmd_mini_servo_ctrl_set_warning_limit_param = CMDID(1008, 101), // 过压保护设置 最大电压 最小电压 + + /******************************************************************************* + * |Module_1009:EEPROM * + *******************************************************************************/ + kcmd_eeprom_read_block = CMDID(1009, 0), // 读取EEPROM + kcmd_eeprom_write_block = CMDID(1009, 1), // 写入EEPROM + + /******************************************************************************* + * |Module_1010:扫码器 * + *******************************************************************************/ + kcmd_barcode_reader_start_scan = CMDID(1010, 0), // 读取扫码器 + kcmd_barcode_reader_stop_scan = CMDID(1010, 1), // 停止读取扫码器 + + /******************************************************************************* + * |Module_1011:帕尔贴-水泵-风扇控温系统 * + *******************************************************************************/ + // 设置目标温度 + kcmd_heater_ctrl_module_start_ctrl_temperature = CMDID(1011, 0), // 设置目标温度 + kcmd_heater_ctrl_module_read_stop_temperature = CMDID(1011, 1), // 读取停止温度 + + kcmd_heater_ctrl_module_read_version = CMDID(1011, 50), // 读取模块型号版本信息 + kcmd_heater_ctrl_module_read_status = CMDID(1011, 51), // 读取模块精简状态信息 + kcmd_heater_ctrl_module_read_debug_info = CMDID(1011, 52), // 读取模块详细状态信息 + + kcmd_heater_ctrl_module_set_run_param = CMDID(1011, 100), // 设置运行参数 + kcmd_heater_ctrl_module_set_warning_limit_param = CMDID(1011, 101), // 设置限制参数 + + /******************************************************************************* + * |Module_1012:光学模组扫码器 * + *******************************************************************************/ + kcmd_optical_barcode_reader_start_scan = CMDID(1012, 0), // 开始扫码 + kcmd_optical_barcode_reader_stop_scan = CMDID(1012, 1), // 停止扫码 + kcmd_optical_barcode_reader_motor_move_to = CMDID(1012, 4), // 水平电机移动到 + kcmd_optical_barcode_reader_motor_move_to_zero = CMDID(1012, 6), // 电机校准 + kcmd_optical_barcode_reader_motor_move_to_zero_with_calibrate = CMDID(1012, 7), // 电机校准 + kcmd_optical_barcode_reader_motor_stop = CMDID(1012, 8), // 电机停止 + kcmd_optical_barcode_reader_motor_enable = CMDID(1012, 9), // 电机使能 + + kcmd_optical_barcode_reader_read_version = CMDID(1012, 50), // 读取模块型号版本信息 + kcmd_optical_barcode_reader_read_status = CMDID(1012, 51), // 读取模块精简状态信息 + kcmd_optical_barcode_reader_read_debug_info = CMDID(1012, 52), // 读取模块详细状态信息 + + kcmd_optical_barcode_reader_set_run_param = CMDID(1012, 100), // 设置运行参数 + kcmd_optical_barcode_reader_set_warning_limit_param = CMDID(1012, 101), // 设置限制参数 + kcmd_optical_barcode_reader_set_run_to_zero_param = CMDID(1012, 102), // 设置归零参数 + + /******************************************************************************* + * |Module_1013:板夹仓 * + *******************************************************************************/ + + kcmd_board_clamp_module_push_and_scan = CMDID(1013, 0), // 推出反应板并扫码 + kcmd_board_clamp_module_moter_move_to = CMDID(1013, 1), // 电机移动到 + kcmd_board_clamp_module_moter_move_by = CMDID(1013, 2), // 电机移动到 + kcmd_board_clamp_module_moter_move_to_zero = CMDID(1013, 3), // 电机归零 + kcmd_board_clamp_module_moter_move_to_zero_with_calibrate = CMDID(1013, 4), // 电机归零并校准 + kcmd_board_clamp_module_moter_stop = CMDID(1013, 5), // 电机停止 + kcmd_board_clamp_module_moter_enable = CMDID(1013, 6), // 电机使能 + + kcmd_board_clamp_module_read_version = CMDID(1013, 50), // 读取模块型号版本信息 + kcmd_board_clamp_module_read_status = CMDID(1013, 51), // 读取模块精简状态信息 + kcmd_board_clamp_module_read_debug_info = CMDID(1013, 52), // 读取模块详细状态信息 + + kcmd_board_clamp_module_set_run_param = CMDID(1013, 100), // 设置运行参数 + kcmd_board_clamp_module_set_warning_limit_param = CMDID(1013, 101), // 设置限制参数 + kcmd_board_clamp_module_set_run_to_zero_param = CMDID(1013, 102), // 设置归零参数 + + // 风扇 + /******************************************************************************* + * |Module_1014:风扇 * + *******************************************************************************/ + kcmd_fan_module_fan_ctrl = CMDID(1014, 0), // 风扇控制 + kcmd_fan_module_fan_read_status = CMDID(1014, 50), // 读取模块精简状态信息 + kcmd_fan_module_fan_read_debug_info = CMDID(1014, 51), // 读取模块详细状态信息 + + // 串口透传 + /******************************************************************************* + * |Module_1015:串口透传 * + *******************************************************************************/ + kcmd_serial_module_send_data = CMDID(1015, 0), // 串口透传发送数据 + kcmd_serial_module_start_read_data = CMDID(1015, 1), // 串口透传读取数据 + kcmd_serial_module_start_stop_data = CMDID(1015, 2), // 串口透传停止读取数据 + kcmd_serial_module_read_status = CMDID(1015, 50), // 读取模块状态信息 + kcmd_serial_module_set_cfg = CMDID(1015, 100), // 串口透传设置配置 + + // 移液枪控制 + /******************************************************************************* + * |Module_1016:移液枪控制 * + *******************************************************************************/ + kcmd_pipette_module_z_motor_enable = CMDID(1016, 0), // 使能 + kcmd_pipette_module_z_motor_move_to = CMDID(1016, 1), // 移动到 + kcmd_pipette_module_z_motor_move_to_zero = CMDID(1016, 2), // 归零 + kcmd_pipette_module_z_motor_move_to_zero_with_calibrate = CMDID(1016, 3), // 归零并校准 + kcmd_pipette_module_z_motor_stop = CMDID(1016, 4), // 停止 + + kcmd_pipette_module_take_liquid = CMDID(1016, 4), // 取液体 + kcmd_pipette_module_split_liquid = CMDID(1016, 5), // 吐液体 + kcmd_pipette_module_take_tip = CMDID(1016, 6), // 取tip + kcmd_pipette_module_remove_tip = CMDID(1016, 7), // 移除tip + + kcmd_pipette_module_read_version = CMDID(1016, 50), // 读取模块型号版本信息 + kcmd_pipette_module_read_status = CMDID(1016, 51), // 读取模块精简状态信息 + kcmd_pipette_module_read_debug_info = CMDID(1016, 52), // 读取模块详细状态信息 + + kcmd_pipette_module_set_run_param = CMDID(1016, 100), // 设置运行参数 + kcmd_pipette_module_set_warning_limit_param = CMDID(1016, 101), // 设置限制参数 + kcmd_pipette_module_set_run_to_zero_param = CMDID(1016, 102), // 设置归零参数 + +} CmdID_t; + +#pragma pack(push, 1) + +ZPACKET_CMD_ACK(kcmd_ping, // + CMD(u8 boardid;), // + ACK(u8 boardid;)); + +ZPACKET_CMD_ACK(kcmd_read_io, // + CMD(u8 ioid;), // + ACK(u8 ioid; u8 val;)); + +ZPACKET_CMD_ACK(kcmd_set_io, // + CMD(u8 ioid; u8 val;), // + ACK(u8 ioid; u8 val;)); + +ZPACKET_CMD_ACK(kcmd_readadc_raw, // + CMD(u8 sensorid;), // + ACK(u8 sensorid; s32 val;)); + +/******************************************************************************* + * |Module_1006:XYRobot机器人控制模组 * + *******************************************************************************/ +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_enable, + CMD(u8 id; u8 enable;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_stop, + CMD(u8 id; u8 stop_type;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to_zero, + CMD(u8 id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, + CMD(u8 id; s32 nowx; s32 nowy;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 zero_shift_x; s32 zero_shift_y;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to, + CMD(u8 id; s32 x; s32 y; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 x; s32 y;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_by, + CMD(u8 id; s32 dx; s32 dy; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 dx; s32 dy;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_read_version, // + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_read_status, // + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_read_debug_info, // + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_run_param, // + CMD(u8 id; u8 opt_type; u8 shaft; s32 distance_scale; s32 shift_x; s32 shift_y; s32 acc; s32 dec; s32 maxspeed; s32 min_x; s32 max_x; s32 min_y; + s32 max_y;), // + ACK(u8 id; u8 opt_type; u8 shaft; s32 distance_scale; s32 shift_x; s32 shift_y; s32 acc; s32 dec; s32 maxspeed; s32 min_x; s32 max_x; s32 min_y; + s32 max_y;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_warning_limit_param, // + CMD(u8 id; u8 opt_type;), // + ACK(u8 id; u8 opt_type;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_run_to_zero_param, // + CMD(u8 id; u8 opt_type; u32 move_to_zero_max_d; u32 leave_from_zero_max_d; u32 speed; u32 dec;), // + ACK(u8 id; u8 opt_type; u32 move_to_zero_max_d; u32 leave_from_zero_max_d; u32 speed; u32 dec;)); + +/******************************************************************************* + * |Module_1007:步进电机控制模组 * + *******************************************************************************/ +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_enable, + CMD(u8 id; u8 enable;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_stop, + CMD(u8 id; u8 stop_type;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_step_motor_ctrl_move_to_zero, + CMD(u8 id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_step_motor_ctrl_move_to_zero_with_calibrate, + CMD(u8 id; s32 nowx; s32 nowy;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 zero_shift_x;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_step_motor_ctrl_move_to, + CMD(u8 id; s32 x; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; u32 x;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_step_motor_ctrl_move_by, + CMD(u8 id; s32 dx; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 dx;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_step_motor_ctrl_rotate, + CMD(u8 id; s32 speed; s32 run_time;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 has_run_time;)); +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_read_version, // + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_read_status, // + CMD(u8 id;), // + ACK(u8 id; u8 status; s32 x; s32 velocity;)); +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_read_debug_info, // + CMD(u8 id;), // + ACK(u8 id; u8 status; s32 x; s32 velocity; s32 acc; s32 dec; s32 speed;)); +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_set_run_param, // + CMD(u8 id; u8 opt_type; u8 shaft; s32 d_scale; s32 x_shift; s32 acc; s32 dec; s32 breakdec; s32 maxv; s32 minpos; s32 maxpos;), // + ACK(u8 id; u8 opt_type; u8 shaft; s32 d_scale; s32 x_shift; s32 acc; s32 dec; s32 breakdec; s32 maxv; s32 minpos; s32 maxpos;)); +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_set_warning_limit_param, // + CMD(u8 id; u8 opt_type; s32 pad;), // + ACK(u8 id; u8 opt_type; s32 pad;)); +ZPACKET_CMD_ACK(kcmd_step_motor_ctrl_set_run_to_zero_param, // + CMD(u8 id; u8 opt_type; u32 move_to_zero_max_d; u32 leave_from_zero_max_d; u32 speed; u32 dec;), // + ACK(u8 id; u8 opt_type; u32 move_to_zero_max_d; u32 leave_from_zero_max_d; u32 speed; u32 dec;)); + +/******************************************************************************* + * |Module_1008:舵机 * + *******************************************************************************/ + +ZPACKET_CMD_ACK(kcmd_mini_servo_ctrl_enable, + CMD(u8 id; u8 enable;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_mini_servo_ctrl_stop, + CMD(u8 id; u8 stop_type;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_mini_servo_ctrl_position_calibrate, + CMD(u8 id; s32 calibrate_pos;), // + ACK(u8 id;)); + +ZPACKET_CMD_ACK_AND_REPORT(kcmd_mini_servo_ctrl_rotate, + CMD(u8 id; s32 speed; s32 run_time;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 has_run_time;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_mini_servo_ctrl_move_to, + CMD(u8 id; s32 pos; s32 speed; s32 torque;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 pos;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_mini_servo_ctrl_move_by, + CMD(u8 id; s32 pos; s32 speed; s32 torque;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 pos;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_mini_servo_ctrl_run_with_torque, + CMD(u8 id; s32 torque; s32 run_time;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 has_run_time;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_mini_servo_ctrl_move_by_nolimit, + CMD(u8 id; s32 pos; s32 speed; s32 torque;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 pos;)); +/******************************************************************************* + * |Module_1009:EEPROM * + *******************************************************************************/ + +ZPACKET_CMD_ACK(kcmd_eeprom_read_block, + CMD(u8 id; u16 addr; u16 len;), // + ACK(u8 id; u16 addr; u16 len; u8 data[0];)); +ZPACKET_CMD_ACK(kcmd_eeprom_write_block, + CMD(u8 id; u16 addr; u16 len; u8 data[0];), // + ACK(u8 id; u16 addr; u16 len;)); +/******************************************************************************* + * |Module_1010:扫码器 * + *******************************************************************************/ + +ZPACKET_CMD_ACK_AND_REPORT(kcmd_barcode_reader_start_scan, + CMD(u8 id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; u16 barcodelen; u8 barcode[0];)); +ZPACKET_CMD_ACK(kcmd_barcode_reader_stop_scan, + CMD(u8 id;), // + ACK(u8 id;)); +/******************************************************************************* + * |Module_1011:帕尔贴-水泵-风扇控温系统 * + *******************************************************************************/ +ZPACKET_CMD_ACK(kcmd_heater_ctrl_module_start_ctrl_temperature, + CMD(u8 id; s32 target_temperature;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_heater_ctrl_module_read_stop_temperature, + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_heater_ctrl_module_read_version, + CMD(u8 id;), // + ACK(u8 id; uint32_t version;)); +ZPACKET_CMD_ACK(kcmd_heater_ctrl_module_read_status, + CMD(u8 id;), // + ACK(u8 id; u8 status; s32 temperature;)); +ZPACKET_CMD_ACK(kcmd_heater_ctrl_module_read_debug_info, + CMD(u8 id;), // + ACK(u8 id; u8 status; s32 temperature;)); +ZPACKET_CMD_ACK(kcmd_heater_ctrl_module_set_run_param, + CMD(u8 id; u8 opt_type; s32 kp; s32 ki; s32 kd; s32 max_pwm; s32 min_temperature; s32 max_temperature;), // + ACK(u8 id; u8 opt_type; s32 kp; s32 ki; s32 kd; s32 max_pwm; s32 min_temperature; s32 max_temperature;)); +ZPACKET_CMD_ACK(kcmd_heater_ctrl_module_set_warning_limit_param, + CMD(u8 id; u8 opt_type;), // + ACK(u8 id; u8 opt_type;)); + +/******************************************************************************* + * |Module_1012:光学模组扫码器 * + *******************************************************************************/ +ZPACKET_CMD_ACK_AND_REPORT(kcmd_optical_barcode_reader_start_scan, + CMD(u8 id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; u16 codelen; u16 code[0];)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_stop_scan, + CMD(u8 id;), // + ACK(u8 id;)); + +ZPACKET_CMD_ACK_AND_REPORT(kcmd_optical_barcode_reader_motor_move_to, + CMD(u8 id; u8 motor_id; s32 pos; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 pos;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_optical_barcode_reader_motor_move_to_zero, + CMD(u8 id; u8 motor_id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_optical_barcode_reader_motor_move_to_zero_with_calibrate, + CMD(u8 id; u8 motor_id; s32 now_pos;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 zero_shift;)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_motor_stop, + CMD(u8 id; u8 motor_id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_read_version, + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_read_status, + CMD(u8 id;), // + ACK(u8 id; u8 status; u8 hasmove2zero[2]; s32 pos[2];)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_read_debug_info, + CMD(u8 id;), // + ACK(u8 id; u8 status; u8 hasmove2zero[2]; s32 pos[2]; s32 acc[2]; s32 speed[2];)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_set_run_param, // + CMD(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];), // + ACK(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_set_warning_limit_param, + CMD(u8 id; u8 opt_type; s32 pad;), // + ACK(u8 id; u8 opt_type; s32 pad;)); +ZPACKET_CMD_ACK(kcmd_optical_barcode_reader_set_run_to_zero_param, + CMD(u8 id; u8 opt_type; s32 move_to_zero_max_d[2]; s32 leave_from_zero_max_d[2]; s32 speed[2]; s32 dec[2];), // + ACK(u8 id; u8 opt_type; s32 move_to_zero_max_d[2]; s32 leave_from_zero_max_d[2]; s32 speed[2]; s32 dec[2];)); + +/******************************************************************************* + * Module_1013:板夹仓 * + *******************************************************************************/ +ZPACKET_CMD_ACK_AND_REPORT(kcmd_board_clamp_module_push_and_scan, + CMD(u8 id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; u16 barcodelen; u8 barcode[0];)); + +ZPACKET_CMD_ACK_AND_REPORT(kcmd_board_clamp_module_moter_move_to, + CMD(u8 id; u8 motor_id; s32 pos; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 pos;)); + +ZPACKET_CMD_ACK_AND_REPORT(kcmd_board_clamp_module_moter_move_by, + CMD(u8 id; u8 motor_id; s32 pos; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 pos;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_board_clamp_module_moter_move_to_zero, + CMD(u8 id; u8 motor_id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_board_clamp_module_moter_move_to_zero_with_calibrate, + CMD(u8 id; u8 motor_id; s32 now_pos;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 zero_shift;)); +ZPACKET_CMD_ACK(kcmd_board_clamp_module_moter_stop, + CMD(u8 id; u8 motor_id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_board_clamp_module_read_version, + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_board_clamp_module_read_status, + CMD(u8 id;), // + ACK(u8 id; u8 status; u8 hasmove2zero[2]; s32 pos[2];)); +ZPACKET_CMD_ACK(kcmd_board_clamp_module_read_debug_info, + CMD(u8 id;), // + ACK(u8 id; u8 status; u8 hasmove2zero[2]; s32 pos[2]; s32 acc[2]; s32 speed[2];)); +ZPACKET_CMD_ACK(kcmd_board_clamp_module_set_run_param, // + CMD(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];), // + ACK(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];)); +ZPACKET_CMD_ACK(kcmd_board_clamp_module_set_warning_limit_param, + CMD(u8 id; u8 opt_type; s32 pad;), // + ACK(u8 id; u8 opt_type; s32 pad;)); +ZPACKET_CMD_ACK(kcmd_board_clamp_module_set_run_to_zero_param, + CMD(u8 id; u8 opt_type; s32 move_to_zero_max_d[2]; s32 leave_from_zero_max_d[2]; s32 speed[2]; s32 dec[2];), // + ACK(u8 id; u8 opt_type; s32 move_to_zero_max_d[2]; s32 leave_from_zero_max_d[2]; s32 speed[2]; s32 dec[2];)); + +/******************************************************************************* + * |Module_1014:风扇 * + *******************************************************************************/ +ZPACKET_CMD_ACK(kcmd_fan_module_fan_ctrl, + CMD(u8 id; u8 level;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_fan_module_fan_read_status, + CMD(u8 id;), // + ACK(u8 id; u8 status; u8 level;)); +ZPACKET_CMD_ACK(kcmd_fan_module_fan_read_debug_info, + CMD(u8 id;), // + ACK(u8 id; u8 status; u8 level; int16_t fbcount;)); + +/******************************************************************************* + * |Module_1016:移液枪控制 * + *******************************************************************************/ + + +ZPACKET_CMD_ACK(kcmd_pipette_module_motor_enable, + CMD(u8 id; u8 enable;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_motor_move_to, + CMD(u8 id; u8 motor_id; s32 pos; s32 speed;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 pos;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_motor_move_to_zero, + CMD(u8 id; u8 motor_id;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_motor_move_to_zero_with_calibrate, + CMD(u8 id; u8 motor_id; s32 now_pos;), // + ACK(u8 id;), // + REPORT(u8 id; u8 status; s32 zero_shift;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_motor_stop, + CMD(u8 id; u8 motor_id;), // + ACK(u8 id;)); + +ZPACKET_CMD_ACK(kcmd_pipette_module_take_liquid, + CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_split_liquid, + CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_take_tip, + CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_remove_tip, + CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // + ACK(u8 id;)); + +#if 0 + kcmd_pipette_module_read_status = CMDID(1016, 51), // 读取模块精简状态信息 + kcmd_pipette_module_read_debug_info = CMDID(1016, 52), // 读取模块详细状态信息 + + kcmd_pipette_module_set_run_param = CMDID(1016, 100), // 设置运行参数 + kcmd_pipette_module_set_warning_limit_param = CMDID(1016, 101), // 设置限制参数 + kcmd_pipette_module_set_run_to_zero_param = CMDID(1016, 102), // 设置归零参数 +#endif + +ZPACKET_CMD_ACK(kcmd_pipette_module_read_version, + CMD(u8 id;), // + ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_read_status, + CMD(u8 id;), // + ACK(u8 id; u8 status; s32 pos[2];)); +ZPACKET_CMD_ACK(kcmd_pipette_module_read_debug_info, + CMD(u8 id;), // + ACK(u8 id; u8 status; s32 pos[2]; s32 acc[2]; s32 speed[2];)); +ZPACKET_CMD_ACK(kcmd_pipette_module_set_run_param, + CMD(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];), // + ACK(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];)); +ZPACKET_CMD_ACK(kcmd_pipette_module_set_warning_limit_param, + CMD(u8 id; u8 opt_type; s32 pad;), // + ACK(u8 id; u8 opt_type; s32 pad;)); + +#pragma pack(pop) + +} // namespace zcr +} // namespace iflytop diff --git a/components/zcancmder_module/zcan_basic_order_module.cpp b/components/zcancmder_module/zcan_basic_order_module.cpp index 573d72a..a5416ad 100644 --- a/components/zcancmder_module/zcan_basic_order_module.cpp +++ b/components/zcancmder_module/zcan_basic_order_module.cpp @@ -22,7 +22,7 @@ void ZCanBasicOrderModule::reg_read_adc(uint8_t id, readadcval_t fn) { m_readAdc void ZCanBasicOrderModule::onRceivePacket(CanPacketRxBuffer* rxbuf) { if (rxbuf->iscmd(kcmd_ping)) { - kcmd_ping_t* pingcmd = rxbuf->get_data_as(); + kcmd_ping_cmd_t* pingcmd = rxbuf->get_data_as(); kcmd_ping_ack_t* ack = (kcmd_ping_ack_t*)txbuff; if (pingcmd->boardid == m_zcanReceiver->getDeviceId()) { @@ -31,7 +31,7 @@ void ZCanBasicOrderModule::onRceivePacket(CanPacketRxBuffer* rxbuf) { return; } } else if (rxbuf->iscmd(kcmd_read_io)) { - kcmd_read_io_t* cmd = rxbuf->get_data_as(); + kcmd_read_io_cmd_t* cmd = rxbuf->get_data_as(); kcmd_read_io_ack_t* ack = (kcmd_read_io_ack_t*)txbuff; bool val = false; @@ -43,9 +43,9 @@ void ZCanBasicOrderModule::onRceivePacket(CanPacketRxBuffer* rxbuf) { } } else if (rxbuf->iscmd(kcmd_set_io)) { - kcmd_set_io_t* cmd = rxbuf->get_data_as(); - kcmd_set_io_ack_t ack; - bool val = cmd->val; + kcmd_set_io_cmd_t* cmd = rxbuf->get_data_as(); + kcmd_set_io_ack_t ack; + bool val = cmd->val; if (m_outCtlMap.find(cmd->ioid) != m_outCtlMap.end()) { m_outCtlMap[cmd->ioid](val); @@ -56,9 +56,9 @@ void ZCanBasicOrderModule::onRceivePacket(CanPacketRxBuffer* rxbuf) { } } else if (rxbuf->iscmd(kcmd_readadc_raw)) { - kcmd_readadc_raw_t* cmd = rxbuf->get_data_as(); - kcmd_readadc_raw_ack_t ack; - int32_t val = 0; + kcmd_readadc_raw_cmd_t* cmd = rxbuf->get_data_as(); + kcmd_readadc_raw_ack_t ack; + int32_t val = 0; if (m_readAdcValMap.find(cmd->sensorid) != m_readAdcValMap.end()) { val = m_readAdcValMap[cmd->sensorid](); ack.sensorid = cmd->sensorid; diff --git a/components/zcancmder_module/zcan_xy_robot_module.cpp b/components/zcancmder_module/zcan_xy_robot_module.cpp index 8b6bb1f..a891d80 100644 --- a/components/zcancmder_module/zcan_xy_robot_module.cpp +++ b/components/zcancmder_module/zcan_xy_robot_module.cpp @@ -2,7 +2,7 @@ using namespace iflytop; #define TAG "ZCANXYRobotCtrlModule" - +#if 0 void ZCANXYRobotCtrlModule::initialize(ZCanCmder* cancmder, int id, XYRobotCtrlModule* xyRobotCtrlModule) { m_cancmder = cancmder; m_id = id; @@ -140,4 +140,5 @@ void ZCANXYRobotCtrlModule::onRceivePacket(CanPacketRxBuffer* rxcmd) { errorcode = m_xyRobotCtrlModule->set_runtozero_leave_away_zero_distance(cmd->distance); } END_PROCESS_PACKET(); -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/components/zcancmder_module/zcan_xy_robot_module.hpp b/components/zcancmder_module/zcan_xy_robot_module.hpp index 10d99b4..3151b65 100644 --- a/components/zcancmder_module/zcan_xy_robot_module.hpp +++ b/components/zcancmder_module/zcan_xy_robot_module.hpp @@ -1,7 +1,7 @@ #pragma once #include "sdk\components\xy_robot_ctrl_module\xy_robot_ctrl_module.hpp" #include "sdk\components\zcancmder\zcanreceiver.hpp" - +#if 0 namespace iflytop { class ZCANXYRobotCtrlModule : public ZCanCmderListener { ZCanCmder* m_cancmder = nullptr; @@ -14,4 +14,5 @@ class ZCANXYRobotCtrlModule : public ZCanCmderListener { void initialize(ZCanCmder* cancmder, int id, XYRobotCtrlModule* xyRobotCtrlModule); virtual void onRceivePacket(CanPacketRxBuffer* rxcmd); }; -} // namespace iflytop \ No newline at end of file +} // namespace iflytop +#endif \ No newline at end of file