mirror of
https://github.com/armink/FreeModbus_Slave-Master-RTT-STM32.git
synced 2025-01-22 21:47:11 +08:00
1、【修改】FreeModbus主机和从机中的线圈及离散输入回调方法,解决起始地址偏移的问题
Signed-off-by: armink <armink.ztl@gmail.com>
This commit is contained in:
parent
460be47a96
commit
b9c50c0113
@ -178,6 +178,7 @@ eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, eMBRegis
|
||||
if( ( usAddress >= COIL_START ) &&
|
||||
( usAddress + usNCoils <= COIL_START + COIL_NCOILS ) )
|
||||
{
|
||||
usAddress-=usCoilStart; //计算绝对地址
|
||||
iRegIndex = ( int )( usAddress - usCoilStart ) / 8 ; //每个寄存器存8个
|
||||
iRegBitIndex = ( int )( usAddress - usCoilStart ) % 8 ; //相对于寄存器内部的位地址
|
||||
switch ( eMode )
|
||||
@ -247,6 +248,7 @@ eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )
|
||||
if( ( usAddress >= DISCRETE_INPUT_START )
|
||||
&& ( usAddress + usNDiscrete <= DISCRETE_INPUT_START + DISCRETE_INPUT_NDISCRETES ) )
|
||||
{
|
||||
usAddress-=usDiscreteInputStart; //计算绝对地址
|
||||
iRegIndex = ( int )( usAddress - usDiscreteInputStart ) / 8 ; //每个寄存器存8个
|
||||
iRegBitIndex = ( int )( usAddress - usDiscreteInputStart ) % 8 ; //相对于寄存器内部的位地址
|
||||
|
||||
|
@ -184,6 +184,7 @@ eMBMasterRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, eM
|
||||
if( ( usAddress >= COIL_START ) &&
|
||||
( usAddress + usNCoils <= COIL_START + COIL_NCOILS ) )
|
||||
{
|
||||
usAddress-=usCoilStart; //计算绝对地址
|
||||
iRegIndex = ( int )( usAddress - usCoilStart ) / 8 ; //每个寄存器存8个
|
||||
iRegBitIndex = ( int )( usAddress - usCoilStart ) % 8 ; //相对于寄存器内部的位地址
|
||||
switch ( eMode )
|
||||
@ -253,6 +254,7 @@ eMBMasterRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscre
|
||||
if( ( usAddress >= DISCRETE_INPUT_START )
|
||||
&& ( usAddress + usNDiscrete <= DISCRETE_INPUT_START + DISCRETE_INPUT_NDISCRETES ) )
|
||||
{
|
||||
usAddress-=usDiscreteInputStart; //计算绝对地址
|
||||
iRegIndex = ( int )( usAddress - usDiscreteInputStart ) / 8 ; //每个寄存器存8个
|
||||
iRegBitIndex = ( int )( usAddress - usDiscreteInputStart ) % 8 ; //相对于寄存器内部的位地址
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user