Index: sources/canbus/MessageDispatcher.cpp =================================================================== diff -u -rc8da96049610870d3a8c9c00edc04f80ae62085f -r6abfb957108b171a8a5ab6770ad9b463235c210b --- sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision c8da96049610870d3a8c9c00edc04f80ae62085f) +++ sources/canbus/MessageDispatcher.cpp (.../MessageDispatcher.cpp) (revision 6abfb957108b171a8a5ab6770ad9b463235c210b) @@ -88,6 +88,10 @@ */ void MessageDispatcher::initConnections() { + // Message transmit + connect(&_ApplicationController, SIGNAL(didActionTransmit(const QVariantList &)), + this , SLOT( onActionTransmit(const QVariantList &))); + // From HD connect(&_FrameInterface , SIGNAL(didFrameReceive (Can_Id , const QByteArray &)), this , SLOT( onFrameReceive (Can_Id , const QByteArray &))); @@ -227,6 +231,51 @@ _interpreter.updateUnhandledMessages(); } +void MessageDispatcher::actionTransmit(const QVariantList &vData, Sequence vSequence) +{ + // For dry demo + txCount(); + if (vSequence == 0) { // initialize + // it's obvious that this assignment does not effect outside of the function. + // but is make it easier to just assume the correct value has been passed + // and still using the same variable (function parameter) as a local variable. + vSequence = _txSequence; + } + + QByteArray mData; + Can_Id canid = static_cast(vData[1].toUInt()); + + for (int i = 2; i < vData.size(); ++i) { + mData += Format::fromVariant(vData[i]); + qDebug() << "Data" << mData << vData[i]; + } + + FrameList frameList; + Sequence mSequence = vSequence; + bool mNeedsAcknow = false; //needsAcknow(vCanId); + if (mNeedsAcknow) { + mSequence = -mSequence; + } + + // 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(vData[0].toUInt(), mData, frameList, mSequence) ) { + LOG_DEBUG(QString("Incorrect Message cannot be built")); // TODO : LogInfo Improvement + qDebug() << "Cannot build message"; + return; + } + // disabled coco end + if (mNeedsAcknow) { + // NOTE : here vSequence should be used which is not negative + // because when we get the Acknow it is not the negative + // since it does not need Re-Acknow + // and this is the sequence number which will be used + // to remove the message from the Acknow list. + //emit didAcknowTransmit(canid, vSequence, frameList); + } + framesTransmit(canid, frameList); +} + /*! * \brief MessageDispatcher::actionTransmit * \details This method is called by slot MessageDispatcher::onActionTransmit @@ -247,16 +296,17 @@ quint8 vActionId = 0; QByteArray mData; - Can_Id canid = vCanId; + 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 = needsAcknow(vCanId); + bool mNeedsAcknow = false; //needsAcknow(vCanId); if (mNeedsAcknow) { mSequence = -mSequence; if ( ! gDisableAcknowLog ) { @@ -269,8 +319,9 @@ // 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(mData, frameList, mSequence) ) { + 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