Exemplo n.º 1
0
/*******************************************************************************
  Function Name  : vFormatDataAndId
  Input(s)       : -
  Output         : -
  Functionality  : Format data and id
  Member of      : CFormatMsgCAN
  Author(s)      : Ratnadip
  Date Created   : 8.7.2009
  Modifications  : 
*******************************************************************************/
void CFormatMsgCAN::vFormatDataAndId(BYTE bExprnFlag, 
                                     SFORMATTEDDATA_CAN* CurrDataCAN)
{
    if (IS_NUM_HEX_SET(bExprnFlag))
    {
        _stprintf(CurrDataCAN->m_acMsgIDHex, FORMAT_STR_ID_HEX, CurrDataCAN->m_dwMsgID);
        int j = 0;  // j declared outside
        for (int i = 0; i < CurrDataCAN->m_byDataLength; i++)
        {
            BYTE CurrDat = CurrDataCAN->m_abData[i];
            _stprintf(&(CurrDataCAN->m_acDataHex[j]), FORMAT_STR_DATA_HEX, CurrDat);
            j += 3;
        }
        CurrDataCAN->m_acDataHex[j] = L'\0';
    }

    if (IS_NUM_DEC_SET(bExprnFlag))
    {
        _stprintf(CurrDataCAN->m_acMsgIDDec, FORMAT_STR_ID_DEC, CurrDataCAN->m_dwMsgID);
        int j = 0;
        for (int i = 0; i < CurrDataCAN->m_byDataLength; i++)
        {
            BYTE CurrDat = CurrDataCAN->m_abData[i];
            _stprintf(&(CurrDataCAN->m_acDataDec[j]), FORMAT_STR_DATA_DEC, CurrDat);
			j += 4;
			CurrDataCAN->m_acDataDec[j-1] = L' ';            
        }
        CurrDataCAN->m_acDataDec[j-1] = L'\0';
    }
}
Exemplo n.º 2
0
void CFormatMsgJ1939::vFormatDataAndId(BYTE bExprnFlag,
                                       PSTJ1939_MSG psJ1939BData,
                                       PSFORMATTEDATA_J1939 psJ1939FData)
{
    if (IS_NUM_HEX_SET(bExprnFlag))
    {
        _stprintf(psJ1939FData->m_acPGNHex, FORMAT_PGN_ID_HEX,
                  psJ1939BData->m_sMsgProperties.m_uExtendedID.m_s29BitId.unGetPGN());
        USHORT j = 0;       //j declared outside
        for (USHORT i = 0; i < psJ1939BData->m_unDLC; i++)
        {
            BYTE CurrDat = *(psJ1939BData->m_pbyData + i);
            _stprintf(&(psJ1939FData->m_pcDataHex[j]), FORMAT_STR_DATA_HEX, CurrDat);
            j += 3;
        }
        psJ1939FData->m_pcDataHex[j] = L'\0';
    }
    if (IS_NUM_DEC_SET(bExprnFlag))
    {
        _stprintf(psJ1939FData->m_acPGNDec, FORMAT_PGN_ID_DEC,
                  psJ1939BData->m_sMsgProperties.m_uExtendedID.m_s29BitId.unGetPGN());
        USHORT j = 0;   //j declared outside
        for (USHORT i = 0; i < psJ1939BData->m_unDLC; i++)
        {
            BYTE CurrDat = *(psJ1939BData->m_pbyData + i);
            _stprintf(&(psJ1939FData->m_pcDataDec[j]), FORMAT_STR_DATA_DEC, CurrDat);
            psJ1939FData->m_pcDataDec[j + 3] = L' '; //known issue #51 srinivas R
            j += 4;
        }
        psJ1939FData->m_pcDataDec[j] = L'\0';
    }
}
Exemplo n.º 3
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);

        //Now add the name of message if present in database else show the code
        nMsgCode = sCANCurrData.m_uDataInfo.m_sCANMsg.m_unMsgID;

        CString name;
        GetMessageName(sCANCurrData, name, IS_NUM_HEX_SET(bExprnFlag_Disp));
        strcpy(m_sOutFormattedData.m_acMsgDesc, name.GetBuffer(0));
    }
    else
    {
        memset (&m_sOutFormattedData, 0, sizeof(m_sOutFormattedData));
        nMsgCode = -1;
    }

    return hResult;
}
Exemplo n.º 4
0
/******************************************************************************
    Function Name    :  vGetUpdatedCurrDataPtrArray
    Input(s)         :
    Output           :
    Functionality    :  Provide format data structure pointers to the user
    Member of        :  CMsgContainerJ1939
    Friend of        :      -
    Author(s)        :  Arun kumar K
    Date Created     :  20.01.2011
******************************************************************************/
void CMsgContainerJ1939::vGetUpdatedCurrDataPtrArray(SMSGWNDHDRCOL& sHdrColStruct,
        char* pomDataPtrArr[MAX_MSG_WND_COL_CNT],
        BYTE bExprnFlag_Disp)
{
    //Time mode
    if (IS_TM_ABS_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeAbs;
    }

    else if (IS_TM_REL_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeRel;
    }

    else if (IS_TM_SYS_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeSys;
    }

    // Dec/Hex mode for DATA and ID
    if (IS_NUM_HEX_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_pcDataHex;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDHex;
        pomDataPtrArr[sHdrColStruct.m_byPGNPos]  = m_sOutFormattedData.m_acPGNHex;
        pomDataPtrArr[sHdrColStruct.m_bySrcPos]  = m_sOutFormattedData.m_acSrcHex;
        pomDataPtrArr[sHdrColStruct.m_byDestPos] = m_sOutFormattedData.m_acDestHex;
    }
    else if (IS_NUM_DEC_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_pcDataDec;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDDec;
        pomDataPtrArr[sHdrColStruct.m_byPGNPos]  = m_sOutFormattedData.m_acPGNDec;
        pomDataPtrArr[sHdrColStruct.m_bySrcPos]  = m_sOutFormattedData.m_acSrcDec;
        pomDataPtrArr[sHdrColStruct.m_byDestPos] = m_sOutFormattedData.m_acDestDec;
    }

    //Rest will always be same
    pomDataPtrArr[sHdrColStruct.m_byDLCPos]       = m_sOutFormattedData.m_acDataLen;
    pomDataPtrArr[sHdrColStruct.m_byMsgTypePos]   = m_sOutFormattedData.m_acMsgType;
    pomDataPtrArr[sHdrColStruct.m_byRxTxPos]      = m_sOutFormattedData.m_acMsgDir;
    pomDataPtrArr[sHdrColStruct.m_byChannel]      = m_sOutFormattedData.m_acChannel;
    pomDataPtrArr[sHdrColStruct.m_byPriorityPos]  = m_sOutFormattedData.m_acPriority;
    pomDataPtrArr[sHdrColStruct.m_byCodeNamePos]  = m_sOutFormattedData.m_acMsgName;
}
Exemplo n.º 5
0
/*******************************************************************************
  Function Name  : vFormatDataAndId
  Input(s)       : -
  Output         : -
  Functionality  : Format data and id
  Member of      : CFormatMsgCAN
  Author(s)      : Ratnadip
  Date Created   : 8.7.2009
  Modifications  :
*******************************************************************************/
void CFormatMsgCAN::vFormatDataAndId(BYTE bExprnFlag,
                                     SFORMATTEDDATA_CAN* CurrDataCAN)
{
    if (IS_NUM_HEX_SET(bExprnFlag))
    {
        sprintf_s(CurrDataCAN->m_acMsgIDHex, FORMAT_STR_ID_HEX, CurrDataCAN->m_dwMsgID);

        //If an RTR message, Databyte(s) not required to be displayed
        if ( ! ( CurrDataCAN->m_byMsgType & TYPE_MSG_CAN_RTR ) )
        {
            int j = 0;  // j declared outside

            for (int i = 0; i < CurrDataCAN->m_byDataLength; i++)
            {
                BYTE CurrDat = CurrDataCAN->m_abData[i];
                _stprintf(&(CurrDataCAN->m_acDataHex[j]), FORMAT_STR_DATA_HEX, CurrDat);
                j += 3;
            }

            CurrDataCAN->m_acDataHex[j] = L'\0';
        }
    }

    if (IS_NUM_DEC_SET(bExprnFlag))
    {
        sprintf_s(CurrDataCAN->m_acMsgIDDec, FORMAT_STR_ID_DEC, CurrDataCAN->m_dwMsgID);

        //If an RTR message, Databyte(s) not required to be displayed
        if ( ! ( CurrDataCAN->m_byMsgType & TYPE_MSG_CAN_RTR ) )
        {
            int j = 0;

            for (int i = 0; i < CurrDataCAN->m_byDataLength; i++)
            {
                BYTE CurrDat = CurrDataCAN->m_abData[i];
                _stprintf(&(CurrDataCAN->m_acDataDec[j]), FORMAT_STR_DATA_DEC, CurrDat);
                j += 4;
                CurrDataCAN->m_acDataDec[j-1] = L' ';
            }

            CurrDataCAN->m_acDataDec[j-1] = L'\0';
        }
    }
}
Exemplo n.º 6
0
void CFormatMsgJ1939::vFormatJ1939DataMsg(PSTJ1939_MSG psJ1939BData,
        PSFORMATTEDATA_J1939 psJ1939FData,
        BYTE bExprnFlag_Log)
{
    psJ1939FData->m_dwMsgID = psJ1939BData->m_sMsgProperties.m_uExtendedID.m_unExtID;

    GetMessageTypeStr(psJ1939BData->m_sMsgProperties.m_eType, psJ1939FData->m_acMsgType);

    TYPE_CHANNEL CurrChannel = psJ1939BData->m_sMsgProperties.m_byChannel;
    if ((CurrChannel >= CHANNEL_CAN_MIN) && (CurrChannel <= CHANNEL_CAN_MAX ))
    {
        _stprintf(psJ1939FData->m_acChannel, "%d", CurrChannel);
    }

    if (IS_NUM_HEX_SET(bExprnFlag_Log))
    {
        _stprintf(psJ1939FData->m_acSrcHex, FORMAT_STR_DATA_HEX, psJ1939BData->m_sMsgProperties.m_uExtendedID.m_s29BitId.m_bySrcAddress);
        _stprintf(psJ1939FData->m_acDestHex, FORMAT_STR_DATA_HEX, psJ1939BData->m_sMsgProperties.m_uExtendedID.m_s29BitId.m_uPGN.m_sPGN.m_byPDU_Specific);
    }

    if (IS_NUM_DEC_SET(bExprnFlag_Log))
    {
        _stprintf(psJ1939FData->m_acSrcDec, FORMAT_STR_DATA_DEC, psJ1939BData->m_sMsgProperties.m_uExtendedID.m_s29BitId.m_bySrcAddress);
        _stprintf(psJ1939FData->m_acDestDec, FORMAT_STR_DATA_DEC, psJ1939BData->m_sMsgProperties.m_uExtendedID.m_s29BitId.m_uPGN.m_sPGN.m_byPDU_Specific);
    }

    _stprintf(psJ1939FData->m_acPriority, FORMAT_STR_DATA_DEC, psJ1939BData->m_sMsgProperties.m_uExtendedID.m_s29BitId.m_uPGN.m_sPGN.m_byPriority);
    if (DIR_RX == psJ1939BData->m_sMsgProperties.m_eDirection)
    {
        psJ1939FData->m_acMsgDir[0] = L'R';
    }
    else if (DIR_TX == psJ1939BData->m_sMsgProperties.m_eDirection)
    {
        psJ1939FData->m_acMsgDir[0] = L'T';
    }
    else
    {
        ASSERT(FALSE);
    }
    _itot(psJ1939BData->m_unDLC, psJ1939FData->m_acDataLen, 10);

    vFormatTime(bExprnFlag_Log, psJ1939BData, psJ1939FData);
    vFormatDataAndId(bExprnFlag_Log, psJ1939BData, psJ1939FData);
}
Exemplo n.º 7
0
/******************************************************************************
    Function Name    :  vGetUpdatedCurrDataPtrArray
    Input(s)         :
    Output           :
    Functionality    :  Provide format data structure pointers to the user
    Member of        :  CMsgContainerLIN
    Friend of        :      -
    Author(s)        :  Anish kumar
    Date Created     :  01.04.2010
******************************************************************************/
void CMsgContainerLIN::vGetUpdatedCurrDataPtrArray(SMSGWNDHDRCOL& sHdrColStruct,
        char* pomDataPtrArr[MAX_MSG_WND_COL_CNT],
        BYTE bExprnFlag_Disp)
{
    //Time mode
    if (IS_TM_ABS_SET(bExprnFlag_Disp)) //for Absolute non-reset timestamp
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeAbs;
    }

    else if (IS_TM_REL_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeRel;
    }

    else if (IS_TM_SYS_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeSys;
    }

    // Dec/Hex mode for DATA and ID
    if (IS_NUM_HEX_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_acDataHex;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDHex;
    }
    else if (IS_NUM_DEC_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_acDataDec;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDDec;
    }

    //Rest will always be same
    pomDataPtrArr[sHdrColStruct.m_byDLCPos]       = m_sOutFormattedData.m_acDataLen;
    pomDataPtrArr[sHdrColStruct.m_byMsgTypePos]   = m_sOutFormattedData.m_acType;
    pomDataPtrArr[sHdrColStruct.m_byRxTxPos]      = m_sOutFormattedData.m_acMsgDir;
    pomDataPtrArr[sHdrColStruct.m_byCodeNamePos]  = m_sOutFormattedData.m_acMsgDesc;
    pomDataPtrArr[sHdrColStruct.m_byChannel]      = m_sOutFormattedData.m_acChannel;
    pomDataPtrArr[sHdrColStruct.m_byChecksumPos]  = m_sOutFormattedData.m_acChecksum;
}
Exemplo n.º 8
0
/*******************************************************************************
  Function Name  : vFormatDataAndId
  Input(s)       : -
  Output         : -
  Functionality  : Format data and id
  Member of      : CFormatMsgEthernet
  Author(s)      : Ashwin R Uchil
  Date Created   : 5.6.2014
  Modifications  :
*******************************************************************************/
void CFormatMsgEthernet::vFormatDataAndId(BYTE bExprnFlag, SFORMATTEDDATA_ETHERNET* CurrDataEthernet)
{
   if (IS_NUM_HEX_SET(bExprnFlag))
    {
        strcpy(CurrDataEthernet->m_acMsgIDHex, "");
        if ( CurrDataEthernet->m_dwMsgID != -1 )
        {
            sprintf_s(CurrDataEthernet->m_acMsgIDHex, FORMAT_STR_ID_HEX, CurrDataEthernet->m_dwMsgID);
        }
        int j = 0;  // j declared outside

        for (int i = 0; i < CurrDataEthernet->m_nDataLength; i++)
        {
            BYTE CurrDat = CurrDataEthernet->m_abData[i];
            _stprintf(&(CurrDataEthernet->m_acDataHex[j]), FORMAT_STR_DATA_HEX, CurrDat);
            j += 3;
        }
        CurrDataEthernet->m_acDataHex[j] = L'\0';
    }

    if (IS_NUM_DEC_SET(bExprnFlag))
    {
        strcpy(CurrDataEthernet->m_acMsgIDDec, "");
        if ( CurrDataEthernet->m_dwMsgID != -1 )
        {
            sprintf_s(CurrDataEthernet->m_acMsgIDDec, FORMAT_STR_ID_DEC, CurrDataEthernet->m_dwMsgID);
        }
        int j = 0;

        for (int i = 0; i < CurrDataEthernet->m_nDataLength; i++)
        {
            BYTE CurrDat = CurrDataEthernet->m_abData[i];
            _stprintf(&(CurrDataEthernet->m_acDataDec[j]), FORMAT_STR_DATA_DEC, CurrDat);
            j += 4;
            CurrDataEthernet->m_acDataDec[j-1] = L' ';
        }

        CurrDataEthernet->m_acDataDec[j-1] = L'\0';
    }
}
Exemplo n.º 9
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        :  CMsgContainerJ1939
    Friend of        :      -
    Author(s)        :  Arun kumar K
    Date Created     :  20.01.2011
