コード例 #1
0
/******************************************************************************
    Function Name    :  nCreateKeyWithCodeAndType
    Input(s)         :
    Output           :
    Functionality    :  Creates a key for SmsgDispEntry map
    Member of        :  CMsgContainerCAN
    Friend of        :      -
    Author(s)        :  Anish kumar
    Date Created     :  01.04.2010
******************************************************************************/
__int64 CMsgContainerCAN::nCreateMapIndexKey( LPVOID pMsgData )
{
    STCANDATA* pouCANData = (STCANDATA*)pMsgData;
    STCAN_MSG& sMsg = pouCANData->m_uDataInfo.m_sCANMsg;

    // Form message to get message index in the CMap
    int nMsgID = 0;
    if (IS_ERR_MESSAGE(pouCANData->m_ucDataType))
    {
        nMsgID = MAKE_RX_TX_MESSAGE( usProcessCurrErrorEntry(pouCANData->m_uDataInfo.m_sErrInfo),
                                     IS_RX_MESSAGE(pouCANData->m_ucDataType));
    }
    else
    {
        nMsgID = MAKE_RX_TX_MESSAGE( sMsg.m_unMsgID,
                                     IS_RX_MESSAGE(pouCANData->m_ucDataType));
    }

    nMsgID = MAKE_DEFAULT_MESSAGE_TYPE(nMsgID);
    // For extended message
    if (sMsg.m_ucEXTENDED)
    {
        nMsgID = MAKE_EXTENDED_MESSAGE_TYPE(nMsgID);
    }
    // Apply Channel Information
    __int64 n64MapIndex = MAKE_CHANNEL_SPECIFIC_MESSAGE( nMsgID,
                          sMsg.m_ucChannel );
    return n64MapIndex;
}
コード例 #2
0
HRESULT CMsgContainerCAN::GetErrorInfo(STCANDATA& sCANMsg, CString& msgName)
{
    CString omErrMsg("");
    BOOL bErrProcessed = FALSE;
    int nCount = 0;

    auto nMsgCode = usProcessCurrErrorEntry(sCANMsg.m_uDataInfo.m_sErrInfo);

    while ((nCount < ERRORS_DEFINED) && (bErrProcessed == FALSE))
    {
        if (nMsgCode == sg_asErrorEntry[nCount].m_usErrorCode)
        {
            msgName = _(sg_asErrorEntry[nCount].m_ptcErorMsg);
            bErrProcessed = TRUE;
        }
        nCount++;
    }

    if (bErrProcessed == FALSE)
    {
        msgName.Format(_("Error code: %X"), sCANMsg.m_uDataInfo.m_sErrInfo.m_ucReg_ErrCap);
    }
    return S_OK;
}
コード例 #3
0
/*******************************************************************************
  Function Name  : vFormatCANDataMsg
  Input(s)       : -
  Output         : -
  Functionality  : Format CAN data bytes
  Member of      : CFormatMsgCAN
  Author(s)      : Ratnadip
  Date Created   : 8.7.2009
  Modifications  : ArunKumar K
                   08.09.2010,
                   Added handler for error messages. ERR_FLAG
*******************************************************************************/
void CFormatMsgCAN::vFormatCANDataMsg(STCANDATA* pMsgCAN,
                                      SFORMATTEDDATA_CAN* CurrDataCAN,
                                      BYTE bExprnFlag_Log)
{
    if (RX_FLAG == pMsgCAN->m_ucDataType)
    {
        CurrDataCAN->m_eDirection = DIR_RX;
        CurrDataCAN->m_acMsgDir[0] = _T('R');
    }
    else if (TX_FLAG == pMsgCAN->m_ucDataType)
    {
        CurrDataCAN->m_eDirection = DIR_TX;
        CurrDataCAN->m_acMsgDir[0] = _T('T');
    }
    CurrDataCAN->m_acMsgDir[1] = _T('x');

    TYPE_CHANNEL CurrChannel = pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucChannel;
    if ((CurrChannel >= CHANNEL_CAN_MIN) && (CurrChannel <= CHANNEL_CAN_MAX ))
    {
        sprintf_s(CurrDataCAN->m_acChannel, "%d", CurrChannel);
    }

    memset(CurrDataCAN->m_acType,'\0',sizeof(CurrDataCAN->m_acType));
    if (pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucEXTENDED != 0)
    {
        CurrDataCAN->m_byIDType = TYPE_ID_CAN_EXTENDED;
        CurrDataCAN->m_acType[0] = 'x';
    }
    else
    {
        CurrDataCAN->m_byIDType = TYPE_ID_CAN_STANDARD;
        CurrDataCAN->m_acType[0] = _T('s');
    }

    if (pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucRTR != 0)
    {
        CurrDataCAN->m_byMsgType |= TYPE_MSG_CAN_RTR;
        CurrDataCAN->m_acType[1] = _T('r');
    }

    _itoa_s(pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucDataLen, CurrDataCAN->m_acDataLen, 10);
    strcpy_s(CurrDataCAN->m_acMsgDesc, LENGTH_STR_DESCRIPTION_CAN, "Description");
    CurrDataCAN->m_u64TimeStamp = pMsgCAN->m_lTickCount.QuadPart;
    CurrDataCAN->m_dwMsgID = pMsgCAN->m_uDataInfo.m_sCANMsg.m_unMsgID;
    CurrDataCAN->m_byDataLength = pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucDataLen;

    memcpy(CurrDataCAN->m_abData, pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucData,
           CurrDataCAN->m_byDataLength);

    /*PROCESS ERROR MSGS: If Error Message type. Change the data and type fields. */
    if(ERR_FLAG == pMsgCAN->m_ucDataType)
    {
        USHORT usErrCode = usProcessCurrErrorEntry(pMsgCAN->m_uDataInfo.m_sErrInfo);

        if( usErrCode != ERROR_UNKNOWN )
        {
            // Format error message
            char* ptrStrErrName = NULL;
            ptrStrErrName = vFormatCurrErrorEntry(usErrCode);

            if(ptrStrErrName)
            {
                strcpy_s(CurrDataCAN->m_acDataDec, LENGTH_STR_DATA_CAN, ptrStrErrName);
                strcpy_s(CurrDataCAN->m_acDataHex, LENGTH_STR_DATA_CAN, ptrStrErrName);
            }
        }

        CurrDataCAN->m_dwMsgID = pMsgCAN->m_uDataInfo.m_sCANMsg.m_unMsgID;
        sprintf_s(CurrDataCAN->m_acMsgIDDec, FORMAT_STR_ID_DEC, CurrDataCAN->m_dwMsgID);
        strcpy_s(CurrDataCAN->m_acType, LENGTH_STR_TYPE_CAN, "ERR");
    }

    /* PROCESS ERROR MSGS ENDS */
    vFormatTime(bExprnFlag_Log, CurrDataCAN);
    vFormatDataAndId(bExprnFlag_Log, CurrDataCAN);
}
コード例 #4
0
/******************************************************************************
    Function Name    :  hUpdateFormattedMsgStruct
    Input(s)         :  
    Output           :  
    Functionality    :  Format the requested Msg and save it in Format data 
                        structure which is accessible from the User module
    Member of        :  CMsgContainerCAN
    Friend of        :      -
    Author(s)        :  Anish kumar
    Date Created     :  01.04.2010
******************************************************************************/
HRESULT CMsgContainerCAN::hUpdateFormattedMsgStruct(int nListIndex,
                                                 int &nMsgCode, 
                                                 BYTE bExprnFlag_Disp,
                                                 __int64 nTimeOffset)
{
    HRESULT hResult = S_FALSE;
    nMsgCode  = 0;	
    static STCANDATA sCANCurrData;
    static STCANDATASPL sCANCurrDataSpl;
    memset( &m_sOutFormattedData, 0, sizeof(m_sOutFormattedData) );
    if( IS_MODE_APPEND(bExprnFlag_Disp) )
    {
        //INT nType = 0;
		//INT nSize =sizeof(sCANCurrDataSpl);
        //In append mode providing interpret state is not required
		//hResult = m_ouAppendCanBuf.ReadEntry(nType, (BYTE*)&sCANCurrDataSpl, nSize, nListIndex, 0); 
        hResult = m_ouAppendCanBuf.ReadFromBuffer(&sCANCurrDataSpl, nListIndex);		
        sCANCurrData = *((STCANDATA*)&sCANCurrDataSpl);
        if (IS_TM_REL_SET(bExprnFlag_Disp))
        {
            //If relative time then the time will be delta time, for formatting
            sCANCurrData.m_lTickCount.QuadPart = sCANCurrDataSpl.m_nDeltime;
        }
    }
    else
    {
        hResult = m_ouOWCanBuf.ReadFromBuffer(&sCANCurrData, nListIndex);
        if (hResult == S_OK)
        {
            if (IS_TM_REL_SET(bExprnFlag_Disp))
            {
                //If relative time then the time will be delta time, for formatting
                sCANCurrData.m_lTickCount.QuadPart -= nTimeOffset;
            }
        }
    }
    
    if (hResult == S_OK)
    {
        m_ouFormatCAN.vFormatCANDataMsg(&sCANCurrData, 
                                        &m_sOutFormattedData, 
                                        bExprnFlag_Disp);

		//If Message is erroneous, return S_FALSE
		if(IS_ERR_MESSAGE(sCANCurrData.m_ucDataType))
		{
			nMsgCode = usProcessCurrErrorEntry(sCANCurrData.m_uDataInfo.m_sErrInfo);				
			return S_FALSE;
		}

        //Now add the name of message if present in database else show the code
        nMsgCode = sCANCurrData.m_uDataInfo.m_sCANMsg.m_unMsgID;	
    }
    else
    {
        memset (&m_sOutFormattedData, 0, sizeof(m_sOutFormattedData));
		nMsgCode = -1;
    }	

    return hResult;
}
コード例 #5
0
/*******************************************************************************
  Function Name  : vFormatCANDataMsg
  Input(s)       : -
  Output         : -
  Functionality  : Format CAN data bytes
  Member of      : CFormatMsgCAN
  Author(s)      : Ratnadip
  Date Created   : 8.7.2009
  Modifications  : ArunKumar K
                   08.09.2010,
                   Added handler for error messages. ERR_FLAG
*******************************************************************************/
void CFormatMsgCAN::vFormatCANDataMsg(STCANDATA* pMsgCAN,
                                      SFORMATTEDDATA_CAN* CurrDataCAN,
                                      BYTE bExprnFlag_Log)
{
    if (RX_FLAG == pMsgCAN->m_ucDataType)
    {
        CurrDataCAN->m_eDirection = DIR_RX;
        CurrDataCAN->m_acMsgDir[0] = 'R';
    }
    else if (TX_FLAG == pMsgCAN->m_ucDataType)
    {
        CurrDataCAN->m_eDirection = DIR_TX;
        CurrDataCAN->m_acMsgDir[0] = 'T';
    }
    CurrDataCAN->m_acMsgDir[1] = 'x';

    TYPE_CHANNEL CurrChannel = pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucChannel;  // Assuming default CAN msg
    if (pMsgCAN->m_uDataInfo.m_sCANMsg.m_bCANFD) // Incase of CANFD msg
    {
        CurrChannel = pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucChannel;
    }

    if ((CurrChannel >= CHANNEL_CAN_MIN) && (CurrChannel <= CHANNEL_CAN_MAX ))
    {
        sprintf_s(CurrDataCAN->m_acChannel, "%d", CurrChannel);
    }

    memset(CurrDataCAN->m_acType, 0, sizeof(CurrDataCAN->m_acType));
    if (pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucEXTENDED != 0)
    {
        CurrDataCAN->m_byIDType = TYPE_ID_CAN_EXTENDED;
        strcpy_s(CurrDataCAN->m_acType, LENGTH_STR_TYPE_CAN, "x");
    }
    else
    {
        CurrDataCAN->m_byIDType = TYPE_ID_CAN_STANDARD;
        strcpy_s(CurrDataCAN->m_acType, LENGTH_STR_TYPE_CAN, "s");
    }
    /* If it is a CAN FD frame */
    if ( pMsgCAN->m_uDataInfo.m_sCANMsg.m_bCANFD )
    {
        strcpy_s(&CurrDataCAN->m_acType[1], LENGTH_STR_TYPE_CAN, "-fd");
    }
    else if (pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucRTR != 0) // CANFD cannot have RTR frames
    {
        CurrDataCAN->m_byMsgType |= TYPE_MSG_CAN_RTR;
        strcpy_s(&CurrDataCAN->m_acType[1], LENGTH_STR_DESCRIPTION_CAN, "r");
    }

    /* If it is a CAN FD frame */
    //if ( pMsgCAN->m_bCANFDMsg )
    //{
    //    _itoa_s(pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucDataLen, CurrDataCAN->m_acDataLen, 10);
    //    strcpy_s(CurrDataCAN->m_acMsgDesc, LENGTH_STR_DESCRIPTION_CAN, "Description");
    //    CurrDataCAN->m_u64TimeStamp = pMsgCAN->m_lTickCount.QuadPart;
    //    CurrDataCAN->m_dwMsgID = pMsgCAN->m_uDataInfo.m_sCANMsg.m_unMsgID;
    //    CurrDataCAN->m_byDataLength = pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucDataLen;

    //    memcpy(CurrDataCAN->m_abData, pMsgCAN->m_uDataInfo.m_sCANMsg.m_aucCANFDData,
    //           CurrDataCAN->m_byDataLength);
    //}
    //else
    {
        _itoa_s(pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucDataLen, CurrDataCAN->m_acDataLen, 10);
        strcpy_s(CurrDataCAN->m_acMsgDesc, LENGTH_STR_DESCRIPTION_CAN, _("Description"));
        CurrDataCAN->m_u64TimeStamp = pMsgCAN->m_lTickCount.QuadPart;
        CurrDataCAN->m_dwMsgID = pMsgCAN->m_uDataInfo.m_sCANMsg.m_unMsgID;
        CurrDataCAN->m_byDataLength = pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucDataLen;

        memcpy(CurrDataCAN->m_abData, pMsgCAN->m_uDataInfo.m_sCANMsg.m_ucData,
               CurrDataCAN->m_byDataLength);
    }

    /*PROCESS ERROR MSGS: If Error Message type. Change the data and type fields. */
    if(ERR_FLAG == pMsgCAN->m_ucDataType)
    {
        USHORT usErrCode = usProcessCurrErrorEntry(pMsgCAN->m_uDataInfo.m_sErrInfo);

        if( usErrCode != ERROR_UNKNOWN )
        {
            // Format error message
            char* ptrStrErrName = nullptr;
            ptrStrErrName = vFormatCurrErrorEntry(usErrCode);

            if(ptrStrErrName)
            {
                strcpy_s(CurrDataCAN->m_acDataDec, LENGTH_STR_DATA_CAN, ptrStrErrName);
                strcpy_s(CurrDataCAN->m_acDataHex, LENGTH_STR_DATA_CAN, ptrStrErrName);
            }
        }

        CurrDataCAN->m_dwMsgID = pMsgCAN->m_uDataInfo.m_sCANMsg.m_unMsgID;
        sprintf_s(CurrDataCAN->m_acMsgIDDec, FORMAT_STR_ID_DEC, CurrDataCAN->m_dwMsgID);
        strcpy_s(CurrDataCAN->m_acType, LENGTH_STR_TYPE_CAN, "ERR");
    }

    /* PROCESS ERROR MSGS ENDS */
    vFormatTime(bExprnFlag_Log, CurrDataCAN);
    vFormatDataAndId(bExprnFlag_Log, CurrDataCAN);
}