Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -r260229a756a3ee29c681132bdc4d32204c215ceb -r7936e751fe1cd3517d0d548b53fef41f41b4db4a --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 260229a756a3ee29c681132bdc4d32204c215ceb) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 7936e751fe1cd3517d0d548b53fef41f41b4db4a) @@ -282,8 +282,10 @@ * \param vActionId - The ActionID of the message * \param vData - The data of the Message */ +/* void MessageDispatcher::actionTransmit(const QVariantList &vData, Sequence vSequence, Can_Id vCanId) { + Q_UNUSED(vCanId) txCount(); if (vSequence == 0) { // initialize // it's obvious that this assignment does not effect outside of the function. @@ -297,29 +299,27 @@ Can_Id canid = Can::Can_Id::eChlid_UI_HD; // TODO figure out //vCanId; if (! _interpreter.interpretMessage(vData, mData, canid)) { LOG_DEBUG(QString("Incorrect Message, cannot be interpreted, %1").arg(Format::toHexString(vActionId))); // TODO : LogInfo Improvement - qDebug() << "Cannot Interpret"; return; } - qDebug() << "Got to action" << mData << vCanId << vData[0]; + // TODO : Create a buildFrames method FrameList frameList; Sequence mSequence = vSequence; - bool mNeedsAcknow = false; //needsAcknow(vCanId); + bool mNeedsAcknow = true; //needsAcknow(vCanId); if (mNeedsAcknow) { mSequence = -mSequence; if ( ! gDisableAcknowLog ) { - LOG_APPED_UI(tr("Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(vActionId))); + LOG_APPED_UI(tr("Ack Req, Sq:%1, ID:%2").arg(mSequence).arg(Format::toHexString(vActionId))); } #ifdef DEBUG_ACKBACK_HD_TO_UI - qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckReq : %1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence); + qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckReq : %1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence); #endif } // disabled coco begin validated: Has been tested manually but in this function this cannot be false because the message interpreter is doing the same validation. // still checking here in case the logic has changed therefore buildFrame should still validate the message for developer safety. if ( ! _builder.buildFrames(0, mData, frameList, mSequence) ) { LOG_DEBUG(QString("Incorrect Message cannot be built")); // TODO : LogInfo Improvement - qDebug() << "Cannot build message"; return; } // disabled coco end @@ -334,6 +334,7 @@ framesTransmit(canid, frameList); } +*/ /*! * \brief MessageDispatcher::framesTransmit * \details iterates through all the frames and emits to send the frames @@ -377,9 +378,24 @@ */ bool MessageDispatcher::checkAcknowReceived(const Message &vMessage, const QString &vSrcText) { - Q_UNUSED(vMessage); - Q_UNUSED(vSrcText); - return true; + enum GuiActionsType_Enum /* : quint16 QML does not support enum types */ { + ID_Acknow = 0xFFFF, + }; + + int mActionId = vMessage.actionId; + Sequence mSequence = vMessage.sequence; + bool ok = false; + if ( mActionId == ID_Acknow ) { + ok = true; + if ( ! gDisableAcknowLog ) { + LOG_APPED(tr(" ,%1,Ack Bak, Sq:%2").arg(vSrcText).arg(mSequence)); + } +#ifdef DEBUG_ACKBACK_HD_TO_UI + qDebug() << tr(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HD AckBak : %1 %2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ").arg(mSequence).arg(vMessage.actionId); +#endif + emit didAcknowReceive(mSequence); + } + return ok; } /*! @@ -391,13 +407,15 @@ */ bool MessageDispatcher::checkAcknowTransmit(const Message &vMessage, const QString &vSrcText) { + enum GuiActionsType_Enum /* : quint16 QML does not support enum types */ { + ID_Acknow = 0xFFFF, + }; + bool ok = false; - int mActionId = 0; + int mActionId = vMessage.actionId; Sequence mSequence = vMessage.sequence; - // UI shall acknowledge the messages is intended for UI. if ( ! needsAcknow(vMessage.can_id)) return ok; // false - if (mSequence < 0) { ok = true; if ( ! gDisableAcknowLog ) { @@ -409,7 +427,13 @@ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UI AckBak is immediately handled at the same place. QString dstText; Can_Id dstID = MessageInterpreter::identifyDestination(vMessage.can_id, &dstText); - actionTransmit({}, -mSequence, dstID); + Q_UNUSED(dstID) + + QVariantList msg; + msg.append(static_cast(ID_Acknow)); + msg.append(Can_Id::eChlid_HD_UI); + + actionTransmit(msg, -mSequence); if ( ! gDisableAcknowLog ) { LOG_APPED_UI(tr("Ack Bak, Sq:%1, Dst:%2").arg(-mSequence).arg(dstText)); } @@ -434,6 +458,7 @@ QVariantList mData; QString srcText; MessageInterpreter::identifySource(vMessage.can_id, &srcText); + if ( ! checkAcknowReceived(vMessage, srcText) ) { // check if the message was an acknowledge. checkAcknowTransmit(vMessage, srcText); // then if needs acknow send it immediately. }