node_message.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef __NODE_MESSAGE_H
  2. #define __NODE_MESSAGE_H
  3. #include "stm32f2xx.h"
  4. #define slave
  5. #ifdef slave
  6. // 存储在本地的枚举了协议类型
  7. #define MODBUS_WRITE 4 //本机用于区分读写
  8. #define MODBUS_READ 3
  9. #define DLT645_07 2
  10. #define DLT645_97 1
  11. typedef struct _NODE_DLT645_PARAMS
  12. {
  13. uint32_t dataType645; //645数据标识
  14. uint8_t deviceType645[6]; //645地址
  15. uint8_t datalength;
  16. uint8_t value[10];
  17. uint8_t rxLen;
  18. }NODE_DLT645_PARAMS;
  19. typedef struct _NODE_MODBUS_READ
  20. {
  21. uint8_t slaveAddress;
  22. uint8_t functionCode;
  23. uint16_t registerAddress;
  24. uint16_t registerLength;
  25. uint8_t dataType; //数据类型
  26. uint8_t precision;
  27. uint8_t bigLittleFormat;
  28. uint8_t flag; //此属性读取是否成功
  29. uint8_t callback[4]; //对应读取到的数据存储于此
  30. uint8_t rxLen;
  31. }NODE_MODBUS_READ;
  32. typedef struct _NODE_MODBUS_WRITE
  33. {
  34. uint8_t slaveAddress;
  35. uint8_t functionCode;
  36. uint8_t dataType; //数据类型
  37. uint16_t registerAddress;
  38. uint16_t registerLength;
  39. uint8_t bigLittleFormat;
  40. uint8_t flag; //写入指令操作是否成功标志
  41. }NODE_MODBUS_WRITE;
  42. typedef struct _PARAMS
  43. {
  44. uint8_t protcol; //此属性决定用那个协议属性也会包含对应的响应值,其他未涉及到的属性赋值为NULL
  45. NODE_DLT645_PARAMS *dlt645_params;
  46. NODE_MODBUS_READ *modbus_read;
  47. NODE_MODBUS_WRITE *modbus_write;
  48. }PARAMS;
  49. typedef struct _NODE_DEVICE_PARAMS
  50. {
  51. uint8_t Index; //记录总共有多少个属性
  52. PARAMS params[20];
  53. }NODE_DEVICE_PARAMS;
  54. NODE_DEVICE_PARAMS *get_node_receive_params(void);
  55. void free_all_node_params(void);
  56. extern uint8_t protocol_485;
  57. #endif
  58. #endif