1、【优化】FreeModbus主机缓冲区与从机关联的地址逻辑,站点地址为1的从机数据应该存放在数组地址为0的位置。

Signed-off-by: armink <armink.ztl@gmail.com>
This commit is contained in:
armink 2014-03-03 16:07:23 +08:00
parent 5832f7aa89
commit c7e08d179d
1 changed files with 4 additions and 4 deletions

View File

@ -62,7 +62,7 @@ eMBMasterRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs )
UCHAR REG_INPUT_NREGS;
UCHAR usRegInStart;
pusRegInputBuf = usMRegInBuf[ucMBMasterGetDestAddress()];
pusRegInputBuf = usMRegInBuf[ucMBMasterGetDestAddress() - 1];
REG_INPUT_START = M_REG_INPUT_START;
REG_INPUT_NREGS = M_REG_INPUT_NREGS;
usRegInStart = usMRegInStart;
@ -109,7 +109,7 @@ eMBMasterRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, e
UCHAR REG_HOLDING_NREGS;
UCHAR usRegHoldStart;
pusRegHoldingBuf = usMRegHoldBuf[ucMBMasterGetDestAddress()];
pusRegHoldingBuf = usMRegHoldBuf[ucMBMasterGetDestAddress() - 1];
REG_HOLDING_START = M_REG_HOLDING_START;
REG_HOLDING_NREGS = M_REG_HOLDING_NREGS;
usRegHoldStart = usMRegHoldStart;
@ -176,7 +176,7 @@ eMBMasterRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, eM
UCHAR usCoilStart;
iNReg = usNCoils / 8 + 1; //占用寄存器数量
pucCoilBuf = ucMCoilBuf[ucMBMasterGetDestAddress()];
pucCoilBuf = ucMCoilBuf[ucMBMasterGetDestAddress() - 1];
COIL_START = M_COIL_START;
COIL_NCOILS = M_COIL_NCOILS;
usCoilStart = usMCoilStart;
@ -248,7 +248,7 @@ eMBMasterRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscre
UCHAR usDiscreteInputStart;
iNReg = usNDiscrete / 8 + 1; //占用寄存器数量
pucDiscreteInputBuf = ucMDiscInBuf[ucMBMasterGetDestAddress()];
pucDiscreteInputBuf = ucMDiscInBuf[ucMBMasterGetDestAddress() - 1];
DISCRETE_INPUT_START = M_DISCRETE_INPUT_START;
DISCRETE_INPUT_NDISCRETES = M_DISCRETE_INPUT_NDISCRETES;
usDiscreteInputStart = usMDiscInStart;