Développement CAN Watchdog
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "CANMessage.h"
|
||||
#include "defines.h"
|
||||
#include <QtEndian>
|
||||
|
||||
CCANMessage::CCANMessage():
|
||||
mPendingData(false)
|
||||
@@ -97,6 +98,34 @@ int CCANMessage::UpdateValue(CCANMessage *NewDeviceMessage)
|
||||
|
||||
}
|
||||
|
||||
//This function should be used to set the raw data to send over CAN
|
||||
//It will do the byte swapping crap and fill the data array
|
||||
int CCANMessage::SetRawData(quint64 RawData, int Encoding)
|
||||
{
|
||||
if(Encoding != CCANSignal::CAN_SIGNAL_ENCODING_INTEL)
|
||||
{
|
||||
//MOTOROLA encoding not supported for now...
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mCANRawDataIntel = qToLittleEndian(RawData);
|
||||
// mCANRawDataIntel = RawData;
|
||||
|
||||
|
||||
for(unsigned int i = 0; i < mCANMsgLength; i++)
|
||||
{
|
||||
unsigned char byte;
|
||||
byte = (unsigned char)((mCANRawDataIntel >> (i*8)) & 0xFF);
|
||||
mCANMsgData[i] = byte;
|
||||
}
|
||||
}
|
||||
|
||||
quint64 CCANMessage::GetRawData()
|
||||
{
|
||||
// return qFromBigEndian(mCANRawDataIntel);
|
||||
return mCANRawDataIntel;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CCANMessage &source)
|
||||
{
|
||||
out << source.mCANChannel
|
||||
|
||||
Reference in New Issue
Block a user