Index: sources/canbus/FrameInterface.cpp =================================================================== diff -u -r97d593e2e7adb36f2f9f97f9bb9958dcef740bc1 -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/canbus/FrameInterface.cpp (.../FrameInterface.cpp) (revision 97d593e2e7adb36f2f9f97f9bb9958dcef740bc1) +++ sources/canbus/FrameInterface.cpp (.../FrameInterface.cpp) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * - * \file FrameInterface.cpp - * \author (last) Behrouz NematiPour - * \date (last) 26-Aug-2020 - * \author (original) Behrouz NematiPour - * \date (original) 26-Aug-2020 + * \file FrameInterface.cpp + * \author (last) Behrouz NematiPour + * \date (last) 30-Jul-2023 + * \author (original) Behrouz NematiPour + * \date (original) 26-Aug-2020 * */ #include "FrameInterface.h" @@ -47,7 +47,7 @@ startTimer(1, Qt::PreciseTimer); - LOG_DEBUG("UI," + tr("%1 Initialized").arg(metaObject()->className())); + LOG_DEBUG(tr("%1 Initialized").arg(metaObject()->className())); return true; } @@ -74,11 +74,11 @@ */ void FrameInterface::quit() { - // coco begin validated: Application termination is not correctly done in coco!!! + // disabled coco begin validated: Application termination is not correctly done in coco!!! // it has been tested and works perfectly fine in normal run. quitThread(); // validated } -// coco end +// disabled coco end /*! * \brief FrameInterface connections definition @@ -118,26 +118,26 @@ /*! * \brief FrameInterface::quitThread - * \details Moves this object to main thread to be handled by QApplicaiton + * \details Moves this object to main thread to be handled by QApplication * And to be destroyed there. */ void FrameInterface::quitThread() { - // coco begin validated: Application termination is not correctly done in coco!!! + // disabled coco begin validated: Application termination is not correctly done in coco!!! // it has been tested and works perfectly fine in normal run. if ( ! _thread ) return; // runs in thread moveToThread(qApp->thread()); // validated } -// coco end +// disabled coco end /*! * \brief FrameInterface::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 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 @@ -148,7 +148,7 @@ QCanBusFrame mFrame; mFrame.setFrameId(vCan_Id); if (vData.length() > Can::eLenCanFrame) { - LOG_DEBUG(QString("Payload can't be larger than %1 bytes").arg(Can::eLenCanFrame)); + LOG_DEBUG(QString("Payload cannot be larger than %1 bytes").arg(Can::eLenCanFrame)); return; } mFrame.setPayload(vData); @@ -165,68 +165,97 @@ * \return The Category if the channels from the UI * perspective FrameInterface::ChannelGroup */ -FrameInterface::ChannelGroup FrameInterface::checkChannel(quint32 vFrameId, bool *vOK) +FrameInterface::ChannelGroup FrameInterface::checkChannel(quint32 vFrameId, bool *vOK, bool *vDebugChanngel) { bool ok = true; + bool debugChannel = false; + FrameInterface::ChannelGroup channelGroup = ChannelGroup::eChannel_Unknown; switch (vFrameId) { + case eDialin_HD: + case eHD_Dialin: + case eDialin_DG: + case eDG_Dialin: + case eDialin_UI: + case eUI_Dialin: + if ( gDisableDialinUnhandled ) { + channelGroup = ChannelGroup::eChannel_Ignores; + } else { + channelGroup = ChannelGroup::eChannel_Listens; + } + debugChannel = gDisableDialinUnhandled; // if debug channel is true, the raw can message in logged in the service log. + ok = ! gDisableDialinUnhandled; // if ok is true then it will be interpreted as unhandled messages. + break; + case eChlid_HD_DG : channelGroup = ChannelGroup::eChannel_Ignores; break; - // coco begin validated: The HD/DG communication has not been defined and implemented yet. + // disabled coco begin validated: The HD/DG communication has not been defined and implemented yet. case eChlid_DG_HD : - // coco end + // disabled coco end // this channel is used for DG CheckIn for HW support and testing for now. //channelGroup = ChannelGroup::eChannel_Ignores; //break; case eChlid_HD_UI : case eChlid_HD_Alarm : case eChlid_HD_Sync : - // coco begin validated: The UI/DG communication has not been defined and implemented yet. + // disabled coco begin validated: The UI/DG communication has not been defined and implemented yet. case eChlid_DG_Alarm : case eChlid_DG_UI : case eChlid_DG_Sync : - // coco end + // disabled coco end //case eChlid_DG_UI : // has duplicate value as eChlid_DG_Alarm channelGroup = ChannelGroup::eChannel_Listens; break; - // coco begin validated: The UI Alarm and Sync messages has not been defined and implemented yet. + // disabled coco begin validated: The UI Alarm and Sync messages has not been defined and implemented yet. case eChlid_UI_Alarm : case eChlid_UI_Sync : //case eChlid_UI_DG : channelGroup = ChannelGroup::eChannel_Outputs; break; - // coco end + // disabled coco end default: ok = false; break; } - // coco begin validated: manually tested + // disabled coco begin validated: manually tested if (vOK) *vOK = ok; - // coco end + if (vDebugChanngel) *vDebugChanngel = debugChannel; + + // disabled coco end return channelGroup; } /*! * \brief FrameInterface::onFrameReceive * \details This the slot connected to the CanInterface didFrameReceive signal. - * When a frame received over the CANBUS, + * 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 FrameInterface::onFrameReceive(const QCanBusFrame &vFrame) { bool ok = false; + bool debugChannel = false; + quint32 mFrameId = vFrame.frameId(); - ChannelGroup channelGroup = checkChannel(mFrameId, &ok); - if (!ok) { - LOG_DEBUG("Unexpected Channel\r\n" + - Format::toHexString(mFrameId, false, eLenChannelDigits) + " -- " + vFrame.payload().toHex(' ')); + ChannelGroup channelGroup = checkChannel(mFrameId, &ok, &debugChannel); + + QString logMessage; + if ( debugChannel ) { + logMessage = "Debug Channel\r\n" + + Format::toHexString(mFrameId, false, eLenChannelDigits) + " -- " + vFrame.payload().toHex(' '); + LOG_DEBUG(logMessage); + } + if ( ! ok ) { + logMessage = "Unexpected Channel\r\n" + + Format::toHexString(mFrameId, false, eLenChannelDigits) + " -- " + vFrame.payload().toHex(' '); + LOG_DEBUG(logMessage); return; } @@ -241,15 +270,15 @@ /*! * \brief FrameInterface::onFrameTransmit * \details This the slot connected to the MessageDispatcher didFrameTransmit signal. - * When a frame needs to be send to CANBUS, + * 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 vCan_Id - CANBus Can Id target of the frame. * \param vData - The data which this frame will carry. */ void FrameInterface::onFrameTransmit(Can_Id vCan_Id, const QByteArray &vData) { appendHead(vCan_Id, vData); - // Test : qDebug() << _timestamp << "apnd #" << _txFrameList.count(); + // DEBUG: qDebug() << _timestamp << "apnd #" << _txFrameList.count(); } /*! @@ -260,7 +289,7 @@ { _transmitted = true; removeHead(); - // Test : qDebug() << _timestamp << "Sent #" << _txFrameList.count() << vCount; + // DEBUG: qDebug() << _timestamp << "Sent #" << _txFrameList.count() << vCount; } /*! @@ -270,10 +299,10 @@ void FrameInterface::timerEvent(QTimerEvent *) { static quint8 count = 0; - // Test : _timestamp = QTime::currentTime().toString("HH:mm:ss.zzz"); + // TEST : _timestamp = QTime::currentTime().toString("HH:mm:ss.zzz"); if (++count != _interval) return; - // Test : qDebug() << _timestamp; + // DEBUG: qDebug() << _timestamp; count = 0; _transmitted = false; trnsmtHead(); @@ -288,19 +317,19 @@ void FrameInterface::trnsmtHead() { if ( _txFrameList.isEmpty() ) { - // coco begin validated: This is a fake data generator for CANBus missing/swapped frames Testing + // disabled coco begin validated: This is a fake data generator for CANBus missing/swapped frames Testing // will never be executed on the product and shall be removed after the CANBus issues has been resolved. // has been tested manually if ( gSendEmptyKeepAwake ) { transmitFrame(eChlid_LOWEST,QByteArray()); // Keep the CANBus awake. return; } } - // coco end + // disabled coco end else { Frame frame = _txFrameList.first(); transmitFrame(frame.can_Id, frame.data); - // Test : qDebug() << _timestamp << "Tsmt #" << _txFrameList.count(); + // DEBUG: qDebug() << _timestamp << "Tsmt #" << _txFrameList.count(); } } @@ -327,7 +356,8 @@ */ void FrameInterface::appendHead(Can_Id vCan_Id, const QByteArray &vData) { - // coco begin validated: has been manually tested by sending over 4000 frames and not received by any other node. + // disabled coco begin validated: has been manually tested by sending over 4000 frames and not received by any other node. + //DEBUG qDebug() << "F " << _txFrameList.count(); if (_txFrameList.count() >= _txFrameList_Max) { static quint32 i = 0; if ( i % 60 == 0 ) { // log only for the first time and each minute. @@ -336,7 +366,7 @@ if ( i < UINT32_MAX - 1 ) i++ ; else i = 0; return; - // coco end + // disabled coco end } Frame frame = Frame(vCan_Id, vData);