tEplKernel EplDllkCalIssueRequest(tEplDllReqServiceId Service_p, unsigned int uiNodeId_p, BYTE bSoaFlag1_p) { tEplKernel Ret = kEplSuccessful; if (bSoaFlag1_p != 0xFF) { Ret = EplDllkSetFlag1OfNode(uiNodeId_p, bSoaFlag1_p); if (Ret != kEplSuccessful) { goto Exit; } } // add node to appropriate request queue switch (Service_p) { case kEplDllReqServiceIdent: { if (((EplDllkCalInstance_g.m_uiWriteIdentReq + 1) % tabentries (EplDllkCalInstance_g.m_auiQueueIdentReq)) == EplDllkCalInstance_g.m_uiReadIdentReq) { // queue is full Ret = kEplDllAsyncTxBufferFull; goto Exit; } EplDllkCalInstance_g.m_auiQueueIdentReq[EplDllkCalInstance_g.m_uiWriteIdentReq] = uiNodeId_p; EplDllkCalInstance_g.m_uiWriteIdentReq = (EplDllkCalInstance_g.m_uiWriteIdentReq + 1) % tabentries (EplDllkCalInstance_g.m_auiQueueIdentReq); break; } case kEplDllReqServiceStatus: { if (((EplDllkCalInstance_g.m_uiWriteStatusReq + 1) % tabentries (EplDllkCalInstance_g.m_auiQueueStatusReq)) == EplDllkCalInstance_g.m_uiReadStatusReq) { // queue is full Ret = kEplDllAsyncTxBufferFull; goto Exit; } EplDllkCalInstance_g.m_auiQueueStatusReq[EplDllkCalInstance_g.m_uiWriteStatusReq] = uiNodeId_p; EplDllkCalInstance_g.m_uiWriteStatusReq = (EplDllkCalInstance_g.m_uiWriteStatusReq + 1) % tabentries (EplDllkCalInstance_g.m_auiQueueStatusReq); break; } default: { Ret = kEplDllInvalidParam; goto Exit; } } Exit: return Ret; }
//------------------------------------------------------------------------------ static tOplkError syncResponseCb(const tFrameInfo* pFrameInfo_p) { tOplkError ret = kErrorOk; UINT nodeId; UINT index; tSyncuCbResponse pfnCbResponse; nodeId = ami_getUint8Le(&pFrameInfo_p->frame.pBuffer->srcNodeId); index = nodeId - 1; if (index < tabentries(syncuInstance_g.aSyncRespQueue)) { // memorize pointer to callback function pfnCbResponse = readResponseQueue(nodeId); if (pfnCbResponse == NULL) { // response was not requested return ret; } if (pFrameInfo_p->frameSize < C_DLL_MINSIZE_SYNCRES) { // SyncResponse not received or it has invalid size ret = pfnCbResponse(nodeId, NULL); } else { // SyncResponse received ret = pfnCbResponse(nodeId, &pFrameInfo_p->frame.pBuffer->data.asnd.payload.syncResponse); } } return ret; }
//--------------------------------------------------------------------------- // // Function: EplStatusuCbStatusResponse // // Description: callback funktion for StatusResponse // // // // Parameters: pFrameInfo_p = Frame with the StatusResponse // // // Returns: tEplKernel = error code // // // State: // //--------------------------------------------------------------------------- static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p) { tEplKernel Ret = kEplSuccessful; unsigned int uiNodeId; unsigned int uiIndex; tEplStatusuCbResponse pfnCbResponse; uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId); uiIndex = uiNodeId - 1; if (uiIndex < tabentries(EplStatusuInstance_g.m_apfnCbResponse)) { // memorize pointer to callback function pfnCbResponse = EplStatusuInstance_g.m_apfnCbResponse[uiIndex]; if (pfnCbResponse == NULL) { // response was not requested goto Exit; } // reset callback function pointer so that caller may issue next request EplStatusuInstance_g.m_apfnCbResponse[uiIndex] = NULL; if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_STATUSRES) { // StatusResponse not received or it has invalid size Ret = pfnCbResponse(uiNodeId, NULL); } else { // StatusResponse received Ret = pfnCbResponse(uiNodeId, &pFrameInfo_p->m_pFrame->m_Data. m_Asnd.m_Payload.m_StatusResponse); } } Exit: return Ret; }
tEplKernel EplIdentuRequestIdentResponse(unsigned int uiNodeId_p, tEplIdentuCbResponse pfnCbResponse_p) { tEplKernel Ret; Ret = kEplSuccessful; // decrement node ID, because array is zero based uiNodeId_p--; if (uiNodeId_p < tabentries(EplIdentuInstance_g.m_apfnCbResponse)) { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) if (EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL) { // request already issued (maybe by someone else) Ret = kEplInvalidOperation; } else { EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] = pfnCbResponse_p; Ret = EplDlluCalIssueRequest(kEplDllReqServiceIdent, (uiNodeId_p + 1), 0xFF); } #else Ret = kEplInvalidOperation; #endif } else { // invalid node ID specified Ret = kEplInvalidNodeId; } return Ret; }
tEplKernel PUBLIC EplIdentuGetIdentResponse( unsigned int uiNodeId_p, tEplIdentResponse** ppIdentResponse_p) { tEplKernel Ret; tEplIdentResponse* pIdentResponse; Ret = kEplSuccessful; // decrement node ID, because array is zero based uiNodeId_p--; if (uiNodeId_p < tabentries (EplIdentuInstance_g.m_apIdentResponse)) { pIdentResponse = EplIdentuInstance_g.m_apIdentResponse[uiNodeId_p]; *ppIdentResponse_p = pIdentResponse; // Check if ident response is valid, adjust return value otherwise if( NULL == pIdentResponse ) { Ret = kEplInvalidOperation; } } else { // invalid node ID specified *ppIdentResponse_p = NULL; Ret = kEplInvalidNodeId; } return Ret; }
//------------------------------------------------------------------------------ tOplkError syncu_requestSyncResponse(tSyncuCbResponse pfnCbResponse_p, const tDllSyncRequest* pSyncRequestData_p, size_t size_p) { tOplkError ret = kErrorOk; UINT nodeId; UINT index; // Check parameter validity ASSERT(pSyncRequestData_p != NULL); nodeId = pSyncRequestData_p->nodeId; if (nodeId == 0) return kErrorInvalidNodeId; index = nodeId - 1; if (index < tabentries(syncuInstance_g.aSyncRespQueue)) { ret = writeResponseQueue(nodeId, pfnCbResponse_p); if (ret == kErrorOk) ret = dllucal_issueSyncRequest(pSyncRequestData_p, size_p); } else ret = kErrorInvalidNodeId; return ret; }
static tEplKernel EplIdentuCbIdentResponse(tEplFrameInfo *pFrameInfo_p) { tEplKernel Ret = kEplSuccessful; unsigned int uiNodeId; unsigned int uiIndex; tEplIdentuCbResponse pfnCbResponse; uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId); uiIndex = uiNodeId - 1; if (uiIndex < tabentries(EplIdentuInstance_g.m_apfnCbResponse)) { // memorize pointer to callback function pfnCbResponse = EplIdentuInstance_g.m_apfnCbResponse[uiIndex]; // reset callback function pointer so that caller may issue next request immediately EplIdentuInstance_g.m_apfnCbResponse[uiIndex] = NULL; if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_IDENTRES) { // IdentResponse not received or it has invalid size if (pfnCbResponse == NULL) { // response was not requested goto Exit; } Ret = pfnCbResponse(uiNodeId, NULL); } else { // IdentResponse received if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL) { // memory for IdentResponse must be allocated EplIdentuInstance_g.m_apIdentResponse[uiIndex] = EPL_MALLOC(sizeof(tEplIdentResponse)); if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL) { // malloc failed if (pfnCbResponse == NULL) { // response was not requested goto Exit; } Ret = pfnCbResponse(uiNodeId, &pFrameInfo_p-> m_pFrame->m_Data. m_Asnd.m_Payload. m_IdentResponse); goto Exit; } } // copy IdentResponse to instance structure EPL_MEMCPY(EplIdentuInstance_g. m_apIdentResponse[uiIndex], &pFrameInfo_p->m_pFrame->m_Data.m_Asnd. m_Payload.m_IdentResponse, sizeof(tEplIdentResponse)); if (pfnCbResponse == NULL) { // response was not requested goto Exit; } Ret = pfnCbResponse(uiNodeId, EplIdentuInstance_g. m_apIdentResponse[uiIndex]); } } Exit: return Ret; }
//------------------------------------------------------------------------------ tDllkNodeInfo* dllknode_getNodeInfo(UINT nodeId_p) { // $$$ d.k.: use hash algorithm to retrieve the appropriate node info structure // if size of array is less than 254. nodeId_p--; // node ID starts at 1 but array at 0 if (nodeId_p >= tabentries(dllkInstance_g.aNodeInfo)) return NULL; else return &dllkInstance_g.aNodeInfo[nodeId_p]; }
//------------------------------------------------------------------------------ char* debugstr_getNmtStateStr(tNmtState nmtState_p) { unsigned int i; for (i = 0; i < tabentries(nmtStateInfo_l); i++) { if (nmtStateInfo_l[i].nmtState == nmtState_p) return (nmtStateInfo_l[i].sNmtState); } return invalidStr_l; }
//------------------------------------------------------------------------------ char* debugstr_getApiEventStr(tOplkApiEventType ApiEvent_p) { UINT i; for (i = 0; i < tabentries(apiEventInfo_l); i++) { if (apiEventInfo_l[i].apiEvent == ApiEvent_p) return (apiEventInfo_l[i].sApiEvent); } return invalidStr_l; }
//------------------------------------------------------------------------------ char* debugstr_getNmtBootEventTypeStr(tNmtBootEvent BootEventType_p) { if (BootEventType_p >= tabentries(OplkNmtBootEvtTypeStr_g)) { return invalidStr_l; } else { return OplkNmtBootEvtTypeStr_g[BootEventType_p]; } }
//------------------------------------------------------------------------------ char* debugstr_getEventTypeStr(tEventType eventType_p) { if (eventType_p >= tabentries(eventTypeStr_l)) { return invalidStr_l; } else { return eventTypeStr_l[eventType_p]; } }
//------------------------------------------------------------------------------ char* debugstr_getNmtEventStr(tNmtEvent nmtEvent_p) { if (nmtEvent_p >= tabentries(nmtEventStr_l)) { return invalidStr_l; } else { return nmtEventStr_l[nmtEvent_p]; } }
//------------------------------------------------------------------------------ char* debugstr_getRetValStr(tOplkError OplkError_p) { UINT i; for (i = 0; i < tabentries(retValInfo_l); i++) { if (retValInfo_l[i].key == OplkError_p) return (retValInfo_l[i].sName); } return invalidStr_l; }
//------------------------------------------------------------------------------ char* debugstr_getSdoComConStateStr(tSdoComConState SdoComConState_p) { if (SdoComConState_p >= tabentries(OplkSdoComConStateStr_g)) { return invalidStr_l; } else { return OplkSdoComConStateStr_g[SdoComConState_p]; } }
//------------------------------------------------------------------------------ tOplkError dllk_setAsndServiceIdFilter(tDllAsndServiceId serviceId_p, tDllAsndFilter filter_p) { tOplkError ret = kErrorOk; if (serviceId_p < tabentries(dllkInstance_g.aAsndFilter)) dllkInstance_g.aAsndFilter[serviceId_p] = filter_p; else ret = kErrorDllInvalidAsndServiceId; return ret; }
//------------------------------------------------------------------------------ char* debugstr_getEmergErrCodeStr(UINT16 emergErrCode_p) { UINT i; for (i = 0; i < tabentries(emergErrCodeInfo_l); i++) { if (emergErrCodeInfo_l[i].key == emergErrCode_p) return (emergErrCodeInfo_l[i].sName); } return invalidStr_l; }
//------------------------------------------------------------------------------ tOplkError dllk_init(void) { tOplkError ret = kErrorOk; UINT index; // reset instance structure OPLK_MEMSET(&dllkInstance_g, 0, sizeof(dllkInstance_g)); #if (CONFIG_DLL_PROCESS_SYNC == DLL_PROCESS_SYNC_ON_TIMER) if ((ret = synctimer_registerHandler(cbCnTimerSync)) != kErrorOk) return ret; if ((ret = synctimer_registerLossOfSyncHandler(cbCnLossOfSync)) != kErrorOk) return ret; #if CONFIG_DLL_PRES_CHAINING_CN != FALSE if ((ret = synctimer_registerLossOfSyncHandler2(cbCnPresFallbackTimeout)) != kErrorOk) return ret; #endif if ((ret = synctimer_setSyncShift(CONFIG_DLL_SOC_SYNC_SHIFT_US)) != kErrorOk) return ret; #endif // if dynamic memory allocation available, allocate instance structure // initialize and link pointers in instance structure to frame tables dllkInstance_g.pTxBuffer = aDllkTxBuffer_l; dllkInstance_g.maxTxFrames = sizeof(aDllkTxBuffer_l) / sizeof(tEdrvTxBuffer); dllkInstance_g.dllState = kDllGsInit; // initialize state #if NMT_MAX_NODE_ID > 0 // set up node info structure for (index = 0; index < tabentries(dllkInstance_g.aNodeInfo); index++) { dllkInstance_g.aNodeInfo[index].nodeId = index + 1; #if defined(CONFIG_INCLUDE_NMT_MN) dllkInstance_g.aNodeInfo[index].soaFlag1 |= PLK_FRAME_FLAG1_ER; dllkInstance_g.aNodeInfo[index].errSigState = STATE_MN_ERRSIG_INIT_WAIT_EC1; dllkInstance_g.aNodeInfo[index].errSigReqCnt = 0; #endif } #endif // initialize TxBuffer array for (index = 0; index < dllkInstance_g.maxTxFrames; index++) { dllkInstance_g.pTxBuffer[index].pBuffer = NULL; } return ret; }
tEplKernel PUBLIC EplErrorHandlerkResetCnError(unsigned int uiNodeId_p) { tEplKernel Ret = kEplSuccessful; uiNodeId_p--; if (uiNodeId_p < tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt)) { EplErrorHandlerkInstance_g.m_abMnCnLossPresEvent[uiNodeId_p] = EPL_ERRORHANDLERK_CN_LOSS_PRES_EVENT_NONE; } return Ret; }
tEplKernel EplDllkCalAsyncSetPendingRequests(unsigned int uiNodeId_p, tEplDllAsyncReqPriority AsyncReqPrio_p, unsigned int uiCount_p) { tEplKernel Ret = kEplSuccessful; // add node to appropriate request queue switch (AsyncReqPrio_p) { case kEplDllAsyncReqPrioNmt: { uiNodeId_p--; if (uiNodeId_p >= (tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests) / 2)) { Ret = kEplDllInvalidParam; goto Exit; } uiNodeId_p += tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests) / 2; EplDllkCalInstance_g.m_auiQueueCnRequests[uiNodeId_p] = uiCount_p; break; } default: { uiNodeId_p--; if (uiNodeId_p >= (tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests) / 2)) { Ret = kEplDllInvalidParam; goto Exit; } EplDllkCalInstance_g.m_auiQueueCnRequests[uiNodeId_p] = uiCount_p; break; } } Exit: return Ret; }
//------------------------------------------------------------------------------ char* debugstr_getAbortCodeStr(UINT32 abortCode_p) { tAbortCodeInfo* pEntry; UINT i; pEntry = abortCodeInfo_g; for (i = 0; i < tabentries(abortCodeInfo_g); i++) { if (pEntry->abortCode == abortCode_p) { return pEntry->sAbortCode; } pEntry++; } return invalidStr_l; }
//------------------------------------------------------------------------------ UINT obdpi_setupProcessImage(void) { UINT errorIndex = 0; size_t i; tProcessImageLink* pLink; pLink = processImageLink_l; for (i = 0; i < tabentries(processImageLink_l); i++, pLink++) { errorIndex = linkProcessImageRange(pLink->objIndexStart, pLink->objIndexEnd, pLink->offsetPI, pLink->fOutputPI, pLink->entrySize, pLink->subindexCountPerIndex); if (errorIndex != 0) break; } return errorIndex; }
tEplKernel EplIdentuGetIdentResponse(unsigned int uiNodeId_p, tEplIdentResponse **ppIdentResponse_p) { tEplKernel Ret; Ret = kEplSuccessful; // decrement node ID, because array is zero based uiNodeId_p--; if (uiNodeId_p < tabentries(EplIdentuInstance_g.m_apIdentResponse)) { *ppIdentResponse_p = EplIdentuInstance_g.m_apIdentResponse[uiNodeId_p]; } else { // invalid node ID specified *ppIdentResponse_p = NULL; Ret = kEplInvalidNodeId; } return Ret; }
tEplKernel EplIdentuReset(void) { tEplKernel Ret; int iIndex; Ret = kEplSuccessful; for (iIndex = 0; iIndex < tabentries(EplIdentuInstance_g.m_apIdentResponse); iIndex++) { if (EplIdentuInstance_g.m_apIdentResponse[iIndex] != NULL) { // free memory EPL_FREE(EplIdentuInstance_g.m_apIdentResponse[iIndex]); } } EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof(EplIdentuInstance_g)); return Ret; }
tEplKernel EplDlluCalRegAsndService(tEplDllAsndServiceId ServiceId_p, tEplDlluCbAsnd pfnDlluCbAsnd_p, tEplDllAsndFilter Filter_p) { tEplKernel Ret = kEplSuccessful; if (ServiceId_p < tabentries(EplDlluCalInstance_g.m_apfnDlluCbAsnd)) { // memorize function pointer EplDlluCalInstance_g.m_apfnDlluCbAsnd[ServiceId_p] = pfnDlluCbAsnd_p; if (pfnDlluCbAsnd_p == NULL) { // close filter Filter_p = kEplDllAsndFilterNone; } // set filter in DLL module in kernel part Ret = EplDlluCalSetAsndServiceIdFilter(ServiceId_p, Filter_p); } return Ret; }
tEplKernel PUBLIC EplSyncuRequestSyncResponse( tEplSyncuCbResponse pfnCbResponse_p, tEplDllSyncRequest* pSyncRequestData_p, unsigned int uiSize_p) { tEplKernel Ret; unsigned int uiNodeId; Ret = kEplSuccessful; uiNodeId = pSyncRequestData_p->m_uiNodeId; if (uiNodeId == 0) { Ret = kEplInvalidNodeId; goto Exit; } // decrement node ID, because array is zero based uiNodeId--; if (uiNodeId < tabentries (EplSyncuInstance_g.m_apfnCbResponse)) { if (EplSyncuInstance_g.m_apfnCbResponse[uiNodeId] != NULL) { // request already issued (maybe by someone else) Ret = kEplNmtSyncReqRejected; } else { EplSyncuInstance_g.m_apfnCbResponse[uiNodeId] = pfnCbResponse_p; Ret = EplDlluCalIssueSyncRequest(pSyncRequestData_p, uiSize_p); } } else { // invalid node ID specified Ret = kEplInvalidNodeId; } Exit: return Ret; }
//------------------------------------------------------------------------------ tOplkError dllucal_regAsndService(tDllAsndServiceId serviceId_p, tDlluCbAsnd pfnDlluCbAsnd_p, tDllAsndFilter filter_p) { tOplkError ret; if (serviceId_p < tabentries(instance_l.apfnDlluCbAsnd)) { // memorize function pointer instance_l.apfnDlluCbAsnd[serviceId_p] = pfnDlluCbAsnd_p; if (pfnDlluCbAsnd_p == NULL) { // close filter filter_p = kDllAsndFilterNone; } // set filter in DLL module in kernel part ret = setAsndServiceIdFilter(serviceId_p, filter_p); } else ret = kErrorDllInvalidAsndServiceId; return ret; }
tEplKernel EplDllkCalAsyncGetSoaRequest(tEplDllReqServiceId* pReqServiceId_p, unsigned int* puiNodeId_p) { tEplKernel Ret = kEplSuccessful; unsigned int uiCount; // *pReqServiceId_p = kEplDllReqServiceNo; for (uiCount = EPL_DLLKCAL_MAX_QUEUES; uiCount > 0; uiCount--) { switch (EplDllkCalInstance_g.m_uiNextRequestQueue) { case 0: { // CnGenReq for (;EplDllkCalInstance_g.m_uiNextQueueCnRequest < (tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests) / 2); EplDllkCalInstance_g.m_uiNextQueueCnRequest++) { if (EplDllkCalInstance_g.m_auiQueueCnRequests[EplDllkCalInstance_g.m_uiNextQueueCnRequest] > 0) { // non empty queue found // remove one request from queue EplDllkCalInstance_g.m_auiQueueCnRequests[EplDllkCalInstance_g.m_uiNextQueueCnRequest]--; *puiNodeId_p = EplDllkCalInstance_g.m_uiNextQueueCnRequest + 1; *pReqServiceId_p = kEplDllReqServiceUnspecified; EplDllkCalInstance_g.m_uiNextQueueCnRequest++; if (EplDllkCalInstance_g.m_uiNextQueueCnRequest >= (tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests) / 2)) { // last node reached // continue with CnNmtReq queue at next SoA EplDllkCalInstance_g.m_uiNextRequestQueue = 1; } goto Exit; } } // all CnGenReq queues are empty -> continue with CnNmtReq queue EplDllkCalInstance_g.m_uiNextRequestQueue = 1; break; } case 1: { // CnNmtReq for (;EplDllkCalInstance_g.m_uiNextQueueCnRequest < tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests); EplDllkCalInstance_g.m_uiNextQueueCnRequest++) { if (EplDllkCalInstance_g.m_auiQueueCnRequests[EplDllkCalInstance_g.m_uiNextQueueCnRequest] > 0) { // non empty queue found // remove one request from queue EplDllkCalInstance_g.m_auiQueueCnRequests[EplDllkCalInstance_g.m_uiNextQueueCnRequest]--; *puiNodeId_p = EplDllkCalInstance_g.m_uiNextQueueCnRequest + 1 - (tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests) / 2); *pReqServiceId_p = kEplDllReqServiceNmtRequest; EplDllkCalInstance_g.m_uiNextQueueCnRequest++; if (EplDllkCalInstance_g.m_uiNextQueueCnRequest > tabentries (EplDllkCalInstance_g.m_auiQueueCnRequests)) { // last node reached // restart CnGenReq queue EplDllkCalInstance_g.m_uiNextQueueCnRequest = 0; // continue with MnGenReq queue at next SoA EplDllkCalInstance_g.m_uiNextRequestQueue = 2; } goto Exit; } } // restart CnGenReq queue EplDllkCalInstance_g.m_uiNextQueueCnRequest = 0; // all CnNmtReq queues are empty -> continue with MnGenReq queue EplDllkCalInstance_g.m_uiNextRequestQueue = 2; break; } case 2: { // MnNmtReq and MnGenReq // next queue will be MnIdentReq queue EplDllkCalInstance_g.m_uiNextRequestQueue = 3; if (*pReqServiceId_p != kEplDllReqServiceNo) { *puiNodeId_p = EPL_C_ADR_INVALID; // DLLk must exchange this with the actual node ID goto Exit; } break; } case 3: { // MnIdentReq // next queue will be MnStatusReq queue EplDllkCalInstance_g.m_uiNextRequestQueue = 4; if (EplDllkCalInstance_g.m_uiReadIdentReq != EplDllkCalInstance_g.m_uiWriteIdentReq) { // queue is not empty *puiNodeId_p = EplDllkCalInstance_g.m_auiQueueIdentReq[EplDllkCalInstance_g.m_uiReadIdentReq]; EplDllkCalInstance_g.m_uiReadIdentReq = (EplDllkCalInstance_g.m_uiReadIdentReq + 1) % tabentries (EplDllkCalInstance_g.m_auiQueueIdentReq); *pReqServiceId_p = kEplDllReqServiceIdent; goto Exit; } break; } case 4: { // MnStatusReq // next queue will be CnGenReq queue EplDllkCalInstance_g.m_uiNextRequestQueue = 0; if (EplDllkCalInstance_g.m_uiReadStatusReq != EplDllkCalInstance_g.m_uiWriteStatusReq) { // queue is not empty *puiNodeId_p = EplDllkCalInstance_g.m_auiQueueStatusReq[EplDllkCalInstance_g.m_uiReadStatusReq]; EplDllkCalInstance_g.m_uiReadStatusReq = (EplDllkCalInstance_g.m_uiReadStatusReq + 1) % tabentries (EplDllkCalInstance_g.m_auiQueueStatusReq); *pReqServiceId_p = kEplDllReqServiceStatus; goto Exit; } break; } } } Exit: return Ret; }
//--------------------------------------------------------------------------- // // Function: EplErrorHandlerkCycleFinished // // Description: cycle has been finished, so threshold counters can be decremented (called by DLL) // // Parameters: fMN_p = TRUE if local node is MN // // Returns: tEpKernel = errorcode // // State: // //--------------------------------------------------------------------------- tEplKernel PUBLIC EplErrorHandlerkCycleFinished(BOOL fMN_p) { tEplKernel Ret = kEplSuccessful; #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) if (fMN_p != FALSE) { // local node is MN -> decrement MN threshold counters BYTE* pbCnNodeId; unsigned int uiNodeId; Ret = EplDllkGetCurrentCnNodeIdList(&pbCnNodeId); if (Ret != kEplSuccessful) { goto Exit; } // iterate through node info structure list while (*pbCnNodeId != EPL_C_ADR_INVALID) { uiNodeId = *pbCnNodeId - 1; if (uiNodeId < tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt)) { if (EplErrorHandlerkInstance_g.m_abMnCnLossPresEvent[uiNodeId] == EPL_ERRORHANDLERK_CN_LOSS_PRES_EVENT_NONE) { if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId] > 0) { EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId]--; } } else if (EplErrorHandlerkInstance_g.m_abMnCnLossPresEvent[uiNodeId] == EPL_ERRORHANDLERK_CN_LOSS_PRES_EVENT_OCC) { EplErrorHandlerkInstance_g.m_abMnCnLossPresEvent[uiNodeId] = EPL_ERRORHANDLERK_CN_LOSS_PRES_EVENT_NONE; } } pbCnNodeId++; } if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_MN_CRC) == 0) { // decrement CRC threshold counter, because it didn't occur last cycle if (EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt > 0) { EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt--; } } if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_MN_CYCTIMEEXCEED) == 0) { // decrement cycle exceed threshold counter, because it didn't occur last cycle if (EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt > 0) { EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt--; } } } else #endif { // local node is CN -> decrement CN threshold counters if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_SOC) == 0) { // decrement loss of SoC threshold counter, because it didn't occur last cycle if (EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt > 0) { EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt--; } } if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_CN_CRC) == 0) { // decrement CRC threshold counter, because it didn't occur last cycle if (EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt > 0) { EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt--; } } } // reset error events EplErrorHandlerkInstance_g.m_ulDllErrorEvents = 0L; #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) Exit: #endif return Ret; }
tEplKernel EplPdokConfigureChannel(tEplPdoChannelConf* pChannelConf_p) { tEplKernel Ret = kEplSuccessful; tEplPdoChannel* pDestPdoChannel; if (pChannelConf_p->m_fTx == FALSE) { // RPDO #if EPL_NMT_MAX_NODE_ID > 0 tEplDllNodeOpParam NodeOpParam; NodeOpParam.m_OpNodeType = kEplDllNodeOpTypeFilterPdo; #endif if (pChannelConf_p->m_uiChannelId >= EplPdokInstance_g.m_Allocation.m_uiRxPdoChannelCount) { Ret = kEplPdoNotExist; goto Exit; } if (pChannelConf_p->m_PdoChannel.m_uiMappObjectCount > tabentries(*EplPdokInstance_g.m_paRxObject)) { Ret = kEplPdoErrorMapp; goto Exit; } pDestPdoChannel = &EplPdokInstance_g.m_pRxPdoChannel[pChannelConf_p->m_uiChannelId]; #if EPL_NMT_MAX_NODE_ID > 0 if ((pDestPdoChannel->m_uiNodeId != EPL_PDO_INVALID_NODE_ID) && (pDestPdoChannel->m_uiNodeId != EPL_PDO_PREQ_NODE_ID)) { // disable old PRes filter in DLL NodeOpParam.m_uiNodeId = pDestPdoChannel->m_uiNodeId; Ret = EplDllkDeleteNode(&NodeOpParam); if (Ret != kEplSuccessful) { goto Exit; } } #endif // EPL_NMT_MAX_NODE_ID > 0 // copy channel configuration to local structure EPL_MEMCPY(pDestPdoChannel, &pChannelConf_p->m_PdoChannel, sizeof (pChannelConf_p->m_PdoChannel)); EPL_MEMCPY(&EplPdokInstance_g.m_paRxObject[pChannelConf_p->m_uiChannelId], &pChannelConf_p->m_aMappObject[0], (pChannelConf_p->m_PdoChannel.m_uiMappObjectCount * sizeof (pChannelConf_p->m_aMappObject[0]))); #if EPL_NMT_MAX_NODE_ID > 0 if ((pDestPdoChannel->m_uiNodeId != EPL_PDO_INVALID_NODE_ID) && (pDestPdoChannel->m_uiNodeId != EPL_PDO_PREQ_NODE_ID)) { // enable new PRes filter in DLL NodeOpParam.m_uiNodeId = pDestPdoChannel->m_uiNodeId; Ret = EplDllkAddNode(&NodeOpParam); if (Ret != kEplSuccessful) { goto Exit; } } #endif // EPL_NMT_MAX_NODE_ID > 0 } else { // TPDO if (pChannelConf_p->m_uiChannelId >= EplPdokInstance_g.m_Allocation.m_uiTxPdoChannelCount) { Ret = kEplPdoNotExist; goto Exit; } if (pChannelConf_p->m_PdoChannel.m_uiMappObjectCount > tabentries(*EplPdokInstance_g.m_paTxObject)) { Ret = kEplPdoErrorMapp; goto Exit; } // copy channel configuration to local structure EPL_MEMCPY(&EplPdokInstance_g.m_pTxPdoChannel[pChannelConf_p->m_uiChannelId], &pChannelConf_p->m_PdoChannel, sizeof (pChannelConf_p->m_PdoChannel)); EPL_MEMCPY(&EplPdokInstance_g.m_paTxObject[pChannelConf_p->m_uiChannelId], &pChannelConf_p->m_aMappObject[0], (pChannelConf_p->m_PdoChannel.m_uiMappObjectCount * sizeof (pChannelConf_p->m_aMappObject[0]))); } Exit: return Ret; }