Ejemplo n.º 1
0
tEplKernel PUBLIC EplEventkPostError(tEplEventSource EventSource_p,
                                     tEplKernel      EplError_p,
                                     unsigned int    uiArgSize_p,
                                     void*           pArg_p)
{
tEplKernel      Ret;
tEplEventError  EventError;
tEplEvent       EplEvent;

    Ret = kEplSuccessful;

    // create argument
    EventError.m_EventSource = EventSource_p;
    EventError.m_EplError = EplError_p;
    uiArgSize_p = (unsigned int) min ((size_t) uiArgSize_p, sizeof (EventError.m_Arg));
    EPL_MEMCPY(&EventError.m_Arg, pArg_p, uiArgSize_p);

    // create event
    EplEvent.m_EventType = kEplEventTypeError;
    EplEvent.m_EventSink = kEplEventSinkApi;
    EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime));
    EplEvent.m_uiSize = (memberoffs (tEplEventError, m_Arg) + uiArgSize_p);
    EplEvent.m_pArg = &EventError;

    // post errorevent
    Ret = EplEventkPost(&EplEvent);

    return Ret;
}
Ejemplo n.º 2
0
tEplKernel PUBLIC EplEventkPostError(tEplEventSource EventSource_p,
                                     tEplKernel      EplError_p,
                                     unsigned int    uiArgSize_p,
                                     void*           pArg_p)
{
tEplKernel  Ret;
BYTE        abBuffer[EPL_MAX_EVENT_ARG_SIZE];
tEplEventError* pEventError = (tEplEventError*) abBuffer;
tEplEvent   EplEvent;

    Ret = kEplSuccessful;

    // create argument
    pEventError->m_EventSource = EventSource_p;
    pEventError->m_EplError = EplError_p;
    EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p);

    // create event
    EplEvent.m_EventType = kEplEventTypeError;
    EplEvent.m_EventSink = kEplEventSinkApi;
    EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime));
    EplEvent.m_uiSize = (sizeof(EventSource_p)+ sizeof(EplError_p)+ uiArgSize_p);
    EplEvent.m_pArg = &abBuffer[0];

    // post errorevent
    Ret = EplEventkPost(&EplEvent);

    return Ret;
}
Ejemplo n.º 3
0
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;
}
//---------------------------------------------------------------------------
//
// Function:    EplErrorHandlerkPostHistoryEntry
//
// Description: posts history entry events to API layer
//
// Parameters:  pHistoryEntry_p     = pointer to history entry structure
//
// Returns:     tEpKernel  = errorcode
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplErrorHandlerkPostHistoryEntry(tEplErrHistoryEntry* pHistoryEntry_p)
{
tEplKernel              Ret;
tEplEvent               Event;

    Event.m_EventSink = kEplEventSinkApi;
    Event.m_EventType = kEplEventTypeHistoryEntry;
    Event.m_uiSize = sizeof (*pHistoryEntry_p);
    Event.m_pArg = pHistoryEntry_p;
    Ret = EplEventkPost(&Event);

    return Ret;

}
//---------------------------------------------------------------------------
//
// Function:    EplErrorHandlerkPostError
//
// Description: posts error events to error handler (called by DLL)
//
// Parameters:  pDllEvent_p = pointer to event-structure
//
// Returns:     tEpKernel  = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplErrorHandlerkPostError(tEplErrorHandlerkEvent* pDllEvent_p)
{
tEplKernel              Ret;
tEplEvent               Event;

    Event.m_EventSink = kEplEventSinkErrk;
    Event.m_EventType = kEplEventTypeDllError;
    Event.m_uiSize = sizeof (*pDllEvent_p);
    Event.m_pArg = pDllEvent_p;
    Ret = EplEventkPost(&Event);

    return Ret;

}
Ejemplo n.º 6
0
tEplKernel EplDllkCalAsyncFrameReceived(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel  Ret = kEplSuccessful;
tEplEvent   Event;

    Event.m_EventSink = kEplEventSinkDlluCal;
    Event.m_EventType = kEplEventTypeAsndRx;
    Event.m_pArg = pFrameInfo_p->m_pFrame;
    Event.m_uiSize = pFrameInfo_p->m_uiFrameSize;

    Ret = EplEventkPost(&Event);
    if (Ret != kEplSuccessful)
    {
        EplDllkCalInstance_g.m_Statistics.m_ulCurRxFrameCount++;
    }
    else
    {
        EplDllkCalInstance_g.m_Statistics.m_ulMaxRxFrameCount++;
    }

    return Ret;
}
Ejemplo n.º 7
0
tEplKernel EplDllkCalAsyncSend(tEplFrameInfo * pFrameInfo_p, tEplDllAsyncReqPriority Priority_p)
{
tEplKernel  Ret = kEplSuccessful;
tEplEvent       Event;
#if EPL_USE_SHAREDBUFF != FALSE
tShbError   ShbError;

    switch (Priority_p)
    {
        case kEplDllAsyncReqPrioNmt:    // NMT request priority
            ShbError = ShbCirWriteDataBlock (EplDllkCalInstance_g.m_ShbInstanceTxNmt, pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
            // returns kShbOk, kShbExceedDataSizeLimit, kShbBufferFull, kShbInvalidArg
            break;

        default:    // generic priority
            ShbError = ShbCirWriteDataBlock (EplDllkCalInstance_g.m_ShbInstanceTxGen, pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
            // returns kShbOk, kShbExceedDataSizeLimit, kShbBufferFull, kShbInvalidArg
            break;

    }

    // error handling
    switch (ShbError)
    {
        case kShbOk:
            break;

        case kShbExceedDataSizeLimit:
            Ret = kEplDllAsyncTxBufferFull;
            break;

        case kShbBufferFull:
            Ret = kEplDllAsyncTxBufferFull;
            break;

        case kShbInvalidArg:
        default:
            Ret = kEplNoResource;
            break;
    }

#else

    switch (Priority_p)
    {
        case kEplDllAsyncReqPrioNmt:    // NMT request priority
            if (EplDllkCalInstance_g.m_uiFrameSizeNmt == 0)
            {
                EPL_MEMCPY(EplDllkCalInstance_g.m_abFrameNmt, pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
                EplDllkCalInstance_g.m_uiFrameSizeNmt = pFrameInfo_p->m_uiFrameSize;
            }
            else
            {
                Ret = kEplDllAsyncTxBufferFull;
                goto Exit;
            }
            break;

        default:    // generic priority
            if (EplDllkCalInstance_g.m_uiFrameSizeGen == 0)
            {
                EPL_MEMCPY(EplDllkCalInstance_g.m_abFrameGen, pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
                EplDllkCalInstance_g.m_uiFrameSizeGen = pFrameInfo_p->m_uiFrameSize;
            }
            else
            {
                Ret = kEplDllAsyncTxBufferFull;
                goto Exit;
            }
            break;
    }

#endif

    // post event to DLL
    Event.m_EventSink = kEplEventSinkDllk;
    Event.m_EventType = kEplEventTypeDllkFillTx;
    EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime));
    Event.m_pArg = &Priority_p;
    Event.m_uiSize = sizeof(Priority_p);
    Ret = EplEventkPost(&Event);

#if EPL_USE_SHAREDBUFF == FALSE
Exit:
#endif

    return Ret;
}
Ejemplo n.º 8
0
//---------------------------------------------------------------------------
//
// Function:        EplNmtkProcess
//
// Description: main process function
//              -> process NMT-State-Maschine und read NMT-Events from Queue
//
//
//
// Parameters:  EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instance pointer
//              pEvent_p    =   Epl-Event with NMT-event to process
//
//
// Returns:     tEplKernel  =   Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtkProcess(EPL_MCO_DECL_PTR_INSTANCE_PTR_
					      tEplEvent * pEvent_p)
{
	tEplKernel Ret;
	tEplNmtState OldNmtState;
	tEplNmtEvent NmtEvent;
	tEplEvent Event;
	tEplEventNmtStateChange NmtStateChange;

	// check for all API function if instance is valid
	EPL_MCO_CHECK_INSTANCE_STATE();

	Ret = kEplSuccessful;

	switch (pEvent_p->m_EventType) {
	case kEplEventTypeNmtEvent:
		{
			NmtEvent = *((tEplNmtEvent *) pEvent_p->m_pArg);
			break;
		}

	case kEplEventTypeTimer:
		{
			NmtEvent =
			    (tEplNmtEvent) ((tEplTimerEventArg *) pEvent_p->
					    m_pArg)->m_ulArg;
			break;
		}
	default:
		{
			Ret = kEplNmtInvalidEvent;
			goto Exit;
		}
	}

	// save NMT-State
	// needed for later comparison to
	// inform hgher layer about state change
	OldNmtState = EPL_MCO_GLB_VAR(m_NmtState);

	// NMT-State-Maschine
	switch (EPL_MCO_GLB_VAR(m_NmtState)) {
		//-----------------------------------------------------------
		// general part of the statemaschine

		// first init of the hardware
	case kEplNmtGsOff:
		{
			// leave this state only if higher layer says so
			if (NmtEvent == kEplNmtEventSwReset) {	// new state kEplNmtGsInitialising
				EPL_MCO_GLB_VAR(m_NmtState) =
				    kEplNmtGsInitialising;
			}
			break;
		}

		// first init of the hardware
	case kEplNmtGsInitialising:
		{
			// leave this state only if higher layer says so

			// check events
			switch (NmtEvent) {
				// 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// new state kEplNmtGsResetApplication
			case kEplNmtEventEnterResetApp:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

			default:
				{
					break;
				}
			}
			break;
		}

		// init of the manufacturer-specific profile area and the
		// standardised device profile area
	case kEplNmtGsResetApplication:
		{
			// check events
			switch (NmtEvent) {
				// 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// leave this state only if higher layer
				// say so
			case kEplNmtEventEnterResetCom:
				{
					// new state kEplNmtGsResetCommunication
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

			default:
				{
					break;
				}
			}
			break;
		}

		// init of the communication profile area
	case kEplNmtGsResetCommunication:
		{
			// check events
			switch (NmtEvent) {
				// 2006/07/31 d.k.: react also on NMT reset commands in ResetComm state
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// leave this state only if higher layer
				// say so
			case kEplNmtEventEnterResetConfig:
				{
					// new state kEplNmtGsResetCommunication
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

			default:
				{
					break;
				}
			}
			break;
		}

		// build the configuration with infos from OD
	case kEplNmtGsResetConfiguration:
		{
			// reset flags
			EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE;
			EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE;
			EPL_MCO_GLB_VAR(m_fFrozen) = FALSE;

			// check events
			switch (NmtEvent) {
				// 2006/07/31 d.k.: react also on NMT reset commands in ResetConf state
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
			case kEplNmtEventResetCom:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// leave this state only if higher layer says so
			case kEplNmtEventEnterCsNotActive:
				{	// Node should be CN
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsNotActive;
					break;

				}

			case kEplNmtEventEnterMsNotActive:
				{	// Node should be CN
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
					// no MN functionality
					// TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
					EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
#else

					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtMsNotActive;
#endif
					break;

				}

			default:
				{
					break;
				}
			}
			break;
		}

		//-----------------------------------------------------------
		// CN part of the statemaschine

		// node liste for EPL-Frames and check timeout
	case kEplNmtCsNotActive:
		{

			// check events
			switch (NmtEvent) {
				// 2006/07/31 d.k.: react also on NMT reset commands in NotActive state
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
//                    Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
//                    Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
//                    Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
					break;
				}

				// NMT Command Reset Configuration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
//                    Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
					break;
				}

				// see if SoA or SoC received
				// k.t. 20.07.2006: only SoA forces change of state
				// see EPL V2 DS 1.0.0 p.267
				// case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCeSoa:
				{	// new state PRE_OPERATIONAL1
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational1;
//                    Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
					break;
				}
				// timeout for SoA and Soc
			case kEplNmtEventTimerBasicEthernet:
				{
					// new state BASIC_ETHERNET
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsBasicEthernet;
					break;
				}

			default:
				{
					break;
				}
			}	// end of switch(NmtEvent)

			break;
		}

		// node processes only async frames
	case kEplNmtCsPreOperational1:
		{

			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command Reset Configuration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// NMT Command StopNode
			case kEplNmtEventStopNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsStopped;
					break;
				}

				// check if SoC received
			case kEplNmtEventDllCeSoc:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational2;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)

			break;
		}

		// node processes isochronous and asynchronous frames
	case kEplNmtCsPreOperational2:
		{
			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command Reset Configuration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// NMT Command StopNode
			case kEplNmtEventStopNode:
				{
					// reset flags
					EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
					    = FALSE;
					EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
					    FALSE;
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsStopped;
					break;
				}

				// error occured
			case kEplNmtEventNmtCycleError:
				{
					// reset flags
					EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
					    = FALSE;
					EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
					    FALSE;
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational1;
					break;
				}

				// check if application is ready to operate
			case kEplNmtEventEnterReadyToOperate:
				{
					// check if command NMTEnableReadyToOperate from MN was received
					if (EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) == TRUE) {	// reset flags
						EPL_MCO_GLB_VAR
						    (m_fEnableReadyToOperate) =
						    FALSE;
						EPL_MCO_GLB_VAR
						    (m_fAppReadyToOperate) =
						    FALSE;
						// change state
						EPL_MCO_GLB_VAR(m_NmtState) =
						    kEplNmtCsReadyToOperate;
					} else {	// set Flag
						EPL_MCO_GLB_VAR
						    (m_fAppReadyToOperate) =
						    TRUE;
					}
					break;
				}

				// NMT Commando EnableReadyToOperate
			case kEplNmtEventEnableReadyToOperate:
				{
					// check if application is ready
					if (EPL_MCO_GLB_VAR(m_fAppReadyToOperate) == TRUE) {	// reset flags
						EPL_MCO_GLB_VAR
						    (m_fEnableReadyToOperate) =
						    FALSE;
						EPL_MCO_GLB_VAR
						    (m_fAppReadyToOperate) =
						    FALSE;
						// change state
						EPL_MCO_GLB_VAR(m_NmtState) =
						    kEplNmtCsReadyToOperate;
					} else {	// set Flag
						EPL_MCO_GLB_VAR
						    (m_fEnableReadyToOperate) =
						    TRUE;
					}
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)
			break;
		}

		// node should be configured und application is ready
	case kEplNmtCsReadyToOperate:
		{
			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// NMT Command StopNode
			case kEplNmtEventStopNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsStopped;
					break;
				}

				// error occured
			case kEplNmtEventNmtCycleError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational1;
					break;
				}

				// NMT Command StartNode
			case kEplNmtEventStartNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsOperational;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)
			break;
		}

		// normal work state
	case kEplNmtCsOperational:
		{

			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// NMT Command StopNode
			case kEplNmtEventStopNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsStopped;
					break;
				}

				// NMT Command EnterPreOperational2
			case kEplNmtEventEnterPreOperational2:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational2;
					break;
				}

				// error occured
			case kEplNmtEventNmtCycleError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational1;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)
			break;
		}

		// node stopped by MN
		// -> only process asynchronous frames
	case kEplNmtCsStopped:
		{
			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// NMT Command EnterPreOperational2
			case kEplNmtEventEnterPreOperational2:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational2;
					break;
				}

				// error occured
			case kEplNmtEventNmtCycleError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational1;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)
			break;
		}

		// no epl cycle
		// -> normal ethernet communication
	case kEplNmtCsBasicEthernet:
		{
			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// error occured
				// d.k.: how does this error occur? on CRC errors
/*                case kEplNmtEventNmtCycleError:
                {
                    EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
                    break;
                }
*/
			case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCePreq:
			case kEplNmtEventDllCePres:
			case kEplNmtEventDllCeSoa:
				{	// Epl-Frame on net -> stop any communication
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtCsPreOperational1;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)

			break;
		}

		//-----------------------------------------------------------
		// MN part of the statemaschine

		// MN listen to network
		// -> if no EPL traffic go to next state
	case kEplNmtMsNotActive:
		{
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
			// no MN functionality
			// TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
			EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
#else

			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// EPL frames received
			case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCeSoa:
				{	// other MN in network
					// $$$ d.k.: generate error history entry
					EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
					break;
				}

				// timeout event
			case kEplNmtEventTimerBasicEthernet:
				{
					if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) {	// new state BasicEthernet
						EPL_MCO_GLB_VAR(m_NmtState) =
						    kEplNmtMsBasicEthernet;
					}
					break;
				}

				// timeout event
			case kEplNmtEventTimerMsPreOp1:
				{
					if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) {	// new state PreOp1
						EPL_MCO_GLB_VAR(m_NmtState) =
						    kEplNmtMsPreOperational1;
						EPL_MCO_GLB_VAR
						    (m_fTimerMsPreOp2) = FALSE;
						EPL_MCO_GLB_VAR
						    (m_fAllMandatoryCNIdent) =
						    FALSE;

					}
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)

#endif // ((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)

			break;
		}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
		// MN process reduces epl cycle
	case kEplNmtMsPreOperational1:
		{
			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// EPL frames received
			case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCeSoa:
				{	// other MN in network
					// $$$ d.k.: generate error history entry
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// error occured
				// d.k. MSPreOp1->CSPreOp1: nonsense -> keep state
				/*
				   case kEplNmtEventNmtCycleError:
				   {
				   EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
				   break;
				   }
				 */

			case kEplNmtEventAllMandatoryCNIdent:
				{	// all mandatory CN identified
					if (EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) !=
					    FALSE) {
						EPL_MCO_GLB_VAR(m_NmtState) =
						    kEplNmtMsPreOperational2;
					} else {
						EPL_MCO_GLB_VAR
						    (m_fAllMandatoryCNIdent) =
						    TRUE;
					}
					break;
				}

			case kEplNmtEventTimerMsPreOp2:
				{	// residence time for PreOp1 is elapsed
					if (EPL_MCO_GLB_VAR
					    (m_fAllMandatoryCNIdent) != FALSE) {
						EPL_MCO_GLB_VAR(m_NmtState) =
						    kEplNmtMsPreOperational2;
					} else {
						EPL_MCO_GLB_VAR
						    (m_fTimerMsPreOp2) = TRUE;
					}
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)
			break;
		}

		// MN process full epl cycle
	case kEplNmtMsPreOperational2:
		{
			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// EPL frames received
			case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCeSoa:
				{	// other MN in network
					// $$$ d.k.: generate error history entry
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// error occured
			case kEplNmtEventNmtCycleError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtMsPreOperational1;
					break;
				}

			case kEplNmtEventEnterReadyToOperate:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtMsReadyToOperate;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)

			break;
		}

		// all madatory nodes ready to operate
		// -> MN process full epl cycle
	case kEplNmtMsReadyToOperate:
		{

			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// EPL frames received
			case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCeSoa:
				{	// other MN in network
					// $$$ d.k.: generate error history entry
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// error occured
			case kEplNmtEventNmtCycleError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtMsPreOperational1;
					break;
				}

			case kEplNmtEventEnterMsOperational:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtMsOperational;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)

			break;
		}

		// normal eplcycle processing
	case kEplNmtMsOperational:
		{
			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// EPL frames received
			case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCeSoa:
				{	// other MN in network
					// $$$ d.k.: generate error history entry
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// error occured
			case kEplNmtEventNmtCycleError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtMsPreOperational1;
					break;
				}

			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)
			break;
		}

		//  normal ethernet traffic
	case kEplNmtMsBasicEthernet:
		{

			// check events
			switch (NmtEvent) {
				// NMT Command SwitchOff
			case kEplNmtEventCriticalError:
			case kEplNmtEventSwitchOff:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsOff;
					break;
				}

				// NMT Command SwReset
			case kEplNmtEventSwReset:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsInitialising;
					break;
				}

				// NMT Command ResetNode
			case kEplNmtEventResetNode:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetApplication;
					break;
				}

				// NMT Command ResetCommunication
				// or internal Communication error
			case kEplNmtEventResetCom:
			case kEplNmtEventInternComError:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// NMT Command ResetConfiguration
			case kEplNmtEventResetConfig:
				{
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetConfiguration;
					break;
				}

				// EPL frames received
			case kEplNmtEventDllCeSoc:
			case kEplNmtEventDllCeSoa:
				{	// other MN in network
					// $$$ d.k.: generate error history entry
					EPL_MCO_GLB_VAR(m_NmtState) =
					    kEplNmtGsResetCommunication;
					break;
				}

				// error occured
				// d.k. BE->PreOp1 on cycle error? No
/*                case kEplNmtEventNmtCycleError:
                {
                    EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
                    break;
                }
*/
			default:
				{
					break;
				}

			}	// end of switch(NmtEvent)
			break;
		}
#endif //#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)

	default:
		{
			//DEBUG_EPL_DBGLVL_NMTK_TRACE0(EPL_DBGLVL_NMT ,"Error in EplNmtProcess: Unknown NMT-State");
			//EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication;
			Ret = kEplNmtInvalidState;
			goto Exit;
		}

	}			// end of switch(NmtEvent)

	// inform higher layer about State-Change if needed
	if (OldNmtState != EPL_MCO_GLB_VAR(m_NmtState)) {
		EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent, OldNmtState,
					      EPL_MCO_GLB_VAR(m_NmtState));

		// d.k.: memorize NMT state before posting any events
		NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState);

		// inform DLL
		if ((OldNmtState > kEplNmtGsResetConfiguration)
		    && (EPL_MCO_GLB_VAR(m_NmtState) <=
			kEplNmtGsResetConfiguration)) {
			// send DLL DEINIT
			Event.m_EventSink = kEplEventSinkDllk;
			Event.m_EventType = kEplEventTypeDllkDestroy;
			EPL_MEMSET(&Event.m_NetTime, 0x00,
				   sizeof(Event.m_NetTime));
			Event.m_pArg = &OldNmtState;
			Event.m_uiSize = sizeof(OldNmtState);
			// d.k.: directly call DLLk process function, because
			//       1. execution of process function is still synchonized and serialized,
			//       2. it is the same as without event queues (i.e. well tested),
			//       3. DLLk will get those necessary events even if event queue is full,
			//       4. event queue is very inefficient
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
			Ret = EplDllkProcess(&Event);
#else
			Ret = EplEventkPost(&Event);
#endif
		} else if ((OldNmtState <= kEplNmtGsResetConfiguration)
			   && (EPL_MCO_GLB_VAR(m_NmtState) >
			       kEplNmtGsResetConfiguration)) {
			// send DLL INIT
			Event.m_EventSink = kEplEventSinkDllk;
			Event.m_EventType = kEplEventTypeDllkCreate;
			EPL_MEMSET(&Event.m_NetTime, 0x00,
				   sizeof(Event.m_NetTime));
			Event.m_pArg = &NmtStateChange.m_NewNmtState;
			Event.m_uiSize = sizeof(NmtStateChange.m_NewNmtState);
			// d.k.: directly call DLLk process function, because
			//       1. execution of process function is still synchonized and serialized,
			//       2. it is the same as without event queues (i.e. well tested),
			//       3. DLLk will get those necessary events even if event queue is full
			//       4. event queue is very inefficient
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
			Ret = EplDllkProcess(&Event);
#else
			Ret = EplEventkPost(&Event);
#endif
		} else
		    if ((EPL_MCO_GLB_VAR(m_NmtState) == kEplNmtCsBasicEthernet)
			|| (EPL_MCO_GLB_VAR(m_NmtState) ==
			    kEplNmtMsBasicEthernet)) {
			tEplDllAsyncReqPriority AsyncReqPriority;

			// send DLL Fill Async Tx Buffer, because state BasicEthernet was entered
			Event.m_EventSink = kEplEventSinkDllk;
			Event.m_EventType = kEplEventTypeDllkFillTx;
			EPL_MEMSET(&Event.m_NetTime, 0x00,
				   sizeof(Event.m_NetTime));
			AsyncReqPriority = kEplDllAsyncReqPrioGeneric;
			Event.m_pArg = &AsyncReqPriority;
			Event.m_uiSize = sizeof(AsyncReqPriority);
			// d.k.: directly call DLLk process function, because
			//       1. execution of process function is still synchonized and serialized,
			//       2. it is the same as without event queues (i.e. well tested),
			//       3. DLLk will get those necessary events even if event queue is full
			//       4. event queue is very inefficient
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
			Ret = EplDllkProcess(&Event);
#else
			Ret = EplEventkPost(&Event);
#endif
		}
		// inform higher layer about state change
		NmtStateChange.m_NmtEvent = NmtEvent;
		Event.m_EventSink = kEplEventSinkNmtu;
		Event.m_EventType = kEplEventTypeNmtStateChange;
		EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime));
		Event.m_pArg = &NmtStateChange;
		Event.m_uiSize = sizeof(NmtStateChange);
		Ret = EplEventkPost(&Event);
		EPL_DBGLVL_NMTK_TRACE2
		    ("EplNmtkProcess(NMT-Event = 0x%04X): New NMT-State = 0x%03X\n",
		     NmtEvent, NmtStateChange.m_NewNmtState);

	}

      Exit:

	return Ret;
}
//---------------------------------------------------------------------------
//
// Function:    EplErrorHandlerkProcess
//
// Description: processes error events from DLL
//
// Parameters:  pEvent_p = pointer to event-structure from buffer
//
// Returns:     tEpKernel  = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplErrorHandlerkProcess(tEplEvent* pEvent_p)
{
tEplKernel              Ret;
unsigned long           ulDllErrorEvents;
tEplEvent               Event;
tEplNmtEvent            NmtEvent;

    Ret = kEplSuccessful;


    // check m_EventType
    switch(pEvent_p->m_EventType)
    {
        case kEplEventTypeDllError:
        {
        tEplErrorHandlerkEvent* pErrHandlerEvent = (tEplErrorHandlerkEvent*)pEvent_p->m_pArg;
        tEplErrHistoryEntry     HistoryEntry = {0};

            ulDllErrorEvents = pErrHandlerEvent->m_ulDllErrorEvents;

            HistoryEntry.m_wEntryType = EPL_ERR_ENTRYTYPE_MODE_OCCURRED | EPL_ERR_ENTRYTYPE_PROF_EPL | EPL_ERR_ENTRYTYPE_HISTORY;

            // check the several error events
            if ((ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_SOC) != 0)
            {   // loss of SoC event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThreshold)
                    {   // threshold is reached
                        // generate error history entry E_DLL_LOSS_SOC_TH
                        HistoryEntry.m_wErrorCode = EPL_E_DLL_LOSS_SOC_TH;
                        HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                        Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                        if (Ret != kEplSuccessful)
                        {
                            goto Exit;
                        }

                        BENCHMARK_MOD_02_TOGGLE(7);

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_CN_LOSS_SOC;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_PREQ) != 0)
            {   // loss of PReq event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThreshold)
                    {   // threshold is reached
                        // generate error history entry E_DLL_LOSS_PREQ_TH
                        HistoryEntry.m_wErrorCode = EPL_E_DLL_LOSS_PREQ_TH;
                        HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                        Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                        if (Ret != kEplSuccessful)
                        {
                            goto Exit;
                        }

                        BENCHMARK_MOD_02_TOGGLE(7);

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                }
            }

            if ((EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt > 0)
                && ((ulDllErrorEvents & EPL_DLL_ERR_CN_RECVD_PREQ) != 0))
            {   // PReq correctly received
                // decrement threshold counter by 1
                EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt--;
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_CN_CRC) != 0)
            {   // CRC error event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThreshold)
                    {   // threshold is reached
                        // generate error history entry E_DLL_CRC_TH
                        HistoryEntry.m_wErrorCode = EPL_E_DLL_CRC_TH;
                        HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                        Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                        if (Ret != kEplSuccessful)
                        {
                            goto Exit;
                        }

                        BENCHMARK_MOD_02_TOGGLE(7);

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_CN_CRC;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_INVALID_FORMAT) != 0)
            {   // invalid format error occured (only direct reaction)
                // generate error history entry E_DLL_INVALID_FORMAT
                HistoryEntry.m_wErrorCode = EPL_E_DLL_INVALID_FORMAT;
                HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                AmiSetByteToLe(&HistoryEntry.m_abAddInfo[0], (BYTE) pErrHandlerEvent->m_uiNodeId);
                Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                if (Ret != kEplSuccessful)
                {
                    goto Exit;
                }

                BENCHMARK_MOD_02_TOGGLE(7);

#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
                if (pErrHandlerEvent->m_NmtState >= kEplNmtMsNotActive)
                {   // MN is active
                    if (pErrHandlerEvent->m_uiNodeId != 0)
                    {
                    tEplHeartbeatEvent  HeartbeatEvent;
                    tEplDllNodeOpParam  NodeOpParam;

                        NodeOpParam.m_OpNodeType = kEplDllNodeOpTypeIsochronous;
                        NodeOpParam.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;

                        // remove node from isochronous phase
                        Ret = EplDllkDeleteNode(&NodeOpParam);

                        // inform NmtMnu module about state change, which shall send NMT command ResetNode to this CN
                        HeartbeatEvent.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;
                        HeartbeatEvent.m_NmtState = kEplNmtCsNotActive;
                        HeartbeatEvent.m_wErrorCode = EPL_E_DLL_INVALID_FORMAT;
                        Event.m_EventSink = kEplEventSinkNmtMnu;
                        Event.m_EventType = kEplEventTypeHeartbeat;
                        Event.m_uiSize = sizeof (HeartbeatEvent);
                        Event.m_pArg = &HeartbeatEvent;
                        Ret = EplEventkPost(&Event);
                    }
                    // $$$ and else should lead to InternComError
                }
                else
#endif
                {   // CN is active
                    // post event to NMT state machine
                    NmtEvent = kEplNmtEventInternComError;
                    Event.m_EventSink = kEplEventSinkNmtk;
                    Event.m_EventType = kEplEventTypeNmtEvent;
                    Event.m_pArg = &NmtEvent;
                    Event.m_uiSize = sizeof (NmtEvent);
                    Ret = EplEventkPost(&Event);
                }
            }

#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
            if ((ulDllErrorEvents & EPL_DLL_ERR_MN_CRC) != 0)
            {   // CRC error event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThreshold)
                    {   // threshold is reached
                        // generate error history entry E_DLL_CRC_TH
                        HistoryEntry.m_wErrorCode = EPL_E_DLL_CRC_TH;
                        HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                        Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                        if (Ret != kEplSuccessful)
                        {
                            goto Exit;
                        }

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_MN_CRC;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_MN_CYCTIMEEXCEED) != 0)
            {   // cycle time exceeded event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThreshold)
                    {   // threshold is reached
                        // generate error history entry E_DLL_CYCLE_EXCEED_TH
                        HistoryEntry.m_wErrorCode = EPL_E_DLL_CYCLE_EXCEED_TH;
                        HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                        AmiSetWordToLe(&HistoryEntry.m_abAddInfo[0], (WORD) pErrHandlerEvent->m_EplError);
                        Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                        if (Ret != kEplSuccessful)
                        {
                            goto Exit;
                        }

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    else
                    {   // generate error history entry E_DLL_CYCLE_EXCEED
                        HistoryEntry.m_wErrorCode = EPL_E_DLL_CYCLE_EXCEED;
                        HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                        AmiSetWordToLe(&HistoryEntry.m_abAddInfo[0], (WORD) pErrHandlerEvent->m_EplError);
                        Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                        if (Ret != kEplSuccessful)
                        {
                            goto Exit;
                        }
                    }

                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_MN_CYCTIMEEXCEED;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_MN_CN_LOSS_PRES) != 0)
            {   // CN loss PRes event occured
            unsigned int uiNodeId;

                uiNodeId = pErrHandlerEvent->m_uiNodeId - 1;
                if (uiNodeId < tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt))
                {
                    if  (EplErrorHandlerkInstance_g.m_abMnCnLossPresEvent[uiNodeId] == EPL_ERRORHANDLERK_CN_LOSS_PRES_EVENT_NONE)
                    {
                        // increment cumulative counter by 1
                        EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt[uiNodeId]++;

                        if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold[uiNodeId] > 0)
                        {
                            // increment threshold counter by 8
                            EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId] += 8;
                            if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId]
                                >= EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold[uiNodeId])
                            {   // threshold is reached
                            tEplHeartbeatEvent  HeartbeatEvent;
                            tEplDllNodeOpParam  NodeOpParam;

                                EplErrorHandlerkInstance_g.m_abMnCnLossPresEvent[uiNodeId] = EPL_ERRORHANDLERK_CN_LOSS_PRES_EVENT_THR;

                                NodeOpParam.m_OpNodeType = kEplDllNodeOpTypeIsochronous;
                                NodeOpParam.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;

                                // generate error history entry E_DLL_LOSS_PRES_TH
                                HistoryEntry.m_wErrorCode = EPL_E_DLL_LOSS_PRES_TH;
                                HistoryEntry.m_TimeStamp = pEvent_p->m_NetTime;
                                AmiSetByteToLe(&HistoryEntry.m_abAddInfo[0], (BYTE) pErrHandlerEvent->m_uiNodeId);
                                Ret = EplErrorHandlerkPostHistoryEntry(&HistoryEntry);
                                if (Ret != kEplSuccessful)
                                {
                                    goto Exit;
                                }

                                // remove node from isochronous phase
                                Ret = EplDllkDeleteNode(&NodeOpParam);

                                // inform NmtMnu module about state change, which shall send NMT command ResetNode to this CN
                                HeartbeatEvent.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;
                                HeartbeatEvent.m_NmtState = kEplNmtCsNotActive;
                                HeartbeatEvent.m_wErrorCode = EPL_E_DLL_LOSS_PRES_TH;
                                Event.m_EventSink = kEplEventSinkNmtMnu;
                                Event.m_EventType = kEplEventTypeHeartbeat;
                                Event.m_uiSize = sizeof (HeartbeatEvent);
                                Event.m_pArg = &HeartbeatEvent;
                                Ret = EplEventkPost(&Event);
                            }
                            else
                            {
                                EplErrorHandlerkInstance_g.m_abMnCnLossPresEvent[uiNodeId] = EPL_ERRORHANDLERK_CN_LOSS_PRES_EVENT_OCC;
                            }
                        }
                    }
                }
            }
#endif

            break;
        }

        // unknown type
        default:
        {
            Ret = kEplInvalidEvent;
            break;
        }

    } // end of switch(pEvent_p->m_EventType)

Exit:
    return Ret;

}
Ejemplo n.º 10
0
//---------------------------------------------------------------------------
//
// Function:    EplErrorHandlerkProcess
//
// Description: processes error events from DLL
//
//
//
// Parameters:  pEvent_p = pointer to event-structur from buffer
//
//
// Returns:      tEpKernel  = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplErrorHandlerkProcess(tEplEvent* pEvent_p)
{
tEplKernel              Ret;
unsigned long           ulDllErrorEvents;
tEplEvent               Event;
tEplNmtEvent            NmtEvent;

    Ret = kEplSuccessful;

    // check m_EventType
    switch(pEvent_p->m_EventType)
    {
        case kEplEventTypeDllError:
        {
        tEplErrorHandlerkEvent* pErrHandlerEvent = (tEplErrorHandlerkEvent*)pEvent_p->m_pArg;

            ulDllErrorEvents = pErrHandlerEvent->m_ulDllErrorEvents;

            // check the several error events
            if ((ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_SOC) != 0)
            {   // loss of SoC event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThreshold)
                    {   // threshold is reached
                        // $$$ d.k.: generate error history entry E_DLL_LOSS_SOC_TH

                        BENCHMARK_MOD_02_TOGGLE(7);

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_CN_LOSS_SOC;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_PREQ) != 0)
            {   // loss of PReq event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThreshold)
                    {   // threshold is reached
                        // $$$ d.k.: generate error history entry E_DLL_LOSS_PREQ_TH

                        BENCHMARK_MOD_02_TOGGLE(7);

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                }
            }

            if ((EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt > 0)
                && ((ulDllErrorEvents & EPL_DLL_ERR_CN_RECVD_PREQ) != 0))
            {   // PReq correctly received
                // decrement threshold counter by 1
                EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt--;
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_CN_CRC) != 0)
            {   // CRC error event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThreshold)
                    {   // threshold is reached
                        // $$$ d.k.: generate error history entry E_DLL_CRC_TH

                        BENCHMARK_MOD_02_TOGGLE(7);

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_CN_CRC;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_INVALID_FORMAT) != 0)
            {   // invalid format error occured (only direct reaction)
                // $$$ d.k.: generate error history entry E_DLL_INVALID_FORMAT

                BENCHMARK_MOD_02_TOGGLE(7);

#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
                if (pErrHandlerEvent->m_NmtState >= kEplNmtMsNotActive)
                {   // MN is active
                    if (pErrHandlerEvent->m_uiNodeId != 0)
                    {
                    tEplHeartbeatEvent  HeartbeatEvent;
                    tEplDllNodeOpParam  NodeOpParam;

                        NodeOpParam.m_OpNodeType = kEplDllNodeOpTypeIsochronous;
                        NodeOpParam.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;

                        // remove node from isochronous phase
                        Ret = EplDllkDeleteNode(&NodeOpParam);

                        // inform NmtMnu module about state change, which shall send NMT command ResetNode to this CN
                        HeartbeatEvent.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;
                        HeartbeatEvent.m_NmtState = kEplNmtCsNotActive;
                        HeartbeatEvent.m_wErrorCode = EPL_E_DLL_INVALID_FORMAT;
                        Event.m_EventSink = kEplEventSinkNmtMnu;
                        Event.m_EventType = kEplEventTypeHeartbeat;
                        Event.m_uiSize = sizeof (HeartbeatEvent);
                        Event.m_pArg = &HeartbeatEvent;
                        Ret = EplEventkPost(&Event);
                    }
                    // $$$ and else should lead to InternComError
                }
                else
#endif
                {   // CN is active
                    // post event to NMT state machine
                    NmtEvent = kEplNmtEventInternComError;
                    Event.m_EventSink = kEplEventSinkNmtk;
                    Event.m_EventType = kEplEventTypeNmtEvent;
                    Event.m_pArg = &NmtEvent;
                    Event.m_uiSize = sizeof (NmtEvent);
                    Ret = EplEventkPost(&Event);
                }
            }

#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
            if ((ulDllErrorEvents & EPL_DLL_ERR_MN_CRC) != 0)
            {   // CRC error event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThreshold)
                    {   // threshold is reached
                        // $$$ d.k.: generate error history entry E_DLL_CRC_TH

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_MN_CRC;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_MN_CYCTIMEEXCEED) != 0)
            {   // cycle time exceeded event occured
                // increment cumulative counter by 1
                EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwCumulativeCnt++;

                if (EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThreshold > 0)
                {
                    // increment threshold counter by 8
                    EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt += 8;
                    if (EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt
                        >= EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThreshold)
                    {   // threshold is reached
                        // $$$ d.k.: generate error history entry E_DLL_CYCLE_EXCEED_TH

                        // post event to NMT state machine
                        NmtEvent = kEplNmtEventNmtCycleError;
                        Event.m_EventSink = kEplEventSinkNmtk;
                        Event.m_EventType = kEplEventTypeNmtEvent;
                        Event.m_pArg = &NmtEvent;
                        Event.m_uiSize = sizeof (NmtEvent);
                        Ret = EplEventkPost(&Event);
                    }
                    // $$$ d.k.: else generate error history entry E_DLL_CYCLE_EXCEED
                    EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
                        EPL_DLL_ERR_MN_CYCTIMEEXCEED;
                }
            }

            if ((ulDllErrorEvents & EPL_DLL_ERR_MN_CN_LOSS_PRES) != 0)
            {   // CN loss PRes event occured
            unsigned int uiNodeId;

                uiNodeId = pErrHandlerEvent->m_uiNodeId - 1;
                if (uiNodeId < tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt))
                {
                    // increment cumulative counter by 1
                    EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt[uiNodeId]++;

                    if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold[uiNodeId] > 0)
                    {
                        // increment threshold counter by 8
                        EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId] += 8;
                        if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId]
                            >= EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold[uiNodeId])
                        {   // threshold is reached
                        tEplHeartbeatEvent  HeartbeatEvent;
                        tEplDllNodeOpParam  NodeOpParam;

                            NodeOpParam.m_OpNodeType = kEplDllNodeOpTypeIsochronous;
                            NodeOpParam.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;

                            // $$$ d.k.: generate error history entry E_DLL_LOSS_PRES_TH

                            // remove node from isochronous phase
                            Ret = EplDllkDeleteNode(&NodeOpParam);

                            // inform NmtMnu module about state change, which shall send NMT command ResetNode to this CN
                            HeartbeatEvent.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;
                            HeartbeatEvent.m_NmtState = kEplNmtCsNotActive;
                            HeartbeatEvent.m_wErrorCode = EPL_E_DLL_LOSS_PRES_TH;
                            Event.m_EventSink = kEplEventSinkNmtMnu;
                            Event.m_EventType = kEplEventTypeHeartbeat;
                            Event.m_uiSize = sizeof (HeartbeatEvent);
                            Event.m_pArg = &HeartbeatEvent;
                            Ret = EplEventkPost(&Event);
                        }
                        EplErrorHandlerkInstance_g.m_afMnCnLossPresEvent[uiNodeId] = TRUE;
                    }
                }
            }
#endif

            break;
        }

        // NMT event
        case kEplEventTypeNmtEvent:
        {
            if ((*(tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllCeSoa)
            {   // SoA event of CN -> decrement 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--;
                    }
                }
            }

#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
            else if ((*(tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllMeSoaSent)
            {   // SoA event of MN -> decrement threshold counters
            tEplDllkNodeInfo*   pIntNodeInfo;
            unsigned int        uiNodeId;

                Ret = EplDllkGetFirstNodeInfo(&pIntNodeInfo);
                if (Ret != kEplSuccessful)
                {
                    break;
                }
                // iterate through node info structure list
                while (pIntNodeInfo != NULL)
                {
                    uiNodeId = pIntNodeInfo->m_uiNodeId - 1;
                    if (uiNodeId < tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt))
                    {
                        if  (EplErrorHandlerkInstance_g.m_afMnCnLossPresEvent[uiNodeId] == FALSE)
                        {
                            if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId] > 0)
                            {
                                EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId]--;
                            }
                        }
                        else
                        {
                            EplErrorHandlerkInstance_g.m_afMnCnLossPresEvent[uiNodeId] = FALSE;
                        }
                    }
                    pIntNodeInfo = pIntNodeInfo->m_pNextNodeInfo;
                }

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

            // reset error events
            EplErrorHandlerkInstance_g.m_ulDllErrorEvents = 0L;

            break;
        }

        // unknown type
        default:
        {
            Ret = kEplInvalidEvent;
            break;
        }

    } // end of switch(pEvent_p->m_EventType)


    return Ret;

}