示例#1
0
//------------------------------------------------------------------------------
static BOOL getMnSyncRequest(tDllReqServiceId* pReqServiceId_p, UINT* pNodeId_p,
                             tSoaPayload* pSoaPayload_p)
{
    tOplkError          ret;
    ULONG               syncReqCount = 0;
    UINT                syncReqSize = 0;
    tDllSyncRequest     syncRequest;
    tDllNodeOpParam     nodeOpParam;

    // next queue will be CnGenReq queue
    instance_l.nextRequestQueue = 0;
    ret = instance_l.pTxSyncFuncs->pfnGetDataBlockCount(
                                instance_l.dllCalQueueTxSync, &syncReqCount);
    if (ret != kErrorOk)
    {
        return TRUE;
    }
    if (syncReqCount > 0)
    {
        syncReqSize = sizeof(syncRequest);
        ret = instance_l.pTxSyncFuncs->pfnGetDataBlock(
                               instance_l.dllCalQueueTxSync,
                               (BYTE *)&syncRequest, &syncReqSize);
        if (ret != kErrorOk)
        {
            return TRUE;
        }

        if (syncReqSize > offsetof(tDllSyncRequest, syncControl))
        {
            ami_setUint32Le(&pSoaPayload_p->syncRequest.syncControlLe,
                            syncRequest.syncControl);
            if ((syncRequest.syncControl & PLK_SYNC_PRES_MODE_SET) != 0)
            {
                nodeOpParam.opNodeType = kDllNodeOpTypeIsochronous;
                nodeOpParam.nodeId = syncRequest.nodeId;
                ret = dllk_addNode(&nodeOpParam);
                if (ret != kErrorOk)
                {
                    return TRUE;
                }
            }
            if ((syncRequest.syncControl & PLK_SYNC_PRES_MODE_RESET) != 0)
            {
                nodeOpParam.opNodeType = kDllNodeOpTypeIsochronous;
                nodeOpParam.nodeId = syncRequest.nodeId;
                ret = dllk_deleteNode(&nodeOpParam);
                if (ret != kErrorOk)
                {
                    return TRUE;
                }
            }
        }
        if (syncReqSize > offsetof(tDllSyncRequest, pResTimeFirst))
        {
            ami_setUint32Le(&pSoaPayload_p->syncRequest.presTimeFirstLe,
                            syncRequest.pResTimeFirst);
        }
        if (syncReqSize > offsetof(tDllSyncRequest, pResFallBackTimeout))
        {
            ami_setUint32Le(&pSoaPayload_p->syncRequest.presFallBackTimeoutLe,
                            syncRequest.pResFallBackTimeout);
        }

        if ((syncRequest.syncControl & PLK_SYNC_DEST_MAC_ADDRESS_VALID) != 0)
        {
            ret = dllk_getCnMacAddress(syncRequest.nodeId,
                            &pSoaPayload_p->syncRequest.aDestMacAddress[0]);
            if (ret != kErrorOk)
            {
                return TRUE;
            }
        }

        *pNodeId_p = syncRequest.nodeId;
        *pReqServiceId_p = kDllReqServiceSync;
        return TRUE;
    }
    return FALSE;
}
示例#2
0
//------------------------------------------------------------------------------
tOplkError dllkcal_process(tEvent* pEvent_p)
{
    tOplkError                  ret = kErrorOk;
    tDllCalAsndServiceIdFilter* pServFilter;
    tDllIdentParam*             pIdentParam;
    tDllConfigParam*            pConfigParam;

#if defined(CONFIG_INCLUDE_NMT_MN)
    tDllCalIssueRequest*        pIssueReq;
#endif

#if NMT_MAX_NODE_ID > 0
    tDllNodeInfo*               pNodeInfo;
    tDllNodeOpParam*            pNodeOpParam;
#endif

#if CONFIG_DLL_DEFERRED_RXFRAME_RELEASE_ASYNC == TRUE
    tFrameInfo* pFrameInfo;
#endif

    switch (pEvent_p->eventType)
    {
        case kEventTypeDllkServFilter:
            pServFilter = (tDllCalAsndServiceIdFilter*)pEvent_p->eventArg.pEventArg;
            ret = dllk_setAsndServiceIdFilter(pServFilter->serviceId,
                                              pServFilter->filter);
            break;

#if defined(CONFIG_INCLUDE_NMT_MN)
        case kEventTypeDllkIssueReq:
            pIssueReq = (tDllCalIssueRequest*)pEvent_p->eventArg.pEventArg;
            ret = dllkcal_issueRequest(pIssueReq->service, pIssueReq->nodeId,
                                       pIssueReq->soaFlag1);
            break;
#endif

#if NMT_MAX_NODE_ID > 0
        case kEventTypeDllkConfigNode:
            pNodeInfo = (tDllNodeInfo*)pEvent_p->eventArg.pEventArg;
            ret = dllk_configNode(pNodeInfo);
            break;

        case kEventTypeDllkAddNode:
            pNodeOpParam = (tDllNodeOpParam*)pEvent_p->eventArg.pEventArg;
            ret = dllk_addNode(pNodeOpParam);
            break;

        case kEventTypeDllkDelNode:
            pNodeOpParam = (tDllNodeOpParam*)pEvent_p->eventArg.pEventArg;
            ret = dllk_deleteNode(pNodeOpParam);
            break;
#endif // NMT_MAX_NODE_ID > 0

        case kEventTypeDllkIdentity:
            pIdentParam = (tDllIdentParam*)pEvent_p->eventArg.pEventArg;
            if (pIdentParam->sizeOfStruct > pEvent_p->eventArgSize)
            {
                pIdentParam->sizeOfStruct = pEvent_p->eventArgSize;
            }
            ret = dllk_setIdentity(pIdentParam);
            break;

        case kEventTypeDllkConfig:
            pConfigParam = (tDllConfigParam*)pEvent_p->eventArg.pEventArg;
            if (pConfigParam->sizeOfStruct > pEvent_p->eventArgSize)
            {
                pConfigParam->sizeOfStruct = pEvent_p->eventArgSize;
            }
            ret = dllk_config(pConfigParam);
            break;

#if CONFIG_DLL_DEFERRED_RXFRAME_RELEASE_ASYNC == TRUE
        case kEventTypeReleaseRxFrame:
            pFrameInfo = (tFrameInfo*)pEvent_p->eventArg.pEventArg;
            ret = dllk_releaseRxFrame(pFrameInfo->frame.pBuffer, pFrameInfo->frameSize);
            if (ret == kErrorOk)
            {
                instance_l.asyncFrameFreed++;

                instance_l.statistics.curRxFrameCount = instance_l.asyncFrameReceived - instance_l.asyncFrameFreed;
            }
            break;
#endif

        default:
            ret = kErrorInvalidEvent;
            break;
    }

    return ret;
}
//------------------------------------------------------------------------------
tOplkError pdok_configureChannel(tPdoChannelConf* pChannelConf_p)
{
    tOplkError          Ret = kErrorOk;
    tPdoChannel*        pDestPdoChannel;

    if (pChannelConf_p->fTx == FALSE)
    {   // RPDO
#if NMT_MAX_NODE_ID > 0
        tDllNodeOpParam     NodeOpParam;
        NodeOpParam.opNodeType = kDllNodeOpTypeFilterPdo;
#endif

        if (pChannelConf_p->channelId >= pdokInstance_g.pdoChannels.allocation.rxPdoChannelCount)
        {
            Ret = kErrorPdoNotExist;
            goto Exit;
        }

        pDestPdoChannel = &pdokInstance_g.pdoChannels.pRxPdoChannel[pChannelConf_p->channelId];

        // copy channel configuration to local structure
        OPLK_MEMCPY(pDestPdoChannel, &pChannelConf_p->pdoChannel,
                    sizeof(pChannelConf_p->pdoChannel));

        // Store channel ID for fast access
        pdokInstance_g.aRpdoChannelIdLut[pDestPdoChannel->nodeId] = pChannelConf_p->channelId;

#if NMT_MAX_NODE_ID > 0
        if ((pDestPdoChannel->nodeId != PDO_INVALID_NODE_ID) &&
            (pDestPdoChannel->nodeId != PDO_PREQ_NODE_ID))
        {   // disable old PRes filter in DLL
            NodeOpParam.nodeId = pDestPdoChannel->nodeId;
            Ret = dllk_deleteNode(&NodeOpParam);
            if (Ret != kErrorOk)
            {
                goto Exit;
            }
        }
#endif // NMT_MAX_NODE_ID > 0

#if NMT_MAX_NODE_ID > 0
        if ((pDestPdoChannel->nodeId != PDO_INVALID_NODE_ID) &&
            (pDestPdoChannel->nodeId != PDO_PREQ_NODE_ID))
        {   // enable new PRes filter in DLL
            NodeOpParam.nodeId = pDestPdoChannel->nodeId;
            Ret = dllk_addNode(&NodeOpParam);
            if (Ret != kErrorOk)
            {
                goto Exit;
            }
        }
#endif // NMT_MAX_NODE_ID > 0

    }
    else
    {   // TPDO
        if (pChannelConf_p->channelId >= pdokInstance_g.pdoChannels.allocation.txPdoChannelCount)
        {
            Ret = kErrorPdoNotExist;
            goto Exit;
        }

        pDestPdoChannel = &pdokInstance_g.pdoChannels.pTxPdoChannel[pChannelConf_p->channelId];

        // copy channel to local structure
        OPLK_MEMCPY(pDestPdoChannel, &pChannelConf_p->pdoChannel,
                    sizeof(pChannelConf_p->pdoChannel));

        // Store channel ID for fast access
        pdokInstance_g.aTpdoChannelIdLut[pDestPdoChannel->nodeId] = pChannelConf_p->channelId;
    }

    pdokInstance_g.fRunning = FALSE;
Exit:
    return Ret;
}