Développement CAN Watchdog

This commit is contained in:
2024-03-01 14:43:12 -05:00
parent 0ee7ece650
commit 56b30216c9
16 changed files with 2480 additions and 531 deletions
+29
View File
@@ -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