Index: sources/canbus/MessageBuilder.cpp =================================================================== diff -u -rf91ee3bac4f77fc7a0fe8d122c8c49b34b6984ec -rc0b30f1fa82d0121706351057ab52b3bb1141459 --- sources/canbus/MessageBuilder.cpp (.../MessageBuilder.cpp) (revision f91ee3bac4f77fc7a0fe8d122c8c49b34b6984ec) +++ sources/canbus/MessageBuilder.cpp (.../MessageBuilder.cpp) (revision c0b30f1fa82d0121706351057ab52b3bb1141459) @@ -17,6 +17,7 @@ // Qt // Project +#include "Logger.h" #include "crc.h" #include "format.h" @@ -47,7 +48,7 @@ QByteArray mPayload ; addSyncByte (mPayload); // Sync Byte addSequence (mPayload, vSequence); // adding sequence - if ( ! addActionId (mPayload) ) { // MessageID + if ( ! addActionId (mPayload ) ) { // MessageID return false; } if ( ! addData (mPayload, vData) ) { // Regarding Payload Length, Adding required Data @@ -104,16 +105,7 @@ */ bool MessageBuilder::addActionId(QByteArray &vPayload) { - if ( false ) { - //if (vAction != Gui::GuiActionType::ID_Unknown) { // TODO is this needed? - quint16 mAction = static_cast(0); - vPayload += (mAction >> 8) & 0xFF; // high byte - vPayload += mAction & 0xFF; // low byte - } else { - //QString mHexString = Format::toHexString(vAction, false, eLenMessageIDDigits); - //LOG_DEBUG(QString("Incorrect Action ID '%1'").arg(mHexString)); // TODO is this needed? - return false; - } + Q_UNUSED(vPayload); return true; } @@ -127,7 +119,8 @@ */ bool MessageBuilder::addData(QByteArray &vPayload, const QByteArray &vData) { - quint8 len = 0; + quint8 vAction = 0; + quint8 len = 0; //payloadLen[vAction]; // if len has been set to max(255) // it means it has no limit and can be as long as 255 bytes if (len == eLenMaxData) { @@ -138,14 +131,13 @@ } } if (vData.length() < len) { - //QString mHexMIdString = Format::toHexString(vAction, false, eLenMessageIDDigits); - //QString mHexDatString = vData.toHex('.').toUpper(); - //LOG_DEBUG(QString("Not enough data has been provided for the Message ID '%1'\r\n%2") - // .arg(mHexMIdString) - // .arg(mHexDatString) - // ); - //return false; - // TODO is this needed? + QString mHexMIdString = Format::toHexString(vAction, false, eLenMessageIDDigits); + QString mHexDatString = vData.toHex('.').toUpper(); + LOG_DEBUG(QString("Not enough data has been provided for the Message ID '%1'\r\n%2") + .arg(mHexMIdString) + .arg(mHexDatString) + ); + return false; } vPayload += len; vPayload += vData.mid(0, len); // Adding required Data @@ -229,13 +221,12 @@ quint8 mBeenRead = 0; if ( ! checkCRC(crcData, mExpected, mBeenRead ) ) { // CRC is always next byte after Data static quint64 erCRC = 0; - Q_UNUSED(erCRC); - //LOG_DEBUG(QString("%1 - CRC error, expected %2 but got %3 : %4") - // .arg(++erCRC) - // .arg(Format::toHexString(mExpected, true, eLenCRCDigits)) - // .arg(Format::toHexString(mBeenRead, true, eLenCRCDigits)) - // .arg(Format::toHexString(vMessage.data)) - // ); // TODO is this needed? + LOG_DEBUG(QString("%1 - CRC error, expected %2 but got %3 : %4") + .arg(++erCRC) + .arg(Format::toHexString(mExpected, true, eLenCRCDigits)) + .arg(Format::toHexString(mBeenRead, true, eLenCRCDigits)) + .arg(Format::toHexString(vMessage.data)) + ); return false; } return true; @@ -265,7 +256,7 @@ vMessage.data = getData (mPayload, vMessage.length); vMessage.initialized = true; } else { // Expected Header but got pure data - //LOG_DEBUG(QString("Expected Header, got frame without Sync byte")); // TODO is this needed? + LOG_DEBUG(QString("Expected Header, got frame without Sync byte")); printPayload(vPayload, false ,vCan_Id); return false; } @@ -295,9 +286,9 @@ if (_enableConsoleOut == vEnabled) return; _enableConsoleOut = vEnabled; if (_enableConsoleOut) { - //LOG_DEBUG("Console out MessageBuilder enabled"); // TODO is this needed? + LOG_DEBUG("Console out MessageBuilder enabled"); } else { - //LOG_DEBUG("Console out MessageBuilder disabled"); // TODO is this needed? + LOG_DEBUG("Console out MessageBuilder disabled"); } } // disabled coco end @@ -357,7 +348,7 @@ { QByteArray headInfo; if (vPayload.length() < eLenHeaderInfo) { - //LOG_DEBUG("Incorrect Message Header"); // TODO is this needed? + LOG_DEBUG("Incorrect Message Header"); return headInfo; } for (int i = 0; i < eLenHeaderInfo; i++) {