Index: denali.pro.user =================================================================== diff -u -rd3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d -r5626bf604947efe5a80c9ca51802aab1a70a6939 --- denali.pro.user (.../denali.pro.user) (revision d3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d) +++ denali.pro.user (.../denali.pro.user) (revision 5626bf604947efe5a80c9ca51802aab1a70a6939) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/canbus/messagedispatcher.cpp =================================================================== diff -u -rd3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d -r5626bf604947efe5a80c9ca51802aab1a70a6939 --- sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision d3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d) +++ sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision 5626bf604947efe5a80c9ca51802aab1a70a6939) @@ -155,7 +155,10 @@ void MessageDispatcher::onFrameReceive(Can_Id vCan_Id, const QByteArray &vPayload) { // Append a message to the list + // coco begin validated: if empty (first condition) is true, it must never check for the complete (second condition) + // because if the list is empty there is no last() item if (_messageList[vCan_Id].isEmpty() || _messageList[vCan_Id].last().isComplete()) { + // coco end _messageList[vCan_Id].append(Message()); } Index: sources/canbus/messagedispatcher.h =================================================================== diff -u -r8f6f7c11390e3ed6d918f1717d8e8b7ae5b7e5c6 -r5626bf604947efe5a80c9ca51802aab1a70a6939 --- sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision 8f6f7c11390e3ed6d918f1717d8e8b7ae5b7e5c6) +++ sources/canbus/messagedispatcher.h (.../messagedispatcher.h) (revision 5626bf604947efe5a80c9ca51802aab1a70a6939) @@ -27,6 +27,7 @@ // forward declarations class tst_canbus; class tst_acknow; +class tst_messaging; // since this class is the interface between GUI and Can // it needs to use Gui namespace otherwise it makes code hard to read. @@ -87,6 +88,7 @@ // friends friend class ::tst_canbus; friend class ::tst_acknow; + friend class ::tst_messaging; QHash _messageList; Index: sources/canbus/messageglobals.h =================================================================== diff -u -rd3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d -r5626bf604947efe5a80c9ca51802aab1a70a6939 --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision d3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision 5626bf604947efe5a80c9ca51802aab1a70a6939) @@ -141,8 +141,22 @@ QByteArray data; bool initialized = false; - bool isEmpty () { return !initialized || !data.length(); } - bool isComplete() { return !isEmpty() && data.length() == length; } + bool isEmpty () { + // coco begin validated:Has been validated manually. + // Since the crc is part of the data and there is no message without crc + // initialized flag and data.length() == 0 became the same. + // I preffer too keep it as it is so the initialization would be independent of the data. + return !initialized || !data.length(); + // coco end + } + bool isComplete() { + // coco begin validated:Has been validated manually. + // Since the crc is part of the data and there is no message without crc + // then a message would never be empty. + // I preffer too keep it as it is so the initialization would be independent of the data. + return !isEmpty() && data.length() == length; + // coco end + } }; typedef QList MessageList; Index: unittests/tst_messaging.cpp =================================================================== diff -u -rd3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d -r5626bf604947efe5a80c9ca51802aab1a70a6939 --- unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision d3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d) +++ unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision 5626bf604947efe5a80c9ca51802aab1a70a6939) @@ -20,6 +20,7 @@ #include "messageinterpreter.h" #include "messagebuilder.h" #include "mpoweroff.h" +#include "messagedispatcher.h" tst_messaging::tst_messaging(QObject *parent) : QObject(parent) { } @@ -409,3 +410,11 @@ QVERIFY( bMsg.buildFrames(Gui::GuiActionType::String, data, framelist, seq)); } +void tst_messaging::tst_MessageBuilder_actionTransmit() +{ + Can::MessageDispatcher dMsg; + QVariantList data; + Can::Sequence seq = 1; + dMsg.actionTransmit(Gui::GuiActionType::AdjustBloodDialysateReq, data, seq); +} + Index: unittests/tst_messaging.h =================================================================== diff -u -rd3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d -r5626bf604947efe5a80c9ca51802aab1a70a6939 --- unittests/tst_messaging.h (.../tst_messaging.h) (revision d3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d) +++ unittests/tst_messaging.h (.../tst_messaging.h) (revision 5626bf604947efe5a80c9ca51802aab1a70a6939) @@ -74,6 +74,7 @@ void tst_MessageBuilder_buildFrames_addActionId(); void tst_MessageBuilder_buildFrames_addData(); void tst_MessageBuilder_buildFrames_eLenCanFrame(); + void tst_MessageBuilder_actionTransmit(); };