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.

322 lines
12 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. #pragma once
  2. #include <stdint.h>
  3. #define PROTOCOL_VERSION 1
  4. #define HEART_PACKET_PERIOD_MS (5 * 1000)
  5. extern "C" {
  6. #pragma pack(1)
  7. /**
  8. * @brief 12bit from,1bit emergency
  9. * H L
  10. * [1] [4bit] [8bit] [8bit] [4bit/4bit]
  11. * , from to frameNum/frameId
  12. */
  13. typedef struct {
  14. uint8_t frameNumAndFrameId;
  15. uint8_t to;
  16. uint8_t from;
  17. uint8_t pad;
  18. } zcanid_t;
  19. typedef struct {
  20. uint8_t ptype;
  21. uint8_t index;
  22. uint16_t function_id;
  23. uint8_t params[];
  24. } zcanbus_packet_t;
  25. #pragma pack()
  26. typedef enum {
  27. kcmd,
  28. kreceipt,
  29. kerror_receipt,
  30. kreport,
  31. } packet_type_t;
  32. typedef enum {
  33. kMainBoard = 0, // 主机
  34. kBoardType_LiquidCtrl = 1, // 液路板
  35. kBoardType_PowerControl = 2, // 电源板
  36. kBoardType_PowerControlMiniBoard = 3, // 电源控制Mini板,用于拉杆箱箱消毒机
  37. kBoardType_ExtBallValveCtrl = 4, // 外部球阀控制板
  38. kBoardType_H2O2Sensor = 5, // H2O2传感器板
  39. } BoardType_t;
  40. typedef enum {
  41. klarge_space_disinfection_machine = 1, // 大空间消毒机
  42. ksmall_space_disinfection_machine = 2, // 小空间消毒机
  43. kpipe_disinfection_machine = 3, // 管道式消毒机
  44. kdraw_bar_disinfection_box = 4, // 手持拉杆箱消毒机
  45. } ProjectID_t;
  46. typedef enum {
  47. kerr_noerror = 0,
  48. kerr_overtime = 1,
  49. // 驱动器错误
  50. kerr_motorReset = 100,
  51. kerr_motorUnkownError = 101,
  52. kerr_AirBlowerError = 200, // 空压机异常
  53. kerr_HeaterError = 201, // 加热片异常
  54. kerr_BlowerError = 202, // 鼓风机异常
  55. kerr_ProportionalValveError = 203, // 气密性测试专用空压机异常
  56. } ErrorCode_t;
  57. static inline const char *ErrorCodeToString(uint32_t code) {
  58. switch (code) {
  59. case kerr_noerror:
  60. return "no error";
  61. case kerr_motorReset:
  62. return "motor reset";
  63. case kerr_motorUnkownError:
  64. return "motor unkown error";
  65. case kerr_AirBlowerError:
  66. return "air blower error";
  67. case kerr_HeaterError:
  68. return "heater error";
  69. case kerr_BlowerError:
  70. return "blower error";
  71. case kerr_ProportionalValveError:
  72. return "proportional valve error";
  73. default:
  74. return "unkown error";
  75. }
  76. }
  77. typedef enum {
  78. /***********************************************************************************************************************
  79. * *
  80. ***********************************************************************************************************************/
  81. kcmd_read_board_info = 1, // cmd:no, ack:read_board_info_ack_t
  82. kcmd_force_report = 2, // cmd:no, ack:read_board_info_ack_t
  83. kcmd_read_sysinfo = 3, // cmd:no, ack:read_board_info_ack_t
  84. kcmd_read_taskinfo = 4, // cmd:taskoff, ack:read_board_info_ack_t
  85. kreport_heatpacket = 50, // cmd:no ack:no report:heatpacket_t
  86. kreport_exception_error = 51, // report:error_code,subid
  87. /***********************************************************************************************************************
  88. * *
  89. ***********************************************************************************************************************/
  90. /**
  91. * (id,)
  92. *
  93. *
  94. * TMC参数
  95. * TMC参数
  96. * ihold,irun,idelay
  97. *
  98. */
  99. kcmd_pump_rotate = 100, // cmd: rpm
  100. kcmd_pump_stop = 101, // cmd: rpm
  101. kcmd_pump_set_subic_reg = 102, // cmd: add,val
  102. kcmd_pump_get_subic_reg = 103, // cmd: add,ack:val
  103. kcmd_pump_set_irun_ihold = 104, // cmd: irun,ihold,idelay
  104. /***********************************************************************************************************************
  105. * *
  106. ***********************************************************************************************************************/
  107. kcmd_triple_warning_light_ctl = 200, // cmd: r,g,b,warning
  108. /***********************************************************************************************************************
  109. * *
  110. ***********************************************************************************************************************/
  111. kreport_pressure_data = 300, // report:subid pressure(0.1pa)
  112. /***********************************************************************************************************************
  113. * H2O2传感器数值上报 *
  114. ***********************************************************************************************************************/
  115. kreport_h2o2_data = 400, // report:subid h2o2_sensor_data
  116. /***********************************************************************************************************************
  117. * *
  118. ***********************************************************************************************************************/
  119. /**
  120. * @brief
  121. * /
  122. *
  123. *
  124. *
  125. *
  126. *
  127. */
  128. kcmd_heater_ctrl = 500, // cmd: power(0-100)
  129. kcmd_heater_ctrl_safe_valve = 501, // cmd: valve_state
  130. kreport_heater_temperature_data = 550, // report:temperature(0.01)
  131. kreport_heater_electric_current = 551, // report:electric_current(ma)
  132. /***********************************************************************************************************************
  133. * *
  134. ***********************************************************************************************************************/
  135. /**
  136. * @brief
  137. * /
  138. *
  139. *
  140. */
  141. kcmd_blower_ctrl = 600, // cmd: power(0-100)
  142. kcmd_blower_ctrl_safe_valve = 601, // cmd: valve_state
  143. kreport_blower_electric_current = 651, // report:electric_current(ma)
  144. /***********************************************************************************************************************
  145. * *
  146. ***********************************************************************************************************************/
  147. /**
  148. * @brief airCompressor
  149. * /
  150. *
  151. *
  152. *
  153. */
  154. kcmd_airCompressor_ctrl = 700, // cmd: power(0-100)
  155. kcmd_airCompressor_ctrl_safe_valve = 701, // cmd: valve_state
  156. kreport_airCompressor_electric_current = 751, // report:electric_current(ma)
  157. /***********************************************************************************************************************
  158. * *
  159. ***********************************************************************************************************************/
  160. /**
  161. * @brief air Tightness Test AirCompressor
  162. * /
  163. *
  164. *
  165. *
  166. */
  167. kcmd_ATTAirCompressor_ctrl = 800, // cmd: power(0-100)
  168. kcmd_ATTAirCompressor_ctrl_safe_valve = 801, // cmd: valve_state
  169. /***********************************************************************************************************************
  170. * *
  171. ***********************************************************************************************************************/
  172. /**
  173. * @brief
  174. * /
  175. */
  176. kcmd_electromagnetic_valve_ctrl = 900, // cmd: valve_state
  177. /***********************************************************************************************************************
  178. * *
  179. ***********************************************************************************************************************/
  180. /**
  181. * @brief
  182. * /
  183. */
  184. kcmd_ball_valve_ctrl = 1000, // cmd: valve_state
  185. /***********************************************************************************************************************
  186. * *
  187. ***********************************************************************************************************************/
  188. /**
  189. * @brief
  190. * /
  191. *
  192. */
  193. kcmd_proportional_valve_ctrl = 1100, // cmd: subid valve_state(0->100)
  194. kreport_proportional_valve_value = 1150, // cmd: subid valve_state(0->100)
  195. /***********************************************************************************************************************
  196. * *
  197. ***********************************************************************************************************************/
  198. kreport_evaporation_bin_water_sensor = 1200, // report:state //蒸发仓水浸
  199. kreport_device_bottom_water_sensor = 1201, // report:state //设备底部水浸
  200. } cmd_t;
  201. #pragma pack(1)
  202. /***********************************************************************************************************************
  203. * ACK *
  204. ***********************************************************************************************************************/
  205. typedef struct {
  206. uint16_t boardType;
  207. uint16_t projectId;
  208. uint16_t protcol_version;
  209. uint16_t software_version;
  210. uint16_t hardware_version;
  211. } ack_read_board_info_data_t;
  212. typedef struct {
  213. uint8_t taskName[8];
  214. uint16_t stackRemindSize;
  215. uint16_t priority;
  216. uint8_t state;
  217. } ask_task_info;
  218. typedef struct {
  219. uint16_t total_heap_size;
  220. uint16_t free_heap_size;
  221. uint16_t taskNum;
  222. uint16_t sysHasRun;
  223. } ack_sysinfo_t;
  224. /***********************************************************************************************************************
  225. * Report *
  226. ***********************************************************************************************************************/
  227. typedef struct {
  228. uint16_t boardType;
  229. } report_heatpacket_data_t;
  230. typedef struct {
  231. uint16_t subid;
  232. uint32_t ecode;
  233. } report_exeception_data_t;
  234. typedef struct {
  235. uint16_t subid;
  236. uint32_t pressure;
  237. } report_pressure_data_t;
  238. typedef struct {
  239. uint16_t subid;
  240. uint16_t h2o2; // ppm
  241. uint16_t humid; // %RH * 100
  242. uint16_t temp; // °C * 100
  243. uint16_t saturation; // %RS * 100
  244. } report_h2o2_data_t;
  245. typedef struct {
  246. uint16_t temperature; // 0.01
  247. } report_heater_temperature_data_t;
  248. typedef struct {
  249. uint16_t electric_current; // ma
  250. } report_heater_electric_current_data_t;
  251. typedef struct {
  252. uint16_t electric_current; // ma
  253. } report_blower_electric_current_data_t;
  254. typedef struct {
  255. uint16_t electric_current; // ma
  256. } report_airCompressor_electric_current_data_t;
  257. typedef struct {
  258. uint16_t subid; // 0->100
  259. uint16_t valve_state; // 0->100
  260. } report_proportional_valve_value_data_t;
  261. typedef struct {
  262. uint16_t state;
  263. } report_evaporation_bin_water_sensor_data_t;
  264. typedef struct {
  265. uint16_t state;
  266. } report_device_bottom_water_sensor_data_t;
  267. #pragma pack()
  268. }