diff --git a/iflytop_canbus_protocol.hpp b/iflytop_canbus_protocol.hpp index 262f2c4..9f9a7a8 100644 --- a/iflytop_canbus_protocol.hpp +++ b/iflytop_canbus_protocol.hpp @@ -1,6 +1,8 @@ #pragma once #include +#define PROTOCOL_VERSION 1 + extern "C" { #pragma pack(1) typedef struct { @@ -35,23 +37,103 @@ typedef enum { } BoardType_t; typedef enum { + klarge_space_disinfection_machine = 1, // 大空间消毒机 + ksmall_space_disinfection_machine = 2, // 小空间消毒机 + kpipe_disinfection_machine = 3, // 管道式消毒机 + kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机 +} ProjectID_t; + +typedef enum { + kerr_noerror = 0, + + // 驱动器错误 + kmotor_reset = 100, + kmotor_unkownError = 100, + +} ErrorCode_t; + +typedef enum { + + /*********************************************************************************************************************** + * 板子基本操作 * + ***********************************************************************************************************************/ + kcmd_read_board_info = 1, // cmd:no, ack:read_board_info_ack_t + kreport_heatpacket = 50, // cmd:no ack:no report:heatpacket_t + kreport_error = 51, // report:error_code,subid + + /*********************************************************************************************************************** + * 蠕动泵控制 * + ***********************************************************************************************************************/ + /** + * 旋转(id,速度) + * 停止 + * + * 设置TMC参数 + * 读取TMC参数 + * 设置ihold,irun,idelay + * + */ + kcmd_pump_rotate = 100, // cmd: rpm + kcmd_pump_stop = 101, // cmd: rpm + kcmd_pump_set_subic_reg = 102, // cmd: add,val + kcmd_pump_get_subic_reg = 103, // cmd: add,ack:val + kcmd_pump_set_irun_ihold = 104, // cmd: irun,ihold,idelay - kcmd_heatpacket_report = 0 * 100, - kcmd_read_board_info = 0 * 100 + 1, + /*********************************************************************************************************************** + * 加热片控制 * + ***********************************************************************************************************************/ + /** + * @brief 加热片控制 + * 打开/关闭 + * 是否支持读取温度 + * + * 电流上报 + * 温度上报 + */ + kcmd_heater_ctrl = 200, // cmd: power_state + kcmd_heater_is_support_temperature_sensor = 202, // cmd:no, ack:bool + kreport_heater_temperature_data = 250, // report:temperature(0.01) + kreport_heater_electric_current = 251, // report:electric_current(ma) + + /*********************************************************************************************************************** + * 风机控制 * + ***********************************************************************************************************************/ + + /** + * @brief 风机控制 + * 打开/关闭 + * 电流上报 + * + */ + + /*********************************************************************************************************************** + * 报警指示灯控制 * + ***********************************************************************************************************************/ + kcmd_triple_warning_light_ctl = 300, // cmd: r,g,b,warning + + /*********************************************************************************************************************** + * 压力传感器读取 * + ***********************************************************************************************************************/ + kreport_pressure_data = 400, // report:subid pressure(0.1pa) } cmd_t; #define HEART_OVERTIME_MS (10 * 1000) #pragma pack(1) - -/*********************************************************************************************************************** - * 心跳包 * - ***********************************************************************************************************************/ typedef struct { zcanbus_packet_t packet; uint8_t boardType; } heatpacket_report_t; +typedef struct { + zcanbus_packet_t packet; + uint8_t boardType; + uint8_t projectId; + uint16_t protcol_version; + uint16_t software_version; + uint16_t hardware_version; +} read_board_info_ack_t; + #pragma pack() }