INLINE_FUNCTION void PUBLIC AmiGetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p) { pTimeOfDay_p->m_dwMs = AmiGetDwordFromLe (((BYTE FAR*) pAddr_p)) & 0x0FFFFFFF; pTimeOfDay_p->m_wDays = AmiGetWordFromLe (((BYTE FAR*) pAddr_p) + 4); }
static tEplKernel EplPdokCalCbProcessRpdo(tEplFrameInfo * pFrameInfo_p) { tEplKernel Ret = kEplSuccessful; tEplEvent Event; Event.m_EventSink = kEplEventSinkPdokCal; Event.m_EventType = kEplEventTypePdoRx; // limit copied data to size of PDO (because from some CNs the frame is larger than necessary) Event.m_uiSize = AmiGetWordFromLe(&pFrameInfo_p->m_pFrame->m_Data.m_Pres.m_le_wSize) + EPL_FRAME_OFFSET_PDO_PAYLOAD; // pFrameInfo_p->m_uiFrameSize; Event.m_pArg = pFrameInfo_p->m_pFrame; Ret = EplEventkPost(&Event); return Ret; }
static tEplKernel EplCfmuDownloadObject( tEplCfmuNodeInfo* pNodeInfo_p) { tEplKernel Ret = kEplSuccessful; static DWORD dw_le_Signature; // forward data pointer for last transfer pNodeInfo_p->m_pbDataConciseDcf += pNodeInfo_p->m_uiCurDataSize; pNodeInfo_p->m_dwBytesRemaining -= pNodeInfo_p->m_uiCurDataSize; if (pNodeInfo_p->m_dwEntriesRemaining > 0) { if (pNodeInfo_p->m_dwBytesRemaining < EPL_CDC_OFFSET_DATA) { // not enough bytes left in ConciseDCF pNodeInfo_p->m_EventCnProgress.m_EplError = kEplCfmInvalidDcf; Ret = EplCfmuCallCbProgress(pNodeInfo_p); if (Ret != kEplSuccessful) { goto Exit; } Ret = EplCfmuFinishConfig(pNodeInfo_p, kEplNmtNodeCommandConfErr); goto Exit; } // fetch next item from ConciseDCF pNodeInfo_p->m_EventCnProgress.m_uiObjectIndex = AmiGetWordFromLe(&pNodeInfo_p->m_pbDataConciseDcf[EPL_CDC_OFFSET_INDEX]); pNodeInfo_p->m_EventCnProgress.m_uiObjectSubIndex = AmiGetByteFromLe(&pNodeInfo_p->m_pbDataConciseDcf[EPL_CDC_OFFSET_SUBINDEX]); pNodeInfo_p->m_uiCurDataSize = (unsigned int) AmiGetDwordFromLe(&pNodeInfo_p->m_pbDataConciseDcf[EPL_CDC_OFFSET_SIZE]); pNodeInfo_p->m_pbDataConciseDcf += EPL_CDC_OFFSET_DATA; pNodeInfo_p->m_dwBytesRemaining -= EPL_CDC_OFFSET_DATA; pNodeInfo_p->m_EventCnProgress.m_dwBytesDownloaded += EPL_CDC_OFFSET_DATA; if ((pNodeInfo_p->m_dwBytesRemaining < pNodeInfo_p->m_uiCurDataSize) || (pNodeInfo_p->m_uiCurDataSize == 0)) { // not enough bytes left in ConciseDCF pNodeInfo_p->m_EventCnProgress.m_EplError = kEplCfmInvalidDcf; Ret = EplCfmuCallCbProgress(pNodeInfo_p); if (Ret != kEplSuccessful) { goto Exit; } Ret = EplCfmuFinishConfig(pNodeInfo_p, kEplNmtNodeCommandConfErr); goto Exit; } pNodeInfo_p->m_dwEntriesRemaining--; Ret = EplCfmuSdoWriteObject(pNodeInfo_p, pNodeInfo_p->m_pbDataConciseDcf, pNodeInfo_p->m_uiCurDataSize); if (Ret != kEplSuccessful) { goto Exit; } } else { // download finished if (pNodeInfo_p->m_fDoStore != FALSE) { // store configuration into non-volatile memory pNodeInfo_p->m_CfmState = kEplCfmuStateWaitStore; AmiSetDwordToLe(&dw_le_Signature, 0x65766173); pNodeInfo_p->m_EventCnProgress.m_uiObjectIndex = 0x1010; pNodeInfo_p->m_EventCnProgress.m_uiObjectSubIndex = 0x01; Ret = EplCfmuSdoWriteObject(pNodeInfo_p, &dw_le_Signature, sizeof (dw_le_Signature)); if (Ret != kEplSuccessful) { goto Exit; } } else { Ret = EplCfmuDownloadCycleLength(pNodeInfo_p); if (Ret == kEplReject) { pNodeInfo_p->m_CfmState = kEplCfmuStateUpToDate; Ret = kEplSuccessful; } else { Ret = EplCfmuFinishConfig(pNodeInfo_p, kEplNmtNodeCommandConfReset); } } } Exit: return Ret; }
static tEplKernel EplObdCdcProcess(tEplObdCdcInfo* pCdcInfo_p) { tEplKernel Ret = kEplSuccessful; DWORD dwEntriesRemaining; unsigned int uiObjectIndex; unsigned int uiObjectSubIndex; size_t iCurDataSize; Ret = EplObdCdcLoadNextBuffer(pCdcInfo_p, sizeof (DWORD)); if (Ret != kEplSuccessful) { goto Exit; } dwEntriesRemaining = AmiGetDwordFromLe(pCdcInfo_p->m_pbCurBuffer); if (dwEntriesRemaining == 0) { Ret = EplEventuPostError(kEplEventSourceObdu, kEplObdNoConfigData, 0, NULL); goto Exit; } for ( ; dwEntriesRemaining != 0; dwEntriesRemaining--) { Ret = EplObdCdcLoadNextBuffer(pCdcInfo_p, EPL_CDC_OFFSET_DATA); if (Ret != kEplSuccessful) { goto Exit; } uiObjectIndex = AmiGetWordFromLe(&pCdcInfo_p->m_pbCurBuffer[EPL_CDC_OFFSET_INDEX]); uiObjectSubIndex = AmiGetByteFromLe(&pCdcInfo_p->m_pbCurBuffer[EPL_CDC_OFFSET_SUBINDEX]); iCurDataSize = (size_t) AmiGetDwordFromLe(&pCdcInfo_p->m_pbCurBuffer[EPL_CDC_OFFSET_SIZE]); EPL_DBGLVL_OBD_TRACE("%s: Reading object 0x%04X/%u with size %u from CDC\n", __func__, uiObjectIndex, uiObjectSubIndex, iCurDataSize); Ret = EplObdCdcLoadNextBuffer(pCdcInfo_p, iCurDataSize); if (Ret != kEplSuccessful) { EPL_DBGLVL_OBD_TRACE("%s: Reading the corresponding data from CDC failed with 0x%02X\n", __func__, Ret); goto Exit; } Ret = EplObdWriteEntryFromLe(uiObjectIndex, uiObjectSubIndex, pCdcInfo_p->m_pbCurBuffer, (tEplObdSize) iCurDataSize); if (Ret != kEplSuccessful) { tEplEventObdError ObdError; ObdError.m_uiIndex = uiObjectIndex; ObdError.m_uiSubIndex = uiObjectSubIndex; EPL_DBGLVL_OBD_TRACE("%s: Writing object 0x%04X/%u to local OBD failed with 0x%02X\n", __func__, uiObjectIndex, uiObjectSubIndex, Ret); Ret = EplEventuPostError(kEplEventSourceObdu, Ret, sizeof (ObdError), &ObdError); if (Ret != kEplSuccessful) { goto Exit; } } } Exit: return Ret; }