1、【优化】错误帧判断逻辑。感谢网友“worldsing”的反馈。

Signed-off-by: armink <armink.ztl@gmail.com>
This commit is contained in:
armink 2013-12-04 12:15:33 +08:00
parent d5b26b9516
commit 460be47a96
1 changed files with 23 additions and 16 deletions

View File

@ -292,23 +292,30 @@ eMBMasterPoll( void )
case EV_MASTER_EXECUTE:
ucFunctionCode = ucMBFrame[MB_PDU_FUNC_OFF];
eException = MB_EX_ILLEGAL_FUNCTION;
for( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ )
{
/* No more function handlers registered. Abort. */
if( xMasterFuncHandlers[i].ucFunctionCode == 0 )
{
break;
}
else if( xMasterFuncHandlers[i].ucFunctionCode == ucFunctionCode )
{
vMBMasterSetCBRunInMasterMode(TRUE);
eException = xMasterFuncHandlers[i].pxHandler( ucMBFrame, &usLength );
vMBMasterSetCBRunInMasterMode(FALSE);
break;
}
}
/* If receive frame has exception .The receive function code highest bit is 1.*/
if(ucFunctionCode >> 7) eException = (eMBException)ucMBFrame[MB_PDU_DATA_OFF];
if(ucFunctionCode >> 7) {
eException = (eMBException)ucMBFrame[MB_PDU_DATA_OFF];
}
else
{
for (i = 0; i < MB_FUNC_HANDLERS_MAX; i++)
{
/* No more function handlers registered. Abort. */
if (xMasterFuncHandlers[i].ucFunctionCode == 0)
{
break;
}
else if (xMasterFuncHandlers[i].ucFunctionCode
== ucFunctionCode)
{
vMBMasterSetCBRunInMasterMode(TRUE);
eException = xMasterFuncHandlers[i].pxHandler(ucMBFrame,
&usLength);
vMBMasterSetCBRunInMasterMode(FALSE);
break;
}
}
}
/* If master has exception ,Master will send error process.Otherwise the Master is idle.*/
if (eException != MB_EX_NONE) ( void ) xMBMasterPortEventPost( EV_MASTER_ERROR_PROCESS );
else vMBMasterSetIsBusy( FALSE );