Index: sources/canbus/messagebuilder.cpp =================================================================== diff -u -rc5389647e2259e67f8e6d923f3481d7d3f4eab68 -r561055268da68e24fe91a1148b76bf1785dae14d --- sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision c5389647e2259e67f8e6d923f3481d7d3f4eab68) +++ sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision 561055268da68e24fe91a1148b76bf1785dae14d) @@ -90,7 +90,7 @@ 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); + qDebug() << "ERROR :" << tr("Incorrect Action ID '%1'").arg(mHexString); return false; } return true; @@ -107,12 +107,6 @@ 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) { @@ -122,6 +116,12 @@ len = vData.length(); } } + 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; + } vPayload += len; vPayload += vData.mid(0, len); // Adding required Data return true;