You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

411 lines
17 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #include <stdint.h>
  3. #define PROTOCOL_VERSION 6
  4. #define HEART_OVERTIME (30 * 1000)
  5. #pragma pack(1)
  6. /**
  7. * @brief 12bit from,1bit emergency
  8. * H L
  9. * [1] [4bit] [8bit] [8bit] [4bit/4bit]
  10. * , from to frameNum/frameId
  11. */
  12. // 数值越大优先级越低
  13. typedef enum {
  14. kpriority_emergency_report = 7,
  15. kpriority_cmd = 8,
  16. kpriority_receipt = 9,
  17. kpriority_report = 10,
  18. } priority_t;
  19. typedef struct {
  20. uint8_t frameNumAndFrameId;
  21. uint8_t to;
  22. uint8_t from;
  23. uint8_t pad;
  24. } zcanid_t;
  25. typedef struct {
  26. uint8_t ptype;
  27. uint8_t index;
  28. uint16_t function_id;
  29. uint8_t params[];
  30. } zcanbus_packet_t;
  31. #pragma pack()
  32. typedef enum {
  33. kcmd,
  34. kreceipt,
  35. kerror_receipt,
  36. kreport,
  37. } packet_type_t;
  38. typedef enum {
  39. klarge_space_disinfection_machine = 1, // 大空间消毒机
  40. ksmall_space_disinfection_machine = 2, // 小空间消毒机
  41. kpipe_disinfection_machine = 3, // 管道式消毒机
  42. kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机
  43. kh2o2_ext_sensor = 5, // 外部H2O2传感器
  44. } ProjID_t;
  45. typedef enum {
  46. kBoardType_LiquidCtrl = 1, // 液路板
  47. kBoardType_PowerControl = 2, // 电源板
  48. kBoardType_PowerControlMiniBoard = 3, // 电源控制Mini板,用于拉杆箱箱消毒机
  49. kBoardType_ExtBallValveCtrl = 4, // 外部球阀控制板
  50. kBoardType_H2O2Sensor = 5, // H2O2传感器板
  51. } BoardType_t;
  52. typedef enum {
  53. kFixBoardId_MainBoard = 1, // 主机
  54. kFixBoardId_LiquidCtrl = 2, // 液路板
  55. kFixBoardId_PowerControl = 3, // 电源板
  56. kFixBoardId_ExtBallValveCtrl = 4, // 外部球阀控制板
  57. kFixBoardId_H2O2SensorStart = 100, // H2O2传感器板
  58. } BoardId_t;
  59. static inline const char *BoardTypeToString(uint32_t type) {
  60. switch (type) {
  61. case kBoardType_LiquidCtrl:
  62. return "LiquidCtrl";
  63. case kBoardType_PowerControl:
  64. return "PowerControl";
  65. case kBoardType_PowerControlMiniBoard:
  66. return "PowerControlMiniBoard";
  67. case kBoardType_ExtBallValveCtrl:
  68. return "ExtBallValveCtrl";
  69. case kBoardType_H2O2Sensor:
  70. return "H2O2Sensor";
  71. default:
  72. return "unkown";
  73. }
  74. }
  75. static inline const char *ProjectIDToString(uint32_t id) {
  76. switch (id) {
  77. case klarge_space_disinfection_machine:
  78. return "large_space_disinfection_machine";
  79. case ksmall_space_disinfection_machine:
  80. return "small_space_disinfection_machine";
  81. case kpipe_disinfection_machine:
  82. return "pipe_disinfection_machine";
  83. case kdraw_bar_disinfection_box:
  84. return "draw_bar_disinfection_box";
  85. case kh2o2_ext_sensor:
  86. return "h2o2_ext_sensor";
  87. default:
  88. return "unkown";
  89. }
  90. }
  91. typedef enum {
  92. kerr_noerror = 0,
  93. kerr_overtime = 1,
  94. kerr_invalid_param = 2,
  95. kerr_invalid_param_num = 3,
  96. kerr_subdevice_offline = 4,
  97. kerr_function_not_support = 5,
  98. // 驱动器错误
  99. kerr_motor_reset_error = 100,
  100. kerr_motor_subdevice_offline = 101,
  101. kerr_motor_driver_error = 102,
  102. kerr_motor_undervoltage_error = 103,
  103. kerr_motor_unkown_error = 104,
  104. kerr_AirBlowerError = 200, // 空压机异常
  105. kerr_HeaterError = 201, // 加热片异常
  106. kerr_BlowerError = 202, // 鼓风机异常
  107. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  108. } ErrorCode_t;
  109. static inline const char *ErrorCodeToString(uint32_t code) {
  110. switch (code) {
  111. case kerr_noerror:
  112. return "noerror";
  113. case kerr_overtime:
  114. return "overtime";
  115. case kerr_invalid_param:
  116. return "invalid_param";
  117. case kerr_invalid_param_num:
  118. return "invalid_param_num";
  119. case kerr_subdevice_offline:
  120. return "subdevice_offline";
  121. case kerr_function_not_support:
  122. return "function_not_support";
  123. case kerr_motor_reset_error:
  124. return "motor_reset_error";
  125. case kerr_motor_subdevice_offline:
  126. return "motor_subdevice_offline";
  127. case kerr_motor_driver_error:
  128. return "motor_driver_error";
  129. case kerr_motor_undervoltage_error:
  130. return "motor_undervoltage_error";
  131. case kerr_AirBlowerError:
  132. return "AirBlowerError";
  133. case kerr_HeaterError:
  134. return "HeaterError";
  135. case kerr_BlowerError:
  136. return "BlowerError";
  137. case kerr_ProportionalValveError:
  138. return "ProportionalValveError";
  139. default:
  140. return "unkown";
  141. }
  142. }
  143. typedef enum {
  144. /***********************************************************************************************************************
  145. * *
  146. ***********************************************************************************************************************/
  147. kfn_read_board_info = 1, // cmd:no, ack:ack_read_board_info_data_t
  148. kfn_force_report = 2, // cmd:no, ack:none //!delete
  149. kfn_read_sysinfo = 3, // cmd:no, ack:ack_sysinfo_t
  150. kfn_read_taskinfo = 4, // cmd:taskoff, ack:ask_taskinfo_t
  151. kfn_heart_ping = 5, // cmd:pingindex, ack:ask_taskinfo_t
  152. kfn_clear_reset_flag = 6, // cmd:taskoff, ack:ask_taskinfo_t
  153. kreport_heatpacket_pong = 50, // cmd:no ack:no report:heatpacket_t
  154. kreport_exception_error = 51, // report:error_code,subid
  155. /***********************************************************************************************************************
  156. * *
  157. ***********************************************************************************************************************/
  158. /**
  159. * (id,)
  160. *
  161. *
  162. * TMC参数
  163. * TMC参数
  164. * ihold,irun,idelay
  165. *
  166. */
  167. kfn_pump_rotate = 100, // cmd: index rpm ack:none
  168. kfn_pump_stop = 101, // cmd: index rpm ack:none
  169. kfn_pump_set_ihold_irun_idelay = 102, // cmd: index irun,ihold,idelay ack:none
  170. kfn_pump_set_acc = 104, // cmd: index acc ack:none
  171. kfn_pump_ping = 105, // cmd: index, ack:none
  172. kfn_pump_set_subic_reg = 110, // cmd: index,val ack:none
  173. kfn_pump_get_subic_reg = 111, // cmd: index, ack:val
  174. /***********************************************************************************************************************
  175. * MINI真空泵 *
  176. ***********************************************************************************************************************/
  177. /**
  178. * @brief Spray liquid mini air compressor
  179. * /
  180. */
  181. kfn_sl_mini_ac_ctrl = 200, // cmd: power(0-100)
  182. /***********************************************************************************************************************
  183. * MINI真空泵 *
  184. ***********************************************************************************************************************/
  185. /**
  186. * @brief air Tightness Test AirCompressor
  187. * /
  188. *
  189. */
  190. kfn_atta_mini_air_compressor_ctrl = 300, // cmd: power(0-100)
  191. /***********************************************************************************************************************
  192. * *
  193. ***********************************************************************************************************************/
  194. kfn_pressure_sensor_bus_read_data = 400, // cmd:subid ack:pressure(0.1pa)
  195. kfn_pressure_sensor_bus_set_report_period_ms = 401, // cmd:period
  196. kreport_pressure_data = 450, // report:subid pressure(0.1pa)
  197. /***********************************************************************************************************************
  198. * MINI_PWM风机控制 *
  199. ***********************************************************************************************************************/
  200. /**
  201. * @brief
  202. * /
  203. *
  204. *
  205. */
  206. kfn_mini_pwm_blower_ctrl = 500, // cmd: speed(0-100)
  207. kfn_mini_pwm_blower_read_fbcount = 501, // cmd: valve_state
  208. /***********************************************************************************************************************
  209. * *
  210. ***********************************************************************************************************************/
  211. /**
  212. * @brief
  213. * /
  214. *
  215. *
  216. *
  217. *
  218. *
  219. */
  220. kfn_heater_ctrl = 600, // cmd: power(0-100)
  221. kfn_heater_ctrl_safe_valve = 601, // cmd: valve_state
  222. kfn_heater_read_electric_current = 602, // report:electric_current(ma)
  223. kfn_heater_read_temperature_data = 603, // report:temperature(0.01)
  224. /***********************************************************************************************************************
  225. * H2O2传感器数值上报 *
  226. ***********************************************************************************************************************/
  227. kfn_h2o2_sensor_read_calibration_date = 700, // cmd:subid ack:year,month,day
  228. kfn_h2o2_sensor_read_sub_ic_errorcode = 701, // cmd:subid ack:errorcode
  229. kfn_h2o2_sensor_read_sub_ic_reg = 702, // cmd:subid,reg,num ack:errorcode
  230. kreport_h2o2_sensor_data = 750, // report:subid h2o2_sensor_data
  231. /***********************************************************************************************************************
  232. * *
  233. ***********************************************************************************************************************/
  234. kfn_triple_warning_light_ctl = 800, // cmd: r,g,b,warning
  235. /***********************************************************************************************************************
  236. * *
  237. ***********************************************************************************************************************/
  238. kfn_evaporation_bin_water_sensor_read_state = 900, // cmd: state
  239. kfn_device_bottom_water_sensor_read_state = 901, // cmd: state
  240. kreport_evaporation_bin_water_sensor = 950, // report:state //蒸发仓水浸 //report_evaporation_bin_water_sensor_data_t
  241. kreport_device_bottom_water_sensor = 951, // report:state //设备底部水浸 //report_device_bottom_water_sensor_data
  242. /***********************************************************************************************************************
  243. * *
  244. ***********************************************************************************************************************/
  245. kfn_blower_ctrl = 1000, // cmd: power(0-100)
  246. kfn_blower_ctrl_safe_valve = 1001, // cmd: valve_state
  247. kfn_blower_read_electric_current = 1002, // report:electric_current(ma)
  248. /***********************************************************************************************************************
  249. * *
  250. ***********************************************************************************************************************/
  251. kfn_air_compressor_ctrl = 1100, // cmd: power(0-100)
  252. kfn_air_compressor_ctrl_safe_valve = 1101, // cmd: valve_state
  253. kfn_air_compressor_read_electric_current = 1102, // report:electric_current(ma)
  254. #if 0
  255. /***********************************************************************************************************************
  256. * H2O2传感器数值上报 *
  257. ***********************************************************************************************************************/
  258. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  259. /***********************************************************************************************************************
  260. * *
  261. ***********************************************************************************************************************/
  262. /**
  263. * @brief
  264. * /
  265. */
  266. kfn_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  267. /***********************************************************************************************************************
  268. * *
  269. ***********************************************************************************************************************/
  270. /**
  271. * @brief
  272. * /
  273. */
  274. kfn_ball_valve_ctrl = 1000, // cmd: valve_state
  275. /***********************************************************************************************************************
  276. * *
  277. ***********************************************************************************************************************/
  278. /**
  279. * @brief
  280. * /
  281. *
  282. */
  283. kfn_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  284. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  285. /***********************************************************************************************************************
  286. * *
  287. ***********************************************************************************************************************/
  288. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  289. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  290. #endif
  291. } cmd_t;
  292. #pragma pack(1)
  293. /***********************************************************************************************************************
  294. * ACK *
  295. ***********************************************************************************************************************/
  296. typedef struct {
  297. uint16_t boardType;
  298. uint16_t projectId;
  299. uint16_t protcol_version;
  300. uint16_t software_version;
  301. uint16_t hardware_version;
  302. } ack_read_board_info_data_t;
  303. typedef struct {
  304. uint8_t taskName[8];
  305. uint16_t stackRemindSize;
  306. uint16_t priority;
  307. uint8_t state;
  308. } ask_taskinfo_t;
  309. typedef struct {
  310. uint32_t total_heap_size;
  311. uint32_t free_heap_size;
  312. uint16_t taskNum;
  313. uint16_t sysHasRun;
  314. } ack_sysinfo_t;
  315. /***********************************************************************************************************************
  316. * Report *
  317. ***********************************************************************************************************************/
  318. typedef struct {
  319. uint16_t heartIndex;
  320. uint8_t boardType;
  321. uint8_t flag; // 0:reset_flag
  322. } report_heatpacket_data_t;
  323. typedef struct {
  324. uint32_t ecode;
  325. uint16_t subid;
  326. } report_exeception_data_t;
  327. #if 1
  328. typedef struct {
  329. uint8_t sensorDataNum;
  330. struct {
  331. uint8_t subid;
  332. int16_t pressureVal;
  333. } data[];
  334. } report_pressure_data_t;
  335. #endif
  336. typedef struct {
  337. uint8_t sensor_error; // 传感器异常
  338. uint16_t h2o2; // ppm * 10
  339. uint16_t humid; // %RH * 10
  340. uint16_t temp; // °C * 10
  341. uint16_t saturation; // %RS * 10
  342. } report_h2o2_data_t;
  343. typedef struct {
  344. uint16_t temperature; // 0.01
  345. } report_heater_temperature_data_t;
  346. typedef struct {
  347. uint16_t subid; // 0->100
  348. uint16_t valve_state; // 0->100
  349. } report_proportional_valve_value_data_t;
  350. typedef struct {
  351. uint16_t state;
  352. } report_water_sensor_state_t;
  353. #pragma pack()