Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef CANMSG_INCLUDEDEF_H
00038 #define CANMSG_INCLUDEDEF_H
00039
00040
00041
00042 #include <iostream>
00043
00044
00045
00050 class CanMsg
00051 {
00052 public:
00053 int m_iID;
00054 int m_iLen;
00055 int m_iType;
00056
00057 private:
00061 char m_bDat[8];
00062
00063 public:
00067 CanMsg()
00068 {
00069 m_iID = 0;
00070 m_iLen = 8;
00071 m_iType = 0x00;
00072 }
00073
00077 void set(char Data0, char Data1, char Data2, char Data3, char Data4, char Data5, char Data6, char Data7)
00078 {
00079 m_bDat[0] = Data0;
00080 m_bDat[1] = Data1;
00081 m_bDat[2] = Data2;
00082 m_bDat[3] = Data3;
00083 m_bDat[4] = Data4;
00084 m_bDat[5] = Data5;
00085 m_bDat[6] = Data6;
00086 m_bDat[7] = Data7;
00087 }
00088
00092 void get(char* pData0, char* pData1, char* pData2, char* pData3, char* pData4, char* pData5, char* pData6, char* pData7)
00093 {
00094 *pData0 = m_bDat[0];
00095 *pData1 = m_bDat[1];
00096 *pData2 = m_bDat[2];
00097 *pData3 = m_bDat[3];
00098 *pData4 = m_bDat[4];
00099 *pData5 = m_bDat[5];
00100 *pData6 = m_bDat[6];
00101 *pData7 = m_bDat[7];
00102 }
00103
00108 int getAt(int iNr)
00109 {
00110 return m_bDat[iNr];
00111 }
00112
00117 int printCanIdentMsgStatus()
00118 {
00119 if(getStatus() == 0)
00120 {
00121 std::cout << "ID= " << m_iID << " " << "Cmd= " << getCmd() << " " << "Msg_OK" << std::endl;
00122 return 0;
00123 }
00124 else
00125 {
00126 std::cout << "ID= " << m_iID << " " << "Cmd= " << getCmd() << " " << "Msg_Error" << std::endl;
00127 return -1;
00128 }
00129 }
00130
00134 void print()
00135 {
00136 std::cout << std::hex << std::showbase << " id= " << m_iID << " type= " << m_iType <<
00137 " len= " << m_iLen << " msg= " <<
00138 (int)m_bDat[0] << " " << (int)m_bDat[1] << " " << (int)m_bDat[2] << " " << (int)m_bDat[3] << " " <<
00139 (int)m_bDat[4] << " " << (int)m_bDat[5] << " " << (int)m_bDat[6] << " " << (int)m_bDat[7] << std::endl;
00140 }
00141
00145 int getStatus()
00146 {
00147
00148 return (int)(m_bDat[7] & 0x0003);
00149 }
00150
00154 int getCmd()
00155 {
00156 return (m_bDat[7] >> 2);
00157 }
00158 };
00159
00164 class CANTimedMessage
00165 {
00166 public:
00170 double dTimeStamp;
00171
00175 CanMsg *pCanMsg;
00176 };
00177
00178
00179
00180 #endif