Modbus.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef __MODBUS_H
  2. #define __MODBUS_H
  3. /***********************************************************************************/
  4. #include "includes.h"
  5. #define MODBUS_REG_NUM_MAX 256 //运行内存不够,不能太大
  6. #define HOLDINGREG 0x03
  7. #define WRITESINGLEREG 0x06
  8. typedef struct SUT_MODBUS_REGLIST
  9. {
  10. unsigned char slave;
  11. unsigned short addr;
  12. short value;
  13. }__attribute__((packed)) SUT_MODBUS_REGLIST;
  14. typedef struct SUT_MODBUS_REGPACK
  15. {
  16. unsigned short RegNum;
  17. SUT_MODBUS_REGLIST RegList[MODBUS_REG_NUM_MAX];
  18. }__attribute__((packed)) SUT_MODBUS_REGPACK;
  19. extern SUT_MODBUS_REGPACK sutModbusRegPack;
  20. extern unsigned char g_ucModbusRefreshEN;
  21. extern unsigned char g_ucModbusRefreshSHUTDOWN;
  22. extern unsigned short g_ucRegNumCount;
  23. extern unsigned short g_ucModbusRefreshTimeOut;
  24. unsigned char ModbusRecvProcess(unsigned char *pMsg,int len,unsigned short num);
  25. void ModbusCmdReadOneValue(SUT_MODBUS_REGLIST *pMsg,unsigned short num);
  26. void ModbusRefreshValue(void);
  27. void ModbusCmdSetValue(SUT_MODBUS_REGLIST *pMsg);
  28. #endif
  29. /***********************************************************************************/