Skip to content

freemodbus主机代码经过疲劳测试触发定时器断言 #86

@XieFang2019

Description

@XieFang2019

freemodbus主机代码经过几小时测试触发定时器断言

(( eSndState == STATE_M_TX_XFWR ) || ( eSndState == STATE_M_TX_IDLE )) has assert failed at xMBMasterRTUTimerExpired.

此断言发生在软定时器回调中

xMBMasterRTUTimerExpired(void){
...
    switch (eSndState)
    {
        /* A frame was send finish and convert delay or respond timeout expired.
         * If the frame is broadcast,The master will idle,and if the frame is not
         * broadcast.Notify the listener process error.*/
    case STATE_M_TX_XFWR:
        if ( xFrameIsBroadcast == FALSE ) {
            vMBMasterSetErrorType(EV_ERROR_RESPOND_TIMEOUT);
            xNeedPoll = xMBMasterPortEventPost(EV_MASTER_ERROR_PROCESS);
        }
        break;
        /* Function called in an illegal state. */
    default:
        CMB_ASSERT(
                ( eSndState == STATE_M_TX_XFWR ) || ( eSndState == STATE_M_TX_IDLE ));
        break;
    }
...
}

接收到软定时器回调时处于 STATE_M_TX_IDLE 状态 此时处理switch (eSndState)就会进入断言
相反这时候应该是STATE_M_TX_XMIT状态才正常

typedef enum
{
    STATE_M_TX_IDLE,              /*!< Transmitter is in idle state. */
    STATE_M_TX_XMIT,              /*!< Transmitter is in transfer state. */
    STATE_M_TX_XFWR,              /*!< Transmitter is in transfer finish and wait receive state. */
} eMBMasterSndState;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions