//---------------------------------------------------------------------------
//
// 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;
}
//------------------------------------------------------------------------------
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;
}
Beispiel #3
0
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;
}