modbus_master.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __MODBUS_MASTER_H__
  2. #define __MODBUS_MASTER_H__
  3. #include "modbus_common.h"
  4. //默认周期命令池大小为20
  5. //可以在编译器predefine里面重定义大小
  6. #ifndef MODBUS_MASTER_PERIOD_POOL_SIZE
  7. #define MODBUS_MASTER_PERIOD_POOL_SIZE 20
  8. #endif
  9. //默认周期命令池大小为20
  10. //可以在编译器predefine里面重定义大小
  11. #ifndef MODBUS_MASTER_ONCE_POOL_SIZE
  12. #define MODBUS_MASTER_ONCE_POOL_SIZE 10
  13. #endif
  14. void modbus_master_init(void);
  15. int modbus_master_run(modbus_master_t * master, unsigned char * request,unsigned char * respone, int length);
  16. modbus_master_period_cmd_t * modbus_master_add_period_cmd(
  17. modbus_master_t * master,
  18. unsigned char id,
  19. unsigned char cmd,
  20. unsigned short address,
  21. unsigned short number,
  22. unsigned char * value,
  23. int respone_timeout,
  24. void (*on_respone)(modbus_master_cmd_t * , unsigned char * ,int),
  25. int period
  26. );
  27. modbus_master_once_cmd_t * modbus_master_add_once_cmd(
  28. modbus_master_t * master,
  29. unsigned char id,
  30. unsigned char cmd,
  31. unsigned short address,
  32. unsigned short number,
  33. unsigned char * value,
  34. int respone_timeout,
  35. void (*on_respone)(modbus_master_cmd_t * , unsigned char * ,int)
  36. );
  37. #endif