Index: sources/canbus/MessageBuilder.cpp =================================================================== diff -u -rfe9459548d7b0f6c1d8cb77c0e23d7a385b48fa2 -r80b8371f1a93481e05302cef6e474db802fda153 --- sources/canbus/MessageBuilder.cpp (.../MessageBuilder.cpp) (revision fe9459548d7b0f6c1d8cb77c0e23d7a385b48fa2) +++ sources/canbus/MessageBuilder.cpp (.../MessageBuilder.cpp) (revision 80b8371f1a93481e05302cef6e474db802fda153) @@ -17,7 +17,6 @@ // Qt // Project -#include "Logger.h" #include "crc.h" #include "format.h" @@ -43,15 +42,15 @@ * \param vFrameList - The list of frames which has been created by vAction and vData to be sent. * \return true on successful to build a frame */ -bool MessageBuilder::buildFrames(Gui::GuiActionType vAction, const QByteArray &vData, FrameList &vFrameList, Sequence vSequence) +bool MessageBuilder::buildFrames(const QByteArray &vData, FrameList &vFrameList, Sequence vSequence) { QByteArray mPayload ; addSyncByte (mPayload); // Sync Byte addSequence (mPayload, vSequence); // adding sequence - if ( ! addActionId (mPayload, vAction ) ) { // MessageID + if ( ! addActionId (mPayload) ) { // MessageID return false; } - if ( ! addData (mPayload, vAction, vData) ) { // Regarding Payload Length, Adding required Data + if ( ! addData (mPayload, vData) ) { // Regarding Payload Length, Adding required Data return false; } addCRC (mPayload); // CRC @@ -103,15 +102,16 @@ * \param vAction - The ActionID of the message which needs to be appended * to the Payload vPayload */ -bool MessageBuilder::addActionId(QByteArray &vPayload, Gui::GuiActionType vAction) +bool MessageBuilder::addActionId(QByteArray &vPayload) { - if (vAction != Gui::GuiActionType::ID_Unknown) { - quint16 mAction = static_cast(vAction); + 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)); + //QString mHexString = Format::toHexString(vAction, false, eLenMessageIDDigits); + //LOG_DEBUG(QString("Incorrect Action ID '%1'").arg(mHexString)); // TODO is this needed? return false; } return true; @@ -125,9 +125,9 @@ * \param vData - The data which is going to be message payload. * \return false if the vData of type QByteArray is not sufficient regarding vAction */ -bool MessageBuilder::addData(QByteArray &vPayload, Gui::GuiActionType vAction, const QByteArray &vData) +bool MessageBuilder::addData(QByteArray &vPayload, const QByteArray &vData) { - quint8 len = payloadLen[vAction]; + quint8 len = 0; // 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,13 +138,14 @@ } } 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; + //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? } vPayload += len; vPayload += vData.mid(0, len); // Adding required Data @@ -228,12 +229,13 @@ quint8 mBeenRead = 0; if ( ! checkCRC(crcData, mExpected, mBeenRead ) ) { // CRC is always next byte after Data static quint64 erCRC = 0; - 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)) - ); + 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? return false; } return true; @@ -258,12 +260,11 @@ vMessage.can_id = vCan_Id; vMessage.head = getHeader (mPayload); // keep header before taking it out of the payload. does not affect payload vMessage.sequence = getSequence (mPayload); - vMessage.actionId = static_cast(getActionId(mPayload)); vMessage.length = getLength (mPayload); 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")); + //LOG_DEBUG(QString("Expected Header, got frame without Sync byte")); // TODO is this needed? printPayload(vPayload, false ,vCan_Id); return false; } @@ -293,9 +294,9 @@ if (_enableConsoleOut == vEnabled) return; _enableConsoleOut = vEnabled; if (_enableConsoleOut) { - LOG_DEBUG("Console out MessageBuilder enabled"); + //LOG_DEBUG("Console out MessageBuilder enabled"); // TODO is this needed? } else { - LOG_DEBUG("Console out MessageBuilder disabled"); + //LOG_DEBUG("Console out MessageBuilder disabled"); // TODO is this needed? } } // disabled coco end @@ -355,7 +356,7 @@ { QByteArray headInfo; if (vPayload.length() < eLenHeaderInfo) { - LOG_DEBUG("Incorrect Message Header"); + //LOG_DEBUG("Incorrect Message Header"); // TODO is this needed? return headInfo; } for (int i = 0; i < eLenHeaderInfo; i++) {