Beispiel #1
0
eMBErrorCode
eMBTCPInit( USHORT ucTCPPort )
{
    eMBErrorCode    eStatus = MB_ENOERR;

    if( ( eStatus = eMBTCPDoInit( ucTCPPort ) ) != MB_ENOERR )
    {
        eMBState = STATE_DISABLED;
    }
    else if( !xMBPortEventInit(  ) )
    {
        /* Port dependent event module initalization failed. */
        eStatus = MB_EPORTERR;
    }
    else
    {
        pvMBFrameStartCur = eMBTCPStart;
        pvMBFrameStopCur = eMBTCPStop;
        peMBFrameReceiveCur = eMBTCPReceive;
        peMBFrameSendCur = eMBTCPSend;
        pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBTCPPortClose : NULL;
        ucMBAddress = MB_TCP_PSEUDO_ADDRESS;
        eMBCurrentMode = MB_TCP;
        eMBState = STATE_DISABLED;
    }
    return eStatus;
}
Beispiel #2
0
eMBErrorCode eMBTCPInit(uint16_t ucTCPPort)
{
  eMBErrorCode eStatus = MB_ENOERR;

  if ((eStatus = eMBTCPDoInit(ucTCPPort)) != MB_ENOERR)
    {
      eMBState = STATE_DISABLED;
    }
  else if (!xMBPortEventInit())
    {
      /* Port dependent event module initialization failed. */

      eStatus = MB_EPORTERR;
    }
  else
    {
      pvMBFrameStartCur = eMBTCPStart;
      pvMBFrameStopCur = eMBTCPStop;
      peMBFrameReceiveCur = eMBTCPReceive;
      peMBFrameSendCur = eMBTCPSend;
#ifdef CONFIG_MB_HAVE_CLOSE
      pvMBFrameCloseCur = vMBTCPPortClose;
#else
      pvMBFrameCloseCur = NULL;
#endif
      ucMBAddress = MB_TCP_PSEUDO_ADDRESS;
      eMBCurrentMode = MB_TCP;
      eMBState = STATE_DISABLED;
    }

  return eStatus;
}