Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip code generation for modbus ascii when ascii disabled #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion modbus/mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
/* ----------------------- Static variables ---------------------------------*/

static UCHAR ucMBAddress;
#if MB_ASCII_ENABLED > 0
static eMBMode eMBCurrentMode;
#endif

static enum
{
Expand Down Expand Up @@ -183,7 +185,9 @@ eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eM
}
else
{
#if MB_ASCII_ENABLED > 0
eMBCurrentMode = eMode;
#endif
eMBState = STATE_DISABLED;
}
}
Expand Down Expand Up @@ -214,7 +218,9 @@ eMBTCPInit( USHORT ucTCPPort )
peMBFrameSendCur = eMBTCPSend;
pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBTCPPortClose : NULL;
ucMBAddress = MB_TCP_PSEUDO_ADDRESS;
#if MB_ASCII_ENABLED > 0
eMBCurrentMode = MB_TCP;
#endif
eMBState = STATE_DISABLED;
}
return eStatus;
Expand Down Expand Up @@ -395,10 +401,12 @@ eMBPoll( void )
ucMBFrame[usLength++] = ( UCHAR )( ucFunctionCode | MB_FUNC_ERROR );
ucMBFrame[usLength++] = eException;
}
#if MB_ASCII_ENABLED > 0
if( ( eMBCurrentMode == MB_ASCII ) && MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS )
{
vMBPortTimersDelay( MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS );
}
}
#endif
eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength );
}
break;
Expand Down