Merge pull request #29 from ericQiang/master
fix the mistake of calling modbus API before T35 timer complate initi…
This commit is contained in:
commit
38e8bd2453
|
@ -172,6 +172,18 @@ eMBErrorCode eMBMasterEnable( void );
|
||||||
*/
|
*/
|
||||||
eMBErrorCode eMBMasterDisable( void );
|
eMBErrorCode eMBMasterDisable( void );
|
||||||
|
|
||||||
|
/*! \ingroup modbus
|
||||||
|
* \brief Check the Modbus Master protocol stack has established or not.
|
||||||
|
*
|
||||||
|
* This function must be called and check the return value before calling
|
||||||
|
* any other functions.
|
||||||
|
*
|
||||||
|
* \return If the protocol stack has been established or not
|
||||||
|
* TRUE. the protocol stack has established
|
||||||
|
* FALSE. the protocol stack hasn't established
|
||||||
|
*/
|
||||||
|
BOOL eMBMasterIsEstablished( void );
|
||||||
|
|
||||||
/*! \ingroup modbus
|
/*! \ingroup modbus
|
||||||
* \brief The main pooling loop of the Modbus Master protocol stack.
|
* \brief The main pooling loop of the Modbus Master protocol stack.
|
||||||
*
|
*
|
||||||
|
|
|
@ -71,7 +71,8 @@ static enum
|
||||||
{
|
{
|
||||||
STATE_ENABLED,
|
STATE_ENABLED,
|
||||||
STATE_DISABLED,
|
STATE_DISABLED,
|
||||||
STATE_NOT_INITIALIZED
|
STATE_NOT_INITIALIZED,
|
||||||
|
STATE_ESTABLISHED,
|
||||||
} eMBState = STATE_NOT_INITIALIZED;
|
} eMBState = STATE_NOT_INITIALIZED;
|
||||||
|
|
||||||
/* Functions pointer which are initialized in eMBInit( ). Depending on the
|
/* Functions pointer which are initialized in eMBInit( ). Depending on the
|
||||||
|
@ -233,7 +234,7 @@ eMBMasterDisable( void )
|
||||||
{
|
{
|
||||||
eMBErrorCode eStatus;
|
eMBErrorCode eStatus;
|
||||||
|
|
||||||
if( eMBState == STATE_ENABLED )
|
if(( eMBState == STATE_ENABLED ) || ( eMBState == STATE_ESTABLISHED))
|
||||||
{
|
{
|
||||||
pvMBMasterFrameStopCur( );
|
pvMBMasterFrameStopCur( );
|
||||||
eMBState = STATE_DISABLED;
|
eMBState = STATE_DISABLED;
|
||||||
|
@ -250,6 +251,20 @@ eMBMasterDisable( void )
|
||||||
return eStatus;
|
return eStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
eMBMasterIsEstablished( void )
|
||||||
|
{
|
||||||
|
if(eMBState == STATE_ESTABLISHED)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
eMBErrorCode
|
eMBErrorCode
|
||||||
eMBMasterPoll( void )
|
eMBMasterPoll( void )
|
||||||
{
|
{
|
||||||
|
@ -265,7 +280,7 @@ eMBMasterPoll( void )
|
||||||
eMBMasterErrorEventType errorType;
|
eMBMasterErrorEventType errorType;
|
||||||
|
|
||||||
/* Check if the protocol stack is ready. */
|
/* Check if the protocol stack is ready. */
|
||||||
if( eMBState != STATE_ENABLED )
|
if(( eMBState != STATE_ENABLED ) && ( eMBState != STATE_ESTABLISHED))
|
||||||
{
|
{
|
||||||
return MB_EILLSTATE;
|
return MB_EILLSTATE;
|
||||||
}
|
}
|
||||||
|
@ -277,6 +292,7 @@ eMBMasterPoll( void )
|
||||||
switch ( eEvent )
|
switch ( eEvent )
|
||||||
{
|
{
|
||||||
case EV_MASTER_READY:
|
case EV_MASTER_READY:
|
||||||
|
eMBState = STATE_ESTABLISHED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EV_MASTER_FRAME_RECEIVED:
|
case EV_MASTER_FRAME_RECEIVED:
|
||||||
|
|
Loading…
Reference in New Issue