Index: denali.pro =================================================================== diff -u -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- denali.pro (.../denali.pro) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) +++ denali.pro (.../denali.pro) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -1,7 +1,7 @@ QT += widgets qml quick serialbus CONFIG += c++17 warn_on +QMAKE_CXXFLAGS += -Wall -Werror - #CONFIG += disable_crc disable_crc { message( *** IMPORTANT : DISABLED CRC CHECK *** ) Index: main.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- main.cpp (.../main.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ main.cpp (.../main.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -102,7 +102,7 @@ emit _ApplicationController->quit(); }); QObject::connect(_ApplicationController, &ApplicationController::quit, &app, [](int retcode) { - qDebug() << "Application Terminated:" << retcode; + qDebug() << tr("Application Terminated: %1").arg(retcode); _CanInterface->quit(); QCoreApplication::exit(retcode); }, Qt::QueuedConnection); Index: sources/canbus/caninterface.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -71,7 +71,7 @@ /*! * \brief CanInterface connections definition - * \details Initializes the required signal/slot connection between this class and other objects\n + * \details Initializes the required signal/slot connection between this class and other objects * to be able to communicate. */ void CanInterface::initConnections() @@ -128,10 +128,10 @@ } /*! - * \brief CanInterface console Output messaging \n - * \details Sends out formatted CANBUS message to the console \n - * for debugging purposes. \n - * \param vFrame - The CANBUS frame to be sent out \n + * \brief CanInterface console Output messaging + * \details Sends out formatted CANBUS message to the console + * for debugging purposes. + * \param vFrame - The CANBUS frame to be sent out */ void CanInterface::consoleOut(const QCanBusFrame &vFrame) { @@ -209,12 +209,12 @@ } /*! - * \brief CanInterface::onFrameWrittern \n - * \details This is the slot connected to the signal \n - * which is emitted every time a payload of frames \n - * has been written to the CANBUS bus. \n - * \param vFramesCount - The framesCount argument is set to the number of frames \n - * that were written in this payload. \n + * \brief CanInterface::onFrameWrittern + * \details This is the slot connected to the signal + * which is emitted every time a payload of frames + * has been written to the CANBUS bus. + * \param vFramesCount - The framesCount argument is set to the number of frames + * that were written in this payload. */ void CanInterface::onFrameWrittern(qint64 /*vFramesCount*/) { Index: sources/canbus/caninterface.h =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/caninterface.h (.../caninterface.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/caninterface.h (.../caninterface.h) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -31,12 +31,12 @@ /*! * \brief CANBUS interface - * \details This class contains the interface to CANBUS \n - * And utilizes Qt QCanBus to interact with the CANBUS \n - * This class works only with the QCanBusFrame frames. \n - * On the OS side there is a driver installed to convert SPI to CAN \n - * Since the GUI Board by itself doesn't contain the CAN Bus. \n - * Application would know nothing about the SPI-TO-CAN \n + * \details This class contains the interface to CANBUS + * And utilizes Qt QCanBus to interact with the CANBUS + * This class works only with the QCanBusFrame frames. + * On the OS side there is a driver installed to convert SPI to CAN + * Since the GUI Board by itself doesn't contain the CAN Bus. + * Application would know nothing about the SPI-TO-CAN */ class CanInterface : public QObject { Index: sources/canbus/messagebuilder.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -25,47 +25,94 @@ MessageBuilder::MessageBuilder(QObject *parent) : QObject(parent) { } -FrameList MessageBuilder::buildFrames(GuiActionType vAction, const QByteArray &vData) +/*! + * \brief MessageBuilder::buildFrames + * \details This method builds list of frames out of the vActions of type GuiActionType + * and vData of type QByteArray which has been requested to be sent by UI. + * The message will be chopped into 8 bytes frames to be able to be send + * by fixed length CANBUS protocol. + * \param vAction - The ActionID of the requested message. + * \param vData - The payload of the message. + * \param ok - Will be set if any error happens. + * This parameter has been defined as mandatory check + * so it has been passed and checked. + * \return list of frames of type FrameList + */ +bool MessageBuilder::buildFrames(GuiActionType vAction, const QByteArray &vData, FrameList &vFrameList) { - QList mFrames; QByteArray mPayload ; - addSyncByte (mPayload); // SyncByte - addActionId (mPayload, vAction); // Message ID - addData (mPayload, vAction, vData); // Regarding Payload Length, Adding required Data + addSyncByte (mPayload); // Sync Byte + if ( ! addActionId (mPayload, vAction) ) { // MessageID + return false; + } + if ( ! addData (mPayload, vAction, vData) ) { // Regarding Payload Length, Adding required Data + return false; + } addCRC (mPayload); // CRC quint16 len = mPayload.length(); if (len > eLenCanFrame) { quint8 frameCount = len / eLenCanFrame; if (len % eLenCanFrame) ++frameCount; for (quint8 i = 0; i < frameCount; i++) { - mFrames += mPayload.mid(i * eLenCanFrame, eLenCanFrame); + vFrameList += mPayload.mid(i * eLenCanFrame, eLenCanFrame); } } else { - mFrames += mPayload; + vFrameList += mPayload; } - addPadding (mFrames.last()); // Padded to 8 byte frame - return mFrames; + addPadding (vFrameList.last()); // Padded to 8 byte frame + return true; } +/*! + * \brief MessageBuilder::addSyncByte + * \details Adds the sync/start byte at the end of the Payload vPayload of type QByteArray + * \param vPayload - payload which is going to be constructed by appending byte + */ void MessageBuilder::addSyncByte(QByteArray &vPayload) { vPayload.append(ePayload_Sync); // Sync byte } -void MessageBuilder::addActionId(QByteArray &vPayload, GuiActionType vAction) +/*! + * \brief MessageBuilder::addActionId + * \details Adds the sync/start byte at the end of the Payload vPayload of type QByteArray + * \param vPayload - payload which is going to be constructed by appending byte + * \param vAction - The ActionID of the message which needs to be appended + * to the Payload vPayload + */ +bool MessageBuilder::addActionId(QByteArray &vPayload, GuiActionType vAction) { if (vAction != GuiActionType::Unknown) { quint16 mAction = static_cast(vAction); vPayload += (mAction >> 8) & 0xFF;//high byte vPayload += mAction & 0xFF;// low byte + } else { + QString mHexString = Format::toHexString(vAction, false, 3); + qDebug() << "ERROR :" << tr("Not enough data has been provided for the Message ID '%1'").arg(mHexString); + return false; } + return true; } -void MessageBuilder::addData(QByteArray &vPayload, GuiActionType vAction, const QByteArray &vData) +/*! + * \brief MessageBuilder::addData + * \details Regarding ActionID appends correct bytes amount of vData to the vPayload + * \param vPayload - payload which is going to be constructed by appending byte + * \param vAction - The ActionID of the message which needs to be appended + * \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, GuiActionType vAction, const QByteArray &vData) { quint8 len = payloadLen[vAction]; + if (vData.length() < len) { + QString mHexString = Format::toHexString(vAction, false, 3); + qDebug() << "ERROR :" << tr("Not enough data has been provided for the Message ID '%1'").arg(mHexString); + qDebug() << vData.toHex('.'); + return false; + } // 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) { @@ -77,47 +124,82 @@ } vPayload += len; vPayload += vData.mid(0, len); // Adding required Data + return true; } +/*! + * \brief MessageBuilder::addCRC + * \details Appends calculated crc8 (1 byte) of the vPayload at the end of the vPayload + * \param vPayload - The Payload which is going to be used for crc8 calculation + * \note The first byte will be excluded and is not part of the crc8 calculation. + * Since the first byte is the Sync and has always constant value of A5. + * SW/FW agreement. + */ void MessageBuilder::addCRC(QByteArray &vPayload) { - // sync byte should not be passed for crc calculation + // sync byte should not be Used for crc calculation vPayload += calcCRC(vPayload.mid(1)); } +/*! + * \brief MessageBuilder::addPadding + * \details This method is appending bytes containing 0x00 + * to keep the length of the frame 8 bytes. + * \param vPayload - The payload of the CANBUS message + */ void MessageBuilder::addPadding(QByteArray &vPayload) { vPayload = vPayload.leftJustified(eLenCanFrame, '\0'); } -// TODO : This section better to be in the MessageModel +/*! + * \brief MessageBuilder::calcCRC + * \details Calculates the crc8 + * \param vData - The data of type QByteArray to be used for crc8 calculation. + * \return returns a byte contains crc8 + */ quint8 MessageBuilder::calcCRC(const QByteArray &vData) +// TODO : This section better to be in the MessageModel { quint8 crc = crc8(vData); return crc; } // CRC is always next byte after Data +/*! + * \brief MessageBuilder::checkCRC + * \details This method checks the crc8 of the vData of type QByteArray + * by using the last byte as the crc8 of the rest of the data + * \param vData - The data of type QByteArray to be used for crc8 calculation. + * \return returns false if the crc8 is not correct or the data is empty. + */ +bool MessageBuilder::checkCRC(const QByteArray &vData, quint8 &vExpected, quint8 &vBeenRead) // TODO : This section better to be in the MessageModel -bool MessageBuilder::checkCRC(const QByteArray &vData) { #ifndef DISABLE_CRC int len = vData.length(); if ( ! len ) return false; - quint8 crc = vData.back(); - quint8 got = calcCRC(vData.mid(0, len - 1)); - bool ok = got == crc; + vBeenRead = vData.back(); + vExpected = calcCRC(vData.mid(0, len - 1)); + bool ok = vExpected == vBeenRead; // it's very good but I'm not sure if it's correct. //bool ok = calcCRC(vData) == 0; - if ( ! ok ) { - qDebug() << "ch crc :" << hex << got << crc << vData.toHex('.'); - } return ok; #else return true; #endif } +/*! + * \brief MessageBuilder::buildMessage + * \details Builds Message out of vPayload of type QByteArray + * by adding Sync byte, ActionID(MessageID), data length, data, CANBUS channel id for header + * and keeps collecting data from payload up until the specified length. + * \param vPayload - The payload of the CANBUS message + * \param vMessage - The Message variable which is going to be built + * \param vCan_Id - The CANBUS frame channel id + * \return false if the payload doesn't contain sync byte (Payload_Data::ePayload_Sync) + */ bool MessageBuilder::buildMessage(const QByteArray &vPayload, Message &vMessage, Can_Id vCan_Id) { QByteArray mPayload = vPayload; @@ -131,8 +213,8 @@ vMessage.data = getData (mPayload, vMessage.length); vMessage.initialized = true; } else { // Expected Header but got pure data - printPayload(vPayload, false ,vCan_Id); qDebug() << "ERROR :" << tr("Expected Header, got frame without Sync byte"); + printPayload(vPayload, false ,vCan_Id); return false; } } else { @@ -146,15 +228,28 @@ if (vMessage.isComplete()) { consoleOut("", false, Can_Id::eChlid_NONE); QByteArray crcData = vMessage.head + vMessage.data; - if ( ! checkCRC(crcData) ) { // CRC is always next byte after Data - qDebug() << "ERROR :" << tr("CRC error"); + quint8 mExpected = 0; + quint8 mBeenRead = 0; + if ( ! checkCRC(crcData, mExpected, mBeenRead ) ) { // CRC is always next byte after Data + qDebug() << "ERROR :" << tr("CRC error, expected %1 but got %2") + .arg(Format::toHexString(mExpected, true, 2)) + .arg(Format::toHexString(mBeenRead, true, 2)); return false; } } return true; } +/*! + * \brief MessageBuilder::hasSyncByte + * \details Checks for Sync byte and take it out of vPayload + * \param vPayload - The payload of type QByteArray + * \return true if the first byte of the vPayload is sync byte + * (Payload_Data::ePayload_Sync) + * \note Removes the first 1 byte of sync byte from vPayload + * It starts from the first byte. + */ bool MessageBuilder::hasSyncByte(QByteArray &vPayload) { quint8 mSyncByte = vPayload[0]; @@ -165,6 +260,20 @@ return false; } +/*! + * \brief MessageBuilder::getHeader + * \details Collect the 3 bytes (Frame_Data::eLenHeaderInfo) + * as header portion of the payload + * which is the MessageID (2 bytes) , data length (1 byte) + * It doesn't contain sync byte (Payload_Data::ePayload_Sync) + * as this value will be used for crc8 calculation + * and that doesn't include sync byte (Payload_Data::ePayload_Sync) + * \param vPayload - The payload of the CANBUS message + * \return Returns 3 byte of header data of type QByteArray + * \note As it's obvious from the function parameter it's not changing the vPayload + * Just has been mentioned to be consistent with the other methods of buildMessage. + * It starts from the first byte so the vPayload should not have the sync byte. + */ QByteArray MessageBuilder::getHeader(const QByteArray &vPayload) { QByteArray headInfo; @@ -174,18 +283,41 @@ return headInfo; } +/*! + * \brief MessageBuilder::getActionId + * \details Extracts the 2 bytes ActionID (Frame_Data::eLenActionId) + * out of the vPayload of type QByteArray + * \param vPayload - The payload of the CANBUS message + * \return Returns ActionId of type GuiActionType + * \note Removes the 2 bytes of ActionID from vPayload + * It starts from the first byte so those 2 bytes should be the first 2 bytes. + */ GuiActionType MessageBuilder::getActionId(QByteArray &vPayload) { quint16 mActionId; mActionId = (vPayload[0] << 8) | vPayload[1]; - //TODO : It needs to be checked that the Action ID is Correct. + //TODO : It needs to be checked that the ActionID is Correct. //return GuiActionType::Unknown; vPayload = vPayload.mid(eLenActionId); return static_cast(mActionId); } +/*! + * \brief MessageBuilder::getLength + * \details Extracts the 1 byte data length out of the vPayload + * and removes the first 1 byte + * \param vPayload - The payload of the CANBUS message + * \return returns the length of the data which is added by 1 to include 1 byte crc + * \note the length of the data should not be more than 255 which requires 1 byte only + * so technically it doesn't need to return a value of type more than 1 byte + * But some room reserved for later huge buffer passing + * And also as 1 byte crc8 is included as part of data + * it make it 256 which is going to be more than a byte. + * \note Removes the 1 byte of data length from vPayload + * It starts from the first byte so that byte should be the first 1 byte. + */ int MessageBuilder::getLength(QByteArray &vPayload) { // on the line bellow it has to be cast to unsigned otherwise FF will be converted to -1 and + 1 becomes 0. @@ -194,7 +326,17 @@ return mlen; } -QByteArray MessageBuilder::getData(QByteArray &vPayload, int vLen) +/*! + * \brief MessageBuilder::getData + * \details Extract data from vPayload + * if vLen is less or equal to Frame_Data::eLenMaxHeaderData + * it gets data of first byte up to the len of vLen + * otherwise returns the whole vPayload as the data + * \param vPayload - The payload of the CANBUS message + * \param vLen - the length of the data + * \return The data to be returned + */ +QByteArray MessageBuilder::getData(const QByteArray &vPayload, int vLen) { QByteArray mData; if (vLen <= eLenMaxHeaderData) { @@ -205,6 +347,19 @@ return mData; } +/*! + * \brief MessageBuilder::printPayload + * \details Sends out formatted message to the console + * for debugging purposes. + * Since this method is only formatting the payload + * and doesn't extract the content of the payload + * it gets required information from outside through it's parameters. + * \param vPayload - The payload of the CANBUS message + * \param vIsHeader - Should be sent as true if this payload contains header data + * \param vCan_Id - CANBUS channel id + * \param vUseColor - Use coloring or just space formatted output + * if vUseColor passed true is uses different color for Sync byte, MessageID & data + */ void MessageBuilder::printPayload(const QByteArray &vPayload, bool vIsHeader, Can_Id vCan_Id, bool vUseColor) { if (vCan_Id == Can_Id::eChlid_NONE) { @@ -238,9 +393,15 @@ } } +/*! + * \brief MessageBuilder::consoleOut + * \details An overloaded method of the MessageBuilder::printPayload + * which is only printPayload if the console output is enabled + * by setting MessageBuilder::enableConsoleOut + * \note please refer to MessageBuilder::printPayload + */ void MessageBuilder::consoleOut(const QByteArray &vPayload, bool vIsHeader, Can_Id vCan_Id, bool vUseColor) { if ( ! _enableConsoleOut) return; printPayload(vPayload, vIsHeader, vCan_Id, vUseColor); - } Index: sources/canbus/messagebuilder.h =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messagebuilder.h (.../messagebuilder.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messagebuilder.h (.../messagebuilder.h) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -53,19 +53,19 @@ bool _enableConsoleOut = false; void addSyncByte ( QByteArray &vPayload); - void addActionId ( QByteArray &vPayload, GuiActionType vAction); - void addData ( QByteArray &vPayload, GuiActionType vAction, const QByteArray &vData); + bool addActionId ( QByteArray &vPayload, GuiActionType vAction) __attribute_warn_unused_result__; + bool addData ( QByteArray &vPayload, GuiActionType vAction, const QByteArray &vData) __attribute_warn_unused_result__; void addCRC ( QByteArray &vPayload); void addPadding ( QByteArray &vPayload); - quint8 calcCRC (const QByteArray &vData); - bool checkCRC (const QByteArray &vData); + quint8 calcCRC (const QByteArray &vData ); + bool checkCRC (const QByteArray &vData , quint8 &vExpected, quint8 &vBeenRead); bool hasSyncByte ( QByteArray &vPayload); QByteArray getHeader (const QByteArray &vPayload); GuiActionType getActionId ( QByteArray &vPayload); int getLength ( QByteArray &vPayload); - QByteArray getData ( QByteArray &vPayload, int vLen); + QByteArray getData (const QByteArray &vPayload, int vLen); void printPayload(const QByteArray &vPayload, bool vIsHeader, Can_Id vCan_Id, bool vUseColor = true); void consoleOut (const QByteArray &vPayload, bool vIsHeader, Can_Id vCan_Id, bool vUseColor = true); @@ -74,9 +74,9 @@ explicit MessageBuilder(QObject *parent = nullptr); // build message to be sent frame by frame - FrameList buildFrames ( GuiActionType vAction , const QByteArray &vData); + bool buildFrames(GuiActionType vAction , const QByteArray &vData, FrameList &vFrameList) __attribute_warn_unused_result__; // build message from received frames - bool buildMessage (const QByteArray &vPayload, Message &vMessage, Can_Id vCan_Id); + bool buildMessage(const QByteArray &vPayload, Message &vMessage, Can_Id vCan_Id) __attribute_warn_unused_result__; void enableConsoleOut( bool vEnabled) { _enableConsoleOut = vEnabled; } Index: sources/canbus/messagedispatcher.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -102,11 +102,15 @@ { QByteArray mData; if (! _interpreter.interpretMessage(vActionId, vData, mData)) { - qDebug() << "Error :" << "Incorrect Message"; + qDebug() << "Error :" << tr("Incorrect Message can't be interpreted"); return; } - FrameList frameList = _builder.buildFrames(vActionId, mData); + FrameList frameList; + if ( ! _builder.buildFrames(vActionId, mData, frameList) ) { + qDebug() << "Error :" << tr("Incorrect Message can't be built"); + return; + } for (const auto &frame : frameList) { emit didFrameTransmit(eChlid_UI, frame); } Index: sources/canbus/messagedispatcher.h =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -108,7 +108,7 @@ // An Action has been requested to be transmitted. void onActionTransmit(GuiActionType vActionId, const QVariantList &vData); - void onMainTimerTimeout(); + void onMainTimerTimeout(); }; } Index: sources/canbus/messageglobals.h =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -23,8 +23,9 @@ namespace Can { /*! - * \brief Payload Length - * \details List of each action acceptable data length in the whole message packet. + * \brief Payload Length + * \details List of each ActionID required data (in byte) length in the message. + * So the data collector has to collect this amount of bytes as payload of a message. */ const QHash payloadLen { {GuiActionType::PowerOff , 1}, @@ -34,7 +35,7 @@ }; /*! - * \brief The Payload_Data enum + * \brief The Payload_Data enum * \details Global information for message packet. */ enum Payload_Data : quint8 { @@ -43,7 +44,7 @@ }; /*! - * \brief The Frame_Data enum + * \brief The Frame_Data enum * \details Global information for each message frame. */ enum Frame_Data : quint8 { @@ -53,13 +54,13 @@ eLenMaxData = 255, ///< Maximum data length in a Can Message since data length value kept in one byte eLenSyncByte = 1, ///< The length of Sync byte at the beginning of each header frame - eLenActionId = 2, ///< The length of Message ID bytes (2) at the beginning of each header frame after sync - eLenLength = 1, ///< The length of data length value byte at the beginning of each header frame after Message ID + eLenActionId = 2, ///< The length of MessageID bytes (2) at the beginning of each header frame after sync + eLenLength = 1, ///< The length of data length value byte at the beginning of each header frame after MessageID }; /*! - * \brief The Can_Id enum - * \details The Valid Can Bus Message Id of each frame + * \brief The Can_Id enum + * \details The Valid Can Bus MessageID of each frame */ enum Can_Id : quint16 { eChlid_NONE = 0x000, @@ -87,8 +88,8 @@ }; /*! - * \brief The Message struct - * \details The message structure after it's been glued together. + * \brief The Message struct + * \details The message structure after it's been converted form hex bytes to meaningful struct for UI. */ struct Message { // TODO : Should be converted to MessageModel class // no time left for now !!! Can_Id can_id; Index: sources/canbus/messagehandler.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messagehandler.cpp (.../messagehandler.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messagehandler.cpp (.../messagehandler.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -45,7 +45,7 @@ /*! * \brief MessageHandler connections definition - * \details Initializes the required signal/slot connection between this class and other objects\n + * \details Initializes the required signal/slot connection between this class and other objects * to be able to communicate. */ void MessageHandler::initConnections() @@ -60,14 +60,14 @@ } /*! - * \brief MessageHandler::transmitFrame \n - * \details Prepares a frame to be transmitted \n - * and emit signal didFrameTransmit with the frame as its argument \n - * \param vFrameId - Channel id of the CANBUS frame \n - * \param vData - The Data this frame is going to carry \n - * \note This frame is created by MessageBuilder \n - * and it can be one of the frames of a message \n - * which has been chopped into frames. \n + * \brief MessageHandler::transmitFrame + * \details Prepares a frame to be transmitted + * and emit signal didFrameTransmit with the frame as its argument + * \param vFrameId - Channel id of the CANBUS frame + * \param vData - The Data this frame is going to carry + * \note This frame is created by MessageBuilder + * and it can be one of the frames of a message + * which has been chopped into frames. */ void MessageHandler::transmitFrame(Can_Id vFrameId, const QByteArray &vData) { @@ -82,14 +82,14 @@ } /*! - * \brief MessageHandler::checkChannel \n - * \details Checks for the channel id of the received frame \n - * which needs to be handled or ignored. \n - * \param vFrameId - Channel id of the frame \n - * \param vOK - will be set to true if the channel \n - * is valid and a variable has been passed to \n - * \return The Category if the channels from the UI \n - * perspective \ref MessageHandler::ChannelGroup \n + * \brief MessageHandler::checkChannel + * \details Checks for the channel id of the received frame + * which needs to be handled or ignored. + * \param vFrameId - Channel id of the frame + * \param vOK - will be set to true if the channel + * is valid and a variable has been passed to + * \return The Category if the channels from the UI + * perspective MessageHandler::ChannelGroup */ MessageHandler::ChannelGroup MessageHandler::checkChannel(quint32 vFrameId, bool *vOK) { @@ -127,12 +127,12 @@ } /*! - * \brief MessageHandler::onFrameTransmit \n - * \details This the slot connected to the MessageDispatcher didFrameTransmit signal. \n - * When a frame needs to be send to CANBUS, \n - * this slot will call transmitFrame method to do the job. \n - * \param vCan_ID - CANBUS Can Id target of the frame. \n - * \param vData - The data which this frame will carry. \n + * \brief MessageHandler::onFrameTransmit + * \details This the slot connected to the MessageDispatcher didFrameTransmit signal. + * When a frame needs to be send to CANBUS, + * this slot will call transmitFrame method to do the job. + * \param vCan_ID - CANBUS Can Id target of the frame. + * \param vData - The data which this frame will carry. */ void MessageHandler::onFrameTransmit(Can_Id vCan_ID, const QByteArray &vData) { @@ -141,10 +141,10 @@ /*! * \brief MessageHandler::onFrameReceive - * \details This the slot connected to the CanInterface didFrameReceive signal. \n - * When a frame received over the CANBUS, \n - * this slot will be called to check the channel if should be listened to. \n - * and will emit didFrameReceive if should be handled and ignored otherwise. \n + * \details This the slot connected to the CanInterface didFrameReceive signal. + * When a frame received over the CANBUS, + * this slot will be called to check the channel if should be listened to. + * and will emit didFrameReceive if should be handled and ignored otherwise. * \param vFrame - The frame has to be sent */ void MessageHandler::onFrameReceive(const QCanBusFrame &vFrame) Index: sources/canbus/messagehandler.h =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messagehandler.h (.../messagehandler.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messagehandler.h (.../messagehandler.h) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -35,10 +35,10 @@ namespace Can { /*! - * \brief The MessageHandler class \n - * \details This class is an adapter or translator from QByteArray and QCanBusFrame \n - * So this class gets the data for the frame as QByteArray and creates a frame \n - * and send it to the CanInterface to deal with the CANBUS. \n + * \brief The MessageHandler class + * \details This class is an adapter or translator from QByteArray and QCanBusFrame + * So this class gets the data for the frame as QByteArray and creates a frame + * and send it to the CanInterface to deal with the CANBUS. */ class MessageHandler : public QObject { Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -28,16 +28,16 @@ MessageInterpreter::MessageInterpreter(QObject *parent) : QObject(parent) { } /*! - * \brief MessageInterpreter::interpretMessage \n - * \details This method will be called \n - * to interpret messages from UI regarding vActionId. \n - * \param vActionId - The Action Id of type GuiActionType \n - * to be interpreted to hex representation of Message ID. \n - * \param vData - The data which has to be sent over the CANBUS. \n - * \param vPayload - The Payload of the frame of Type QByteArray of hex values \n - * Which has been interpreted from vData of Type QVariantList \n - * \return true if the vActionId is valid. \n - * This return value will be used later for error handling. \n + * \brief MessageInterpreter::interpretMessage + * \details This method will be called + * to interpret messages from UI regarding vActionId. + * \param vActionId - The ActionID of type GuiActionType + * to be interpreted to hex representation of Message ID. + * \param vData - The data which has to be sent over the CANBUS. + * \param vPayload - The Payload of the frame of Type QByteArray of hex values + * Which has been interpreted from vData of Type QVariantList + * \return true if the vActionId is valid. + * This return value will be used later for error handling. */ bool MessageInterpreter::interpretMessage(const GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) { @@ -77,17 +77,17 @@ } /*! - * \brief MessageInterpreter::interpretMessage \n - * \details This method will call appropriate message interpreter \n - * for received messages from HD or DG regarding the Can_Id. \n - * \param vCan_Id - The Channel Id of the CANBUS frame. \n - * \param vMessage - The complete message of type Message which needs to be interpreted. \n - * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. \n - * \param vData - The values of QVariantList which is understandable for UI \n - * and has been extracted from hex values of the CANBUS Message Payload \n - * regarding each Message Id definition. \n - * \return true if the message channel is in the range which can be interpreted, false otherwise. \n - * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not \n + * \brief MessageInterpreter::interpretMessage + * \details This method will call appropriate message interpreter + * for received messages from HD or DG regarding the Can_Id. + * \param vCan_Id - The Channel Id of the CANBUS frame. + * \param vMessage - The complete message of type Message which needs to be interpreted. + * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. + * \param vData - The values of QVariantList which is understandable for UI + * and has been extracted from hex values of the CANBUS Message Payload + * regarding each Message Id definition. + * \return true if the message channel is in the range which can be interpreted, false otherwise. + * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not */ bool MessageInterpreter::interpretMessage(const Can_Id vCan_Id, const Message &vMessage, GuiActionType &vActionId, QVariantList &vData) { @@ -104,17 +104,17 @@ } /*! - * \brief MessageInterpreter::interpretMessage_HD \n - * \details This method will be called \n - * for received messages from HD to interpret the vMessage of type Message \n - * to vData of type QVariantList which UI understands regarding the Can_Id. \n - * \param vMessage - The complete message of type Message which needs to be interpreted. \n - * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. \n - * \param vData - The values of QVariantList which is understandable for UI \n - * and has been extracted from hex values of the CANBUS Message Payload \n - * in vMessage of type Message regarding each Message Id definition. \n - * \return true if the message CANBUS channel is in the range which can be interpreted, false otherwise. \n - * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not \n + * \brief MessageInterpreter::interpretMessage_HD + * \details This method will be called + * for received messages from HD to interpret the vMessage of type Message + * to vData of type QVariantList which UI understands regarding the Can_Id. + * \param vMessage - The complete message of type Message which needs to be interpreted. + * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. + * \param vData - The values of QVariantList which is understandable for UI + * and has been extracted from hex values of the CANBUS Message Payload + * in vMessage of type Message regarding each Message Id definition. + * \return true if the message CANBUS channel is in the range which can be interpreted, false otherwise. + * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not */ bool MessageInterpreter::interpretMessage_HD(const Message &vMessage, GuiActionType &vActionId, QVariantList &vData) { @@ -171,17 +171,17 @@ } /*! - * \brief MessageInterpreter::interpretMessage_DG \n - * \details This method will be called \n - * for received messages from DG to interpret the vMessage of type Message \n - * to vData of type QVariantList which UI understands regarding the Can_Id. \n - * \param vMessage - The complete message of type Message which needs to be interpreted. \n - * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. \n - * \param vData - The values of QVariantList which is understandable for UI \n - * and has been extracted from hex values of the CANBUS Message Payload \n - * in vMessage of type Message regarding each Message Id definition. \n - * \return true if the message CANBUS channel is in the range which can be interpreted, false otherwise. \n - * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not \n + * \brief MessageInterpreter::interpretMessage_DG + * \details This method will be called + * for received messages from DG to interpret the vMessage of type Message + * to vData of type QVariantList which UI understands regarding the Can_Id. + * \param vMessage - The complete message of type Message which needs to be interpreted. + * \param vActionId - The ActionId of GuiActionType which will be extracted from vMessage. + * \param vData - The values of QVariantList which is understandable for UI + * and has been extracted from hex values of the CANBUS Message Payload + * in vMessage of type Message regarding each Message Id definition. + * \return true if the message CANBUS channel is in the range which can be interpreted, false otherwise. + * This return value will be used later to emit MessageDispatcher::didActionReceive signal or not */ bool MessageInterpreter::interpretMessage_DG(const Message &vMessage, GuiActionType &vActionId, QVariantList &vData) { @@ -271,14 +271,14 @@ } /*! - * \brief MessageInterpreter::getPowerOffData \n - * \details This is the method which interprets the PowerOff message data \n - * in vMessage of type Message. \n - * to its elements of data. \n - * \param vMessage - The vMessage of type Message which contains all the data, \n - * require to be interpreted. \n - * \param vShowHide - The return value of extracted fro \n - * \return true if the data can be extracted as defined for PowerOff Message ID \n + * \brief MessageInterpreter::getPowerOffData + * \details This is the method which interprets the PowerOff message data + * in vMessage of type Message. + * to its elements of data. + * \param vMessage - The vMessage of type Message which contains all the data, + * require to be interpreted. + * \param vShowHide - The return value of extracted fro + * \return true if the data can be extracted as defined for PowerOff Message ID */ bool MessageInterpreter::getPowerOffData(const Message &vMessage, quint8 &vShowHide) { @@ -297,11 +297,11 @@ } /*! - * \brief MessageInterpreter::printUnhandled \n - * \details Prints out the formatted string of the vMessage of type Message \n - * In case the Message ID of received CANBUS message \n - * is known to the interpreter but has not been handled/implemented. \n - * \param vMessage - The message contains Unhandled Message ID \n + * \brief MessageInterpreter::printUnhandled + * \details Prints out the formatted string of the vMessage of type Message + * In case the Message ID of received CANBUS message + * is known to the interpreter but has not been handled/implemented. + * \param vMessage - The message contains Unhandled Message ID */ void MessageInterpreter::printUnhandled(const Message &vMessage) { Index: sources/canbus/messageinterpreter.h =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -35,21 +35,22 @@ { Q_OBJECT - bool interpretMessage_HD(const Message &vMessage, GuiActionType &vActionId, QVariantList &vData); - bool interpretMessage_DG(const Message &vMessage, GuiActionType &vActionId, QVariantList &vData); + bool interpretMessage_HD(const Message &vMessage, GuiActionType &vActionId, QVariantList &vData) __attribute_warn_unused_result__; + bool interpretMessage_DG(const Message &vMessage, GuiActionType &vActionId, QVariantList &vData) __attribute_warn_unused_result__; bool getBloodFlowData (const Message &vMessage, types::U32 &vFlowSetPoint, - types::F32 &vMeasuredFlow, types::F32 &vRotorSpeed, types::F32 &vMotorSpeed, types::F32 &vMotorCtlSpeed, types::F32 &vMotorCtlCurrent ); - bool getPowerOffData (const Message &vMessage, quint8 &vShowHide); + types::F32 &vMeasuredFlow, types::F32 &vRotorSpeed, types::F32 &vMotorSpeed, + types::F32 &vMotorCtlSpeed, types::F32 &vMotorCtlCurrent ) __attribute_warn_unused_result__; + bool getPowerOffData (const Message &vMessage, quint8 &vShowHide) __attribute_warn_unused_result__; void printUnhandled (const Message &vMessage); public: explicit MessageInterpreter(QObject *parent = nullptr); // interpret the data into GUI understandable Actions/Data - bool interpretMessage(const Can_Id vCan_Id, const Message &vMessage, GuiActionType &vActionId, QVariantList &vData); - bool interpretMessage(const GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload); + bool interpretMessage(const Can_Id vCan_Id, const Message &vMessage, GuiActionType &vActionId, QVariantList &vData) __attribute_warn_unused_result__; + bool interpretMessage(const GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) __attribute_warn_unused_result__; signals: Index: sources/gui/guiglobals.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -58,7 +58,7 @@ _viewer->show(); } else if (vStatus == QQuickView::Error || vStatus == QQuickView::Null) { - // qDebug() << "Application Terminated:" << _viewer->errors(); + qDebug() << "ERROR :" << tr("Application Terminated: %1").arg(_viewer->errors()); QCoreApplication::exit(-1); } Index: sources/utility/format.cpp =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 --- sources/utility/format.cpp (.../format.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/utility/format.cpp (.../format.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) @@ -20,9 +20,9 @@ QString Format::toHexString(quint16 vValue, bool vWith0x, quint8 vLen) { if ( vWith0x ) { - return "0x" + QString("%1").arg(vValue,0,16).rightJustified(vLen, '0'); + return "0x" + QString("%1").arg(vValue,0,16).rightJustified(vLen, '0').toUpper(); } else { - return QString("%1").arg(vValue,0,16).rightJustified(vLen, '0'); + return QString("%1").arg(vValue,0,16).rightJustified(vLen, '0').toUpper(); } }