******************************************************************************/
HRESULT CMsgContainerJ1939::hUpdateFormattedMsgStruct(int nListIndex,
        int& nMsgCode,
        BYTE bExprnFlag_Disp,
        __int64 nTimeOffset)
{
    HRESULT hResult = S_FALSE;
    INT nSize = 0;
    nMsgCode  = 0;
    //memset( &m_sOutFormattedData, 0, sizeof(m_sOutFormattedData) );
    if( IS_MODE_APPEND(bExprnFlag_Disp) )
    {
        INT nType = 0;
        nSize = MAX_MSG_LEN_J1939 + sizeof(__int64);

        //In append mode providing interpret state is not required
        hResult = m_ouAppendJ1939Buf.ReadEntry(nType, m_pbyJ1939Data, nSize,
                                               nListIndex, FALSE);

        if (hResult == S_OK)
        {
            // Save it into J1939 message structure
            m_sJ1939ReadMsgSpl.vSetDataStream(m_pbyJ1939Data);

            // Copy delta time
            BYTE* pBytTemp = m_pbyJ1939Data;
            pBytTemp += /*m_sJ1939Data.unGetSize()*/nSize - sizeof(__int64);
            memcpy(&m_sJ1939ReadMsgSpl.m_nDeltime, pBytTemp, sizeof(__int64));
        }
    }
    else
    {
        hResult = m_ouOWJ1939Buf.ReadFromBuffer(&m_sJ1939Data,
                                                nListIndex);
        if (hResult == S_OK)
        {
            UINT64 u64DelTS = m_sJ1939Data.m_sMsgProperties.m_un64TimeStamp - nTimeOffset;

            m_sJ1939Data.vGetDataStream(m_pbyJ1939Data);
            m_sJ1939ReadMsgSpl.vSetDataStream(m_pbyJ1939Data);
            m_sJ1939ReadMsgSpl.m_nDeltime = u64DelTS;
        }
    }

    if (hResult == S_OK)
    {
        m_ouFormatJ1939.vFormatJ1939DataMsg(
            (PSTJ1939_MSG) &(m_sJ1939ReadMsgSpl), m_sJ1939ReadMsgSpl.m_nDeltime,
            &m_sOutFormattedData, bExprnFlag_Disp);

        CString name;
        GetMessageName(m_sJ1939ReadMsgSpl, name, IS_NUM_HEX_SET(bExprnFlag_Disp));
        strcpy(m_sOutFormattedData.m_acMsgName, name.GetBuffer(0));

        //Now add the name of message if present in database else show the code
        if (nullptr != m_sJ1939ReadMsgSpl.m_pbyData)
        {
            //nMsgCode = m_sJ1939ReadMsgSpl.m_pbyData[0];
            nMsgCode = m_sJ1939ReadMsgSpl.m_sMsgProperties.m_uExtendedID.m_s29BitId.unGetPGN();
        }
    }
    return hResult;
}