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.

75 lines
2.2 KiB

  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #define adwin_config_protocol_size sizeof(adwin_config_protocol_t)
  7. #define active_report_data_size sizeof(active_report_data_t)
  8. #define basic_report_data_size sizeof(basic_report_data_t)
  9. typedef enum
  10. {
  11. CMD_SET_AUTOMATIC_REPORTING_FREQUENCY = 0X01,
  12. CMD_GET_ENCODER_DATA = 0X02,
  13. CMD_SET_ACTIVE = 0X03,
  14. CMD_CLEAR_ENCODER = 0X04,
  15. } cmd_id_type;
  16. #pragma pack(push, 1)
  17. typedef struct
  18. {
  19. uint32_t fixed_bit_1; /* 固定位1:F0 00 20 00 */
  20. uint32_t time_stamp_s; /* 相对时间戳,上位机通知Xsync开始工作时,从0开始,每秒+1 */
  21. uint32_t fixed_bit_2; /* 固定位2:00 00 B0 42 */
  22. uint32_t server_version; /* server版本号 */
  23. uint32_t xilinx_version; /* Xilinx Version,看需求中固定为:41 61 F7 FF */
  24. uint8_t mac_address[6]; /* MAC地址 */
  25. uint16_t fixed_bit_3; /* 固定位3:00 00 */
  26. uint16_t fixed_bit_4; /* 固定位4:00 00 */
  27. uint8_t dhcp_enable; /* DHCP enable :0-False 1- TRUE */
  28. uint8_t netmask_count; /* netmask COUNT */
  29. uint32_t gateway_ip; /* 网关 */
  30. uint64_t fixed_bit_5; /* 固定位5:00 00 00 00 00 00 00 00 */
  31. uint64_t fixed_bit_6; /* 固定位6:00 00 00 00 00 00 00 00 */
  32. } adwin_config_protocol_t;
  33. typedef struct
  34. {
  35. uint16_t index; /* */
  36. uint16_t cmd_id; /* 指令id */
  37. uint32_t time_stamp_s; /* 时间戳 */
  38. uint32_t encoder_1_count; /* 编码器1计数 */
  39. uint32_t encoder_2_count; /* 编码器2计数 */
  40. uint8_t device_id; /* 设备ID号 */
  41. uint8_t checksum; /* 校验和 */
  42. } active_report_data_t;
  43. typedef struct
  44. {
  45. uint16_t index; /* */
  46. uint16_t cmd_id; /* 指令id */
  47. uint16_t data; /* 数据 */
  48. uint8_t checksum; /* 校验和 */
  49. } basic_report_data_t;
  50. typedef struct
  51. {
  52. uint16_t index; /* */
  53. uint16_t cmd_id; /* 指令id */
  54. uint8_t checksum; /* 校验和 */
  55. } get_encoder_report_t;
  56. typedef struct
  57. {
  58. uint16_t index; /* */
  59. uint16_t cmd_id; /* 指令id */
  60. uint32_t encoder1; /* 编码器1的数据 */
  61. uint32_t encoder2; /* 编码器2的数据 */
  62. uint8_t checksum; /* 校验和 */
  63. } get_encoder_respont_t;
  64. #pragma pack(pop)
  65. uint8_t computesum8(char *data, size_t size);