Example #1
0
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);

}
Example #2
0
INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromLe (void FAR* pAddr_p)
{

tdwStruct      dwStruct;

    dwStruct.m_dwDword  = AmiGetDwordFromLe (pAddr_p);
    dwStruct.m_dwDword &= 0x00FFFFFF;

    return ( dwStruct.m_dwDword );

}
Example #3
0
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;
}
Example #4
0
tEplKernel EplCfmuProcessNodeEvent(unsigned int uiNodeId_p, tEplNmtNodeEvent NodeEvent_p)
{
tEplKernel          Ret = kEplSuccessful;
static DWORD        dw_le_Signature;
tEplCfmuNodeInfo*   pNodeInfo = NULL;
tEplObdSize         ObdSize;
DWORD               dwExpConfTime = 0;
DWORD               dwExpConfDate = 0;
tEplIdentResponse*  pIdentResponse = NULL;
BOOL                fDoUpdate = FALSE;

    if ((NodeEvent_p != kEplNmtNodeEventCheckConf)
        && (NodeEvent_p != kEplNmtNodeEventUpdateConf))
    {
        goto Exit;
    }

    pNodeInfo = EplCfmuAllocNodeInfo(uiNodeId_p);
    if (pNodeInfo == NULL)
    {
        Ret = kEplInvalidNodeId;
        goto Exit;
    }

    pNodeInfo->m_uiCurDataSize = 0;

    // fetch pointer to ConciseDCF from object 0x1F22
    // (this allows the application to link its own memory to this object)
    pNodeInfo->m_pbDataConciseDcf = EplObduGetObjectDataPtr(0x1F22, uiNodeId_p);
    if (pNodeInfo->m_pbDataConciseDcf == NULL)
    {
        Ret = kEplCfmNoConfigData;
        goto Exit;
    }

    ObdSize = EplObduGetDataSize(0x1F22, uiNodeId_p);
    pNodeInfo->m_dwBytesRemaining = (DWORD) ObdSize;
    pNodeInfo->m_EventCnProgress.m_dwTotalNumberOfBytes = pNodeInfo->m_dwBytesRemaining;
#if (EPL_CFM_CONFIGURE_CYCLE_LENGTH != FALSE)
    pNodeInfo->m_EventCnProgress.m_dwTotalNumberOfBytes += sizeof (DWORD);
#endif
    pNodeInfo->m_EventCnProgress.m_dwBytesDownloaded = 0;
    if (ObdSize < sizeof (DWORD))
    {
        pNodeInfo->m_EventCnProgress.m_EplError = kEplCfmInvalidDcf;
        Ret = EplCfmuCallCbProgress(pNodeInfo);
        if (Ret != kEplSuccessful)
        {
            goto Exit;
        }
        Ret = pNodeInfo->m_EventCnProgress.m_EplError;
        goto Exit;
    }

    pNodeInfo->m_dwEntriesRemaining = AmiGetDwordFromLe(pNodeInfo->m_pbDataConciseDcf);

    pNodeInfo->m_pbDataConciseDcf += sizeof (DWORD);
    pNodeInfo->m_dwBytesRemaining -= sizeof (DWORD);
    pNodeInfo->m_EventCnProgress.m_dwBytesDownloaded += sizeof (DWORD);

    if (pNodeInfo->m_dwEntriesRemaining == 0)
    {
        pNodeInfo->m_EventCnProgress.m_EplError = kEplCfmNoConfigData;
        Ret = EplCfmuCallCbProgress(pNodeInfo);
        if (Ret != kEplSuccessful)
        {
            goto Exit;
        }
    }
    else
    {
        ObdSize = sizeof (dwExpConfDate);
        Ret = EplObduReadEntry(0x1F26, uiNodeId_p, &dwExpConfDate, &ObdSize);
        if (Ret != kEplSuccessful)
        {
            EPL_DBGLVL_CFM_TRACE2("CN%x Error Reading 0x1F26 returns 0x%X\n", uiNodeId_p, Ret);
        }
        ObdSize = sizeof (dwExpConfTime);
        Ret = EplObduReadEntry(0x1F27, uiNodeId_p, &dwExpConfTime, &ObdSize);
        if (Ret != kEplSuccessful)
        {
            EPL_DBGLVL_CFM_TRACE2("CN%x Error Reading 0x1F27 returns 0x%X\n", uiNodeId_p, Ret);
        }
        if ((dwExpConfDate != 0)
            || (dwExpConfTime != 0))
        {   // store configuration in CN at the end of the download,
            // because expected configuration date or time is set
            pNodeInfo->m_fDoStore = TRUE;
            pNodeInfo->m_EventCnProgress.m_dwTotalNumberOfBytes += sizeof (DWORD);
        }
        else
        {   // expected configuration date and time is not set
            fDoUpdate = TRUE;
        }
        EplIdentuGetIdentResponse(uiNodeId_p, &pIdentResponse);
        if (pIdentResponse == NULL)
        {
            EPL_DBGLVL_CFM_TRACE1("CN%x Ident Response is NULL\n", uiNodeId_p);
            Ret = kEplInvalidNodeId;
            goto Exit;
        }
    }

#if (EPL_CFM_CONFIGURE_CYCLE_LENGTH != FALSE)
    ObdSize = sizeof (EplCfmuInstance_g.m_le_dwCycleLength);
    Ret = EplObduReadEntryToLe(0x1006, 0x00, &EplCfmuInstance_g.m_le_dwCycleLength, &ObdSize);
    if (Ret != kEplSuccessful)
    {   // local OD access failed
        EPL_DBGLVL_CFM_TRACE1("Local OBD read failed %d\n", Ret);
        goto Exit;
    }
#endif

    if ((pNodeInfo->m_dwEntriesRemaining == 0)
        || ((NodeEvent_p != kEplNmtNodeEventUpdateConf)
            && (fDoUpdate == FALSE)
            && ((AmiGetDwordFromLe(&pIdentResponse->m_le_dwVerifyConfigurationDate) == dwExpConfDate)
                && (AmiGetDwordFromLe(&pIdentResponse->m_le_dwVerifyConfigurationTime) == dwExpConfTime))))
    {
        pNodeInfo->m_CfmState = kEplCfmuStateIdle;

        // current version is already available on the CN, no need to write new values, we can continue
        EPL_DBGLVL_CFM_TRACE1("CN%x - Cfg Upto Date\n", uiNodeId_p);

        Ret = EplCfmuDownloadCycleLength(pNodeInfo);
        if (Ret == kEplReject)
        {
            pNodeInfo->m_CfmState = kEplCfmuStateUpToDate;
        }
    }
    else if (NodeEvent_p == kEplNmtNodeEventUpdateConf)
    {
        pNodeInfo->m_CfmState = kEplCfmuStateDownload;

        Ret = EplCfmuDownloadObject(pNodeInfo);
        if (Ret == kEplSuccessful)
        {   // SDO transfer started
            Ret = kEplReject;
        }
    }
    else
    {
        pNodeInfo->m_CfmState = kEplCfmuStateWaitRestore;

        pNodeInfo->m_EventCnProgress.m_dwTotalNumberOfBytes += sizeof (dw_le_Signature);
        AmiSetDwordToLe(&dw_le_Signature, 0x64616F6C);
        //Restore Default Parameters
        EPL_DBGLVL_CFM_TRACE3("CN%x - Cfg Mismatch | MN Expects: %lx-%lx ", uiNodeId_p, dwExpConfDate, dwExpConfTime);
        EPL_DBGLVL_CFM_TRACE2("CN Has: %lx-%lx. Restoring Default...\n", AmiGetDwordFromLe(&pIdentResponse->m_le_dwVerifyConfigurationDate), AmiGetDwordFromLe(&pIdentResponse->m_le_dwVerifyConfigurationTime));

        pNodeInfo->m_EventCnProgress.m_uiObjectIndex = 0x1011;
        pNodeInfo->m_EventCnProgress.m_uiObjectSubIndex = 0x01;
        Ret = EplCfmuSdoWriteObject(pNodeInfo, &dw_le_Signature, sizeof (dw_le_Signature));
        if (Ret == kEplSuccessful)
        {   // SDO transfer started
            Ret = kEplReject;
        }
        else
        {
            // error occured
            EPL_DBGLVL_CFM_TRACE1("CfmCbEvent(Node): EplCfmuSdoWriteObject() returned 0x%02X\n", Ret);
        }
    }

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;
}