From b0a5cf97b53f265eaaf0e3cf1e0aaa2364d2b358 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Fri, 26 Apr 2024 10:47:35 +0800 Subject: [PATCH] update --- iflytop_canbus_protocol.hpp | 204 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 166 insertions(+), 38 deletions(-) diff --git a/iflytop_canbus_protocol.hpp b/iflytop_canbus_protocol.hpp index 906e4ff..d72a4c9 100644 --- a/iflytop_canbus_protocol.hpp +++ b/iflytop_canbus_protocol.hpp @@ -6,22 +6,13 @@ extern "C" { #pragma pack(1) -#define PACKET_HEADER \ - uint8_t ptype; \ - uint16_t index; \ - uint16_t board_id; \ - uint16_t function_id; - typedef struct { - PACKET_HEADER - uint8_t params[]; + uint8_t ptype; + uint8_t index; + uint16_t function_id; + uint8_t params[]; } zcanbus_packet_t; -typedef struct { - PACKET_HEADER - uint8_t boardType; -} heatpacket_t; - #pragma pack() typedef enum { @@ -33,11 +24,12 @@ typedef enum { } packet_type_t; typedef enum { - kMainBoard = 0, // 主机 - kBoardType_LiquidCtrl = 1, // 液路板 - kBoardType_PowerControl = 2, // 电源板 - kBoardType_ExtBallValveCtrl = 3, // 外部球阀控制板 - kBoardType_H2O2Sensor = 4, // H2O2传感器板 + kMainBoard = 0, // 主机 + kBoardType_LiquidCtrl = 1, // 液路板 + kBoardType_PowerControl = 2, // 电源板 + kBoardType_PowerControlMiniBoard = 3, // 电源控制Mini板,用于拉杆箱箱消毒机 + kBoardType_ExtBallValveCtrl = 4, // 外部球阀控制板 + kBoardType_H2O2Sensor = 5, // H2O2传感器板 } BoardType_t; typedef enum { @@ -51,8 +43,13 @@ typedef enum { kerr_noerror = 0, // 驱动器错误 - kmotor_reset = 100, - kmotor_unkownError = 100, + kerr_motorReset = 100, + kerr_motorUnkownError = 101, + + kerr_AirBlowerError = 200, // 空压机异常 + kerr_HeaterError = 201, // 加热片异常 + kerr_BlowerError = 202, // 鼓风机异常 + kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常 } ErrorCode_t; @@ -61,9 +58,9 @@ 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 + kcmd_read_board_info = 1, // cmd:no, ack:read_board_info_ack_t + kreport_heatpacket = 50, // cmd:no ack:no report:heatpacket_t + kreport_exception_error = 51, // report:error_code,subid /*********************************************************************************************************************** * 蠕动泵控制 * @@ -84,60 +81,191 @@ typedef enum { kcmd_pump_set_irun_ihold = 104, // cmd: irun,ihold,idelay /*********************************************************************************************************************** + * 报警指示灯控制 * + ***********************************************************************************************************************/ + kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning + + /*********************************************************************************************************************** + * 压力传感器读取 * + ***********************************************************************************************************************/ + kreport_pressure_data = 300, // report:subid pressure(0.1pa) + + /*********************************************************************************************************************** + * H2O2传感器数值上报 * + ***********************************************************************************************************************/ + kreport_h2o2_data = 400, // report:subid h2o2_sensor_data + + /*********************************************************************************************************************** * 加热片控制 * ***********************************************************************************************************************/ /** * @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) + kcmd_heater_ctrl = 500, // cmd: power(0-100) + kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state + kreport_heater_temperature_data = 550, // report:temperature(0.01) + kreport_heater_electric_current = 551, // report:electric_current(ma) /*********************************************************************************************************************** * 风机控制 * ***********************************************************************************************************************/ - /** * @brief 风机控制 * 打开/关闭 + * 安全继电器控制 + * 电流上报 + */ + + kcmd_blower_ctrl = 600, // cmd: power(0-100) + kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state + kreport_blower_electric_current = 651, // report:electric_current(ma) + + /*********************************************************************************************************************** + * 空压机控制 * + ***********************************************************************************************************************/ + /** + * @brief 空压机 airCompressor + * 打开/关闭 + * 安全继电器控制 + * 电流上报 + * 调整风速 + */ + + kcmd_airCompressor_ctrl = 700, // cmd: power(0-100) + kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state + kreport_airCompressor_electric_current = 751, // report:electric_current(ma) + + /*********************************************************************************************************************** + * 气密性测试专用空压机 * + ***********************************************************************************************************************/ + /** + * @brief air Tightness Test AirCompressor + * 打开/关闭 * 电流上报 * + * */ + kcmd_ATTAirCompressor_ctrl = 800, // cmd: power(0-100) + kcmd_ATTAirCompressor_ctrl_safe_valve = 801, // cmd: valve_state + /*********************************************************************************************************************** - * 报警指示灯控制 * + * 电磁阀控制 * + ***********************************************************************************************************************/ + + /** + * @brief 电磁阀控制 + * 打开/关闭 + */ + kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state + + /*********************************************************************************************************************** + * 球阀控制 * ***********************************************************************************************************************/ - kcmd_triple_warning_light_ctl = 300, // cmd: r,g,b,warning + + /** + * @brief 电磁阀控制 + * 打开/关闭 + */ + kcmd_ball_valve_ctrl = 1000, // cmd: valve_state /*********************************************************************************************************************** - * 压力传感器读取 * + * 比例阀控制 * ***********************************************************************************************************************/ - kreport_pressure_data = 400, // report:subid pressure(0.1pa) + + /** + * @brief 比例阀控制 + * 打开/关闭 + * 比例阀当前比例上报 + */ + + kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100) + kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100) + + /*********************************************************************************************************************** + * 水浸传感器状态上报 * + ***********************************************************************************************************************/ + + kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸 + kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸 } cmd_t; #define HEART_OVERTIME_MS (10 * 1000) #pragma pack(1) -typedef struct { - PACKET_HEADER - uint8_t boardType; -} heatpacket_report_t; +/*********************************************************************************************************************** + * ACK * + ***********************************************************************************************************************/ typedef struct { - PACKET_HEADER uint8_t boardType; uint8_t projectId; uint16_t protcol_version; uint16_t software_version; uint16_t hardware_version; -} read_board_info_ack_t; +} ack_read_board_info_data_t; + +/*********************************************************************************************************************** + * Report * + ***********************************************************************************************************************/ + +typedef struct { + uint16_t boardType; +} report_heatpacket_data_t; + +typedef struct { + uint16_t subid; + uint32_t ecode; +} report_exeception_data_t; + +typedef struct { + uint16_t subid; + uint32_t pressure; +} report_pressure_data_t; + +typedef struct { + uint16_t subid; + uint16_t h2o2; // ppm + uint16_t humid; // %RH * 100 + uint16_t temp; // °C * 100 + uint16_t saturation; // %RS * 100 +} report_h2o2_data_t; + +typedef struct { + uint16_t temperature; // 0.01 +} report_heater_temperature_data_t; + +typedef struct { + uint16_t electric_current; // ma +} report_heater_electric_current_data_t; + +typedef struct { + uint16_t electric_current; // ma +} report_blower_electric_current_data_t; + +typedef struct { + uint16_t electric_current; // ma +} report_airCompressor_electric_current_data_t; + +typedef struct { + uint16_t subid; // 0->100 + uint16_t valve_state; // 0->100 +} report_proportional_valve_value_data_t; + +typedef struct { + uint16_t state; +} report_evaporation_bin_water_sensor_data_t; + +typedef struct { + uint16_t state; +} report_device_bottom_water_sensor_data_t; #pragma pack() }