#ifndef __MODBUS_H #define __MODBUS_H /***********************************************************************************/ #include "includes.h" #define MODBUS_REG_NUM_MAX 256 //运行内存不够,不能太大 #define HOLDINGREG 0x03 #define WRITESINGLEREG 0x06 typedef struct SUT_MODBUS_REGLIST { unsigned char slave; unsigned short addr; short value; }__attribute__((packed)) SUT_MODBUS_REGLIST; typedef struct SUT_MODBUS_REGPACK { unsigned short RegNum; SUT_MODBUS_REGLIST RegList[MODBUS_REG_NUM_MAX]; }__attribute__((packed)) SUT_MODBUS_REGPACK; extern SUT_MODBUS_REGPACK sutModbusRegPack; extern unsigned char g_ucModbusRefreshEN; extern unsigned char g_ucModbusRefreshSHUTDOWN; extern unsigned short g_ucRegNumCount; extern unsigned short g_ucModbusRefreshTimeOut; unsigned char ModbusRecvProcess(unsigned char *pMsg,int len,unsigned short num); void ModbusCmdReadOneValue(SUT_MODBUS_REGLIST *pMsg,unsigned short num); void ModbusRefreshValue(void); void ModbusCmdSetValue(SUT_MODBUS_REGLIST *pMsg); #endif /***********************************************************************************/