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.

62 lines
2.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #pragma once
  2. #include "sdk/hal/zhal.hpp"
  3. namespace iflytop {
  4. namespace zcr {
  5. typedef struct {
  6. uint16_t packetindex;
  7. uint16_t cmdid;
  8. uint8_t subcmdid;
  9. uint8_t packetType;
  10. uint8_t data[];
  11. } Cmdheader_t;
  12. typedef enum {
  13. kpt_cmd = 0,
  14. kpt_ack = 1,
  15. kpt_error_ack = 2,
  16. kpt_status_report = 3,
  17. } PacketType_t;
  18. typedef enum {
  19. kcmd_ping = 0,
  20. kcmd_read_io = 1,
  21. kcmd_set_io = 2,
  22. kcmd_readadc_raw = 3,
  23. kcmd_m211887_operation = 1000, // 维萨拉压力传感器
  24. kcmd_read_presure_sensor = 1001,
  25. kcmd_triple_warning_light_ctl = 1002,
  26. kcmd_peristaltic_pump_ctl = 1004, // subcmd == 1
  27. kcmd_read_huacheng_pressure_sensor = 1005,
  28. kcmd_set_proportional_valve = 1006, // 设置比例阀 {4:valveId,4:valveValue}
  29. kcmd_air_compressor_ch_select = 1007, // 空压机通道选择 {4:val}
  30. kcmd_air_compressor_valve1_set = 1008, // 空压机阀门1控制 {4:val}
  31. kcmd_air_compressor_valve2_set = 1009, // 空压机阀门2控制 {4:val}
  32. kcmd_air_compressor_read_pressure = 1010, // 空压机阀读取压力 {}{4:val}
  33. kcmd_proportional_read_state = 1011,
  34. kcmd_proportional_read_water_immersion_sensor = 1012, // 读取水浸传感器状态
  35. kcmd_spray_air_compressor_power_ctrl = 1013, // 喷雾空压机控制 {4:ID}{4:val}
  36. kcmd_air_tightness_test_air_compressor_power_ctrl = 1014, // 气密性空压机控制 {4:ID}{4:val}
  37. } CmdID_t;
  38. } // namespace zcr
  39. } // namespace iflytop
  40. #define IS_CMD(cmdheader, cmd, subcmd) ((cmdheader->cmdid == cmd) && (cmdheader->subcmdid == subcmd))
  41. #define CMD_GET_PARAM(cmdheader, index) (((int32_t*)cmdheader->data)[index])
  42. #define CMD_PARAM(index) (((int32_t*)cmdheader->data)[index])
  43. #define PROCESS_CMD(cmd, _subcmdid, id) \
  44. if ((cmdheader->cmdid == (uint16_t)cmd) && (cmdheader->subcmdid == _subcmdid) && cmdheader->data[0] == id) { \
  45. matching = true; \
  46. } \
  47. if ((cmdheader->cmdid == (uint16_t)cmd) && (cmdheader->subcmdid == _subcmdid) && cmdheader->data[0] == id)
  48. /**
  49. * @brief
  50. */