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.

444 lines
18 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. kMainBoard = 0, // 主机
  40. kBoardType_LiquidCtrl = 2, // 液路板
  41. kBoardType_PowerControl = 3, // 电源板
  42. kBoardType_PowerControlMiniBoard = 4, // 电源控制Mini板,用于拉杆箱箱消毒机
  43. kBoardType_ExtBallValveCtrl = 5, // 外部球阀控制板
  44. kBoardType_H2O2Sensor = 6, // H2O2传感器板
  45. } BoardType_t;
  46. typedef enum {
  47. kFixBoardId_MainBoard = 1, // 主机
  48. kFixBoardId_LiquidCtrl = 2, // 液路板
  49. kFixBoardId_PowerControl = 3, // 电源板
  50. kFixBoardId_PowerControlMiniBoard = 4, // 电源控制Mini板,用于拉杆箱箱消毒机
  51. kFixBoardId_ExtBallValveCtrl = 5, // 外部球阀控制板
  52. kFixBoardId_H2O2SensorStart = 100, // H2O2传感器板
  53. } FixBoardId_t;
  54. static inline const char *BoardTypeToString(uint32_t type) {
  55. switch (type) {
  56. case kMainBoard:
  57. return "MainBoard";
  58. case kBoardType_LiquidCtrl:
  59. return "LiquidCtrl";
  60. case kBoardType_PowerControl:
  61. return "PowerControl";
  62. case kBoardType_PowerControlMiniBoard:
  63. return "PowerControlMiniBoard";
  64. case kBoardType_ExtBallValveCtrl:
  65. return "ExtBallValveCtrl";
  66. case kBoardType_H2O2Sensor:
  67. return "H2O2Sensor";
  68. default:
  69. return "unkown";
  70. }
  71. }
  72. typedef enum {
  73. klarge_space_disinfection_machine = 1, // 大空间消毒机
  74. ksmall_space_disinfection_machine = 2, // 小空间消毒机
  75. kpipe_disinfection_machine = 3, // 管道式消毒机
  76. kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机
  77. } ProjectID_t;
  78. static inline const char *ProjectIDToString(uint32_t id) {
  79. switch (id) {
  80. case klarge_space_disinfection_machine:
  81. return "large_space_disinfection_machine";
  82. case ksmall_space_disinfection_machine:
  83. return "small_space_disinfection_machine";
  84. case kpipe_disinfection_machine:
  85. return "pipe_disinfection_machine";
  86. case kdraw_bar_disinfection_box:
  87. return "draw_bar_disinfection_box";
  88. default:
  89. return "unkown";
  90. }
  91. }
  92. typedef enum {
  93. kerr_noerror = 0,
  94. kerr_overtime = 1,
  95. kerr_invalid_param = 2,
  96. kerr_invalid_param_num = 3,
  97. kerr_subdevice_offline = 4,
  98. kerr_function_not_support = 5,
  99. // 驱动器错误
  100. kerr_motor_reset_error = 100,
  101. kerr_motor_subdevice_offline = 101,
  102. kerr_motor_driver_error = 102,
  103. kerr_motor_undervoltage_error = 103,
  104. kerr_motor_unkown_error = 104,
  105. kerr_AirBlowerError = 200, // 空压机异常
  106. kerr_HeaterError = 201, // 加热片异常
  107. kerr_BlowerError = 202, // 鼓风机异常
  108. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  109. } ErrorCode_t;
  110. static inline const char *ErrorCodeToString(uint32_t code) {
  111. switch (code) {
  112. case kerr_noerror:
  113. return "noerror";
  114. case kerr_overtime:
  115. return "overtime";
  116. case kerr_invalid_param:
  117. return "invalid_param";
  118. case kerr_invalid_param_num:
  119. return "invalid_param_num";
  120. case kerr_subdevice_offline:
  121. return "subdevice_offline";
  122. case kerr_function_not_support:
  123. return "function_not_support";
  124. case kerr_motor_reset_error:
  125. return "motor_reset_error";
  126. case kerr_motor_subdevice_offline:
  127. return "motor_subdevice_offline";
  128. case kerr_motor_driver_error:
  129. return "motor_driver_error";
  130. case kerr_motor_undervoltage_error:
  131. return "motor_undervoltage_error";
  132. case kerr_AirBlowerError:
  133. return "AirBlowerError";
  134. case kerr_HeaterError:
  135. return "HeaterError";
  136. case kerr_BlowerError:
  137. return "BlowerError";
  138. case kerr_ProportionalValveError:
  139. return "ProportionalValveError";
  140. default:
  141. return "unkown";
  142. }
  143. }
  144. typedef enum {
  145. /***********************************************************************************************************************
  146. * *
  147. ***********************************************************************************************************************/
  148. kcmd_read_board_info = 1, // cmd:no, ack:ack_read_board_info_data_t
  149. kcmd_force_report = 2, // cmd:no, ack:none //!delete
  150. kcmd_read_sysinfo = 3, // cmd:no, ack:ack_sysinfo_t
  151. kcmd_read_taskinfo = 4, // cmd:taskoff, ack:ask_taskinfo_t
  152. kcmd_heart_ping = 5, // cmd:pingindex, ack:ask_taskinfo_t
  153. kcmd_clear_reset_flag = 6, // cmd:taskoff, ack:ask_taskinfo_t
  154. kreport_heatpacket_pong = 50, // cmd:no ack:no report:heatpacket_t
  155. kreport_exception_error = 51, // report:error_code,subid
  156. /***********************************************************************************************************************
  157. * *
  158. ***********************************************************************************************************************/
  159. /**
  160. * (id,)
  161. *
  162. *
  163. * TMC参数
  164. * TMC参数
  165. * ihold,irun,idelay
  166. *
  167. */
  168. kcmd_pump_rotate = 100, // cmd: index rpm ack:none
  169. kcmd_pump_stop = 101, // cmd: index rpm ack:none
  170. kcmd_pump_set_ihold_irun_idelay = 102, // cmd: index irun,ihold,idelay ack:none
  171. kcmd_pump_set_acc = 104, // cmd: index acc ack:none
  172. kcmd_pump_ping = 105, // cmd: index, ack:none
  173. kcmd_pump_set_subic_reg = 110, // cmd: index,val ack:none
  174. kcmd_pump_get_subic_reg = 111, // cmd: index, ack:val
  175. /***********************************************************************************************************************
  176. * MINI真空泵 *
  177. ***********************************************************************************************************************/
  178. /**
  179. * @brief Spray liquid mini air compressor
  180. * /
  181. */
  182. kcmd_sl_mini_ac_ctrl = 200, // cmd: power(0-100)
  183. /***********************************************************************************************************************
  184. * MINI真空泵 *
  185. ***********************************************************************************************************************/
  186. /**
  187. * @brief air Tightness Test AirCompressor
  188. * /
  189. *
  190. */
  191. kcmd_atta_mini_air_compressor_ctrl = 300, // cmd: power(0-100)
  192. /***********************************************************************************************************************
  193. * *
  194. ***********************************************************************************************************************/
  195. kcmd_pressure_sensor_bus_read_data = 400, // cmd:subid ack:pressure(0.1pa)
  196. kcmd_pressure_sensor_bus_set_report_period_ms = 401, // cmd:period
  197. kreport_pressure_data = 450, // report:subid pressure(0.1pa)
  198. /***********************************************************************************************************************
  199. * MINI_PWM风机控制 *
  200. ***********************************************************************************************************************/
  201. /**
  202. * @brief
  203. * /
  204. *
  205. *
  206. */
  207. kcmd_mini_pwm_blower_ctrl = 500, // cmd: speed(0-100)
  208. kcmd_mini_pwm_blower_read_fbcount = 501, // cmd: valve_state
  209. /***********************************************************************************************************************
  210. * *
  211. ***********************************************************************************************************************/
  212. /**
  213. * @brief
  214. * /
  215. *
  216. *
  217. *
  218. *
  219. *
  220. */
  221. kcmd_heater_ctrl = 600, // cmd: power(0-100)
  222. kcmd_heater_ctrl_safe_valve = 601, // cmd: valve_state
  223. kcmd_heater_read_electric_current = 602, // report:electric_current(ma)
  224. kcmd_heater_read_temperature_data = 603, // report:temperature(0.01)
  225. /***********************************************************************************************************************
  226. * H2O2传感器数值上报 *
  227. ***********************************************************************************************************************/
  228. kcmd_h2o2_sensor_read_calibration_date = 700, // cmd:subid ack:year,month,day
  229. kcmd_h2o2_sensor_read_sub_ic_errorcode = 701, // cmd:subid ack:errorcode
  230. kcmd_h2o2_sensor_read_sub_ic_reg = 702, // cmd:subid,reg,num ack:errorcode
  231. kreport_h2o2_sensor_data = 750, // report:subid h2o2_sensor_data
  232. /***********************************************************************************************************************
  233. * *
  234. ***********************************************************************************************************************/
  235. kcmd_triple_warning_light_ctl = 800, // cmd: r,g,b,warning
  236. /***********************************************************************************************************************
  237. * *
  238. ***********************************************************************************************************************/
  239. kcmd_evaporation_bin_water_sensor_read_state = 900, // cmd: state
  240. kcmd_device_bottom_water_sensor_read_state = 901, // cmd: state
  241. kreport_evaporation_bin_water_sensor = 950, // report:state //蒸发仓水浸 //report_evaporation_bin_water_sensor_data_t
  242. kreport_device_bottom_water_sensor = 951, // report:state //设备底部水浸 //report_device_bottom_water_sensor_data
  243. #if 0
  244. /***********************************************************************************************************************
  245. * H2O2传感器数值上报 *
  246. ***********************************************************************************************************************/
  247. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  248. /***********************************************************************************************************************
  249. * *
  250. ***********************************************************************************************************************/
  251. /**
  252. * @brief
  253. * /
  254. *
  255. *
  256. *
  257. *
  258. *
  259. */
  260. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  261. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  262. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  263. kreport_heater_electric_current = 551, // report:electric_current(ma)
  264. /***********************************************************************************************************************
  265. * *
  266. ***********************************************************************************************************************/
  267. /**
  268. * @brief
  269. * /
  270. *
  271. *
  272. */
  273. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  274. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  275. kreport_blower_electric_current = 651, // report:electric_current(ma)
  276. /***********************************************************************************************************************
  277. * *
  278. ***********************************************************************************************************************/
  279. /**
  280. * @brief airCompressor
  281. * /
  282. *
  283. *
  284. *
  285. */
  286. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  287. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  288. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  289. /***********************************************************************************************************************
  290. * *
  291. ***********************************************************************************************************************/
  292. /**
  293. * @brief
  294. * /
  295. */
  296. kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  297. /***********************************************************************************************************************
  298. * *
  299. ***********************************************************************************************************************/
  300. /**
  301. * @brief
  302. * /
  303. */
  304. kcmd_ball_valve_ctrl = 1000, // cmd: valve_state
  305. /***********************************************************************************************************************
  306. * *
  307. ***********************************************************************************************************************/
  308. /**
  309. * @brief
  310. * /
  311. *
  312. */
  313. kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  314. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  315. /***********************************************************************************************************************
  316. * *
  317. ***********************************************************************************************************************/
  318. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  319. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  320. #endif
  321. } cmd_t;
  322. #pragma pack(1)
  323. /***********************************************************************************************************************
  324. * ACK *
  325. ***********************************************************************************************************************/
  326. typedef struct {
  327. uint16_t boardType;
  328. uint16_t projectId;
  329. uint16_t protcol_version;
  330. uint16_t software_version;
  331. uint16_t hardware_version;
  332. } ack_read_board_info_data_t;
  333. typedef struct {
  334. uint8_t taskName[8];
  335. uint16_t stackRemindSize;
  336. uint16_t priority;
  337. uint8_t state;
  338. } ask_taskinfo_t;
  339. typedef struct {
  340. uint32_t total_heap_size;
  341. uint32_t free_heap_size;
  342. uint16_t taskNum;
  343. uint16_t sysHasRun;
  344. } ack_sysinfo_t;
  345. /***********************************************************************************************************************
  346. * Report *
  347. ***********************************************************************************************************************/
  348. typedef struct {
  349. uint16_t heartIndex;
  350. uint8_t boardType;
  351. uint8_t flag; // 0:reset_flag
  352. } report_heatpacket_data_t;
  353. typedef struct {
  354. uint32_t ecode;
  355. uint16_t subid;
  356. } report_exeception_data_t;
  357. #if 1
  358. typedef struct {
  359. uint8_t sensorDataNum;
  360. struct {
  361. uint8_t subid;
  362. int16_t pressureVal;
  363. } data[];
  364. } report_pressure_data_t;
  365. #endif
  366. typedef struct {
  367. uint8_t subid; // 传感器子编号,当且仅当板子上有多个传感器时使用
  368. uint8_t sensor_error; // 传感器异常
  369. uint16_t h2o2; // ppm * 10
  370. uint16_t humid; // %RH * 10
  371. uint16_t temp; // °C * 10
  372. uint16_t saturation; // %RS * 10
  373. } report_h2o2_data_t;
  374. typedef struct {
  375. uint16_t temperature; // 0.01
  376. } report_heater_temperature_data_t;
  377. typedef struct {
  378. uint16_t subid; // 0->100
  379. uint16_t valve_state; // 0->100
  380. } report_proportional_valve_value_data_t;
  381. typedef struct {
  382. uint16_t state;
  383. } report_water_sensor_state_t;
  384. #pragma pack()