Index: denali.pro =================================================================== diff -u -r460df093c4475816fc25d6b4c3ebfc50424ccca3 -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- denali.pro (.../denali.pro) (revision 460df093c4475816fc25d6b4c3ebfc50424ccca3) +++ denali.pro (.../denali.pro) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -3,12 +3,12 @@ #CONFIG += disable_crc -#CONFIG += disable_keepalive - disable_crc { message( *** IMPORTANT : DISABLED CRC CHECK *** ) DEFINES += DISABLE_CRC } + +#CONFIG += disable_keepalive disable_keepalive { message( *** IMPORTANT : DISABLED KEEP ALIVE *** ) DEFINES += DISABLE_KEEP_ALIVE @@ -52,6 +52,7 @@ sources/storage/logger.h \ sources/storage/settings.h \ sources/utility/crc.h \ + sources/utility/format.h \ sources/utility/types.h SOURCES += \ @@ -72,7 +73,8 @@ sources/storage/filehandler.cpp \ sources/storage/logger.cpp \ sources/storage/settings.cpp \ - sources/utility/crc.cpp + sources/utility/crc.cpp \ + sources/utility/format.cpp RESOURCES += \ denali.qrc Index: main.cpp =================================================================== diff -u -r460df093c4475816fc25d6b4c3ebfc50424ccca3 -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- main.cpp (.../main.cpp) (revision 460df093c4475816fc25d6b4c3ebfc50424ccca3) +++ main.cpp (.../main.cpp) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -25,6 +25,7 @@ #include #include #include +#include // Project #include "maintimer.h" @@ -53,6 +54,17 @@ QCoreApplication::setApplicationName(QLatin1String("Denali")); QCoreApplication::setOrganizationName(QLatin1String("Diality Inc.")); + // Test code for debugging can messages + bool _consoleoutMessageHandler = false; + bool _consoleoutCanInterface = false; + QStringList args = app.arguments(); + if (args.length() >= 2) { + _consoleoutMessageHandler = args[1] == "1"; + } + if (args.length() >= 3) { + _consoleoutCanInterface = args[2] == "1"; + } + //! - Setting the application version regarding the Bamboo build number. QString ver_revis = QString("%1").arg(VER_REVIS); if (ver_revis.isEmpty()) { @@ -75,14 +87,14 @@ //! - Initializing CanBus Interface _CanInterface->init(); - _CanInterface->enableConsoleOut(false); + _CanInterface->enableConsoleOut(_consoleoutCanInterface); //! - Initializing CanBus Message Handler _MessageHandler->init(); //! - Initializing CanBus Message Dispatcher _MessageDispatcher->init(); - _MessageDispatcher->enableConsoleOut(false); + _MessageDispatcher->enableConsoleOut(_consoleoutMessageHandler); //! - Initializing Application Controller _ApplicationController->init(); Index: sources/canbus/messagebuilder.cpp =================================================================== diff -u -r460df093c4475816fc25d6b4c3ebfc50424ccca3 -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision 460df093c4475816fc25d6b4c3ebfc50424ccca3) +++ sources/canbus/messagebuilder.cpp (.../messagebuilder.cpp) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -18,6 +18,7 @@ // Project #include "crc.h" +#include "format.h" // namespace using namespace Can; @@ -229,10 +230,10 @@ byteList[i] = QByteArray("\033[36m") + byteList[i].constData() + QByteArray("\033[0m"); } } - view = GuiActions::toHexString(vCan_Id, false, 3).toLatin1() + " " + byteList.join('.'); + view = Format::toHexString(vCan_Id, false, 3).toLatin1() + " " + byteList.join('.'); fprintf(stderr, "%s\n", view.constData()); } else { - view = GuiActions::toHexString(vCan_Id, false, 3).toLatin1() + " " + vPayload.toHex('.'); + view = Format::toHexString(vCan_Id, false, 3).toLatin1() + " " + vPayload.toHex('.'); fprintf(stderr, "%s\n", view.constData()); } } Index: sources/canbus/messagehandler.cpp =================================================================== diff -u -r1732e83d2a0308b9c706f37d6d7724a364bbff2a -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- sources/canbus/messagehandler.cpp (.../messagehandler.cpp) (revision 1732e83d2a0308b9c706f37d6d7724a364bbff2a) +++ sources/canbus/messagehandler.cpp (.../messagehandler.cpp) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -25,6 +25,7 @@ #include "maintimer.h" #include "messagedispatcher.h" #include "caninterface.h" +#include "format.h" // namespace using namespace Can; @@ -125,7 +126,8 @@ ChannelGroup channelGroup = checkChannel(mFrameId, &ok); if (!ok){ - qDebug() << "ERROR : " << "Unexpected Channel"; + qDebug() << "ERROR :" << "Unexpected Channel"; + qDebug() << Format::toHexString(mFrameId, false, 3) + " -- " + vFrame.payload().toHex(' '); return; } Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r460df093c4475816fc25d6b4c3ebfc50424ccca3 -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 460df093c4475816fc25d6b4c3ebfc50424ccca3) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -16,7 +16,9 @@ // Qt // Project +#include "format.h" + using namespace Can; MessageInterpreter::MessageInterpreter(QObject *parent) : QObject(parent) { } @@ -49,7 +51,7 @@ quint8 tmp = vData[ix].toUInt(); vPayload += tmp; } else { - QString mActionIdHexString = GuiActions::toHexString(vActionId); + QString mActionIdHexString = Format::toHexString(vActionId); qDebug() << "ERROR :" << tr("Incorrect data for Message ID (UI) '%1'").arg(mActionIdHexString); ok = false; } @@ -65,7 +67,7 @@ break; default: - QString mActionIdHexString = GuiActions::toHexString(vActionId); + QString mActionIdHexString = Format::toHexString(vActionId); qDebug() << "ERROR :" << tr("Unknown Message ID (UI) '%1'").arg(mActionIdHexString); ok = false; break; @@ -119,16 +121,22 @@ break; } - case GuiActionType::Alarm: + case GuiActionType::AlarmStatus: + printUnhandled(vMessage); break; - default: { - QString mActionIdHexString = GuiActions::toHexString(vMessage.actionId); - qDebug() << "ERROR :" << tr("Unknown Message ID (HD) '%1'").arg(mActionIdHexString); - ok = false; + case GuiActionType::AlarmTriggered: + printUnhandled(vMessage); break; + + case GuiActionType::AlarmCleared: + printUnhandled(vMessage); + break; + + default: + printUnhandled(vMessage); + break; } - } return ok; } @@ -147,7 +155,7 @@ return false; } if ( vMessage.data.length() < payloadLen[GuiActionType::BloodFlow] ) { - QString mActionIdHexString = GuiActions::toHexString(vMessage.actionId); + QString mActionIdHexString = Format::toHexString(vMessage.actionId); qDebug() << "ERROR :" << tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString); return false; } @@ -215,9 +223,17 @@ quint8 tmp = vMessage.data[ix]; vShowHide = tmp; } else { - QString mActionIdHexString = GuiActions::toHexString(vMessage.actionId); + QString mActionIdHexString = Format::toHexString(vMessage.actionId); qDebug() << "ERROR :" << tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString); ok = false; } return ok; } + +void MessageInterpreter::printUnhandled(const Message &vMessage) +{ + QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, 3); + qDebug() << "WARNG :" << tr("Unhandled Message ID (HD)"); + qDebug().noquote() << QString(mActionIdHexString + " " + vMessage.data.toHex('.')).toLatin1(); + qDebug() << ""; +} Index: sources/canbus/messageinterpreter.h =================================================================== diff -u -r460df093c4475816fc25d6b4c3ebfc50424ccca3 -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 460df093c4475816fc25d6b4c3ebfc50424ccca3) +++ sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -38,6 +38,7 @@ types::F32 &vF32_1, types::F32 &vF32_2, types::F32 &vF32_3, types::F32 &vF32_4, types::F32 &vF32_5 ); bool getPowerOffData (const Message &vMessage, quint8 &vShowHide); + void printUnhandled (const Message &vMessage); public: explicit MessageInterpreter(QObject *parent = nullptr); Index: sources/gui/guiglobals.cpp =================================================================== diff -u -r460df093c4475816fc25d6b4c3ebfc50424ccca3 -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision 460df093c4475816fc25d6b4c3ebfc50424ccca3) +++ sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -65,13 +65,4 @@ }); _viewer->setSource(QStringLiteral("qrc:/main.qml")); } - - QString GuiActions::toHexString(quint16 vValue, bool vWith0x, quint8 vLen) { - if ( vWith0x ) { - return "0x" + QString("%1").arg(vValue,0,16).rightJustified(vLen, '0'); - } else { - return QString("%1").arg(vValue,0,16).rightJustified(vLen, '0'); - } - } - } Index: sources/gui/guiglobals.h =================================================================== diff -u -r460df093c4475816fc25d6b4c3ebfc50424ccca3 -r4c1551d45b40987c2d59c11e95760e9b6c55fc68 --- sources/gui/guiglobals.h (.../guiglobals.h) (revision 460df093c4475816fc25d6b4c3ebfc50424ccca3) +++ sources/gui/guiglobals.h (.../guiglobals.h) (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -28,16 +28,17 @@ explicit GuiActions(); public: enum /*class*/ GuiActionsType_Enum /*: quint16 QML doesn't support*/ { - Unknown = 0x0000, - PowerOff = 0x0100, - KeepAlive = 0x0700, - BloodFlow = 0x0500, + Unknown = 0x0000, + PowerOff = 0x0100, + KeepAlive = 0x0700, + BloodFlow = 0x0500, - Alarm = 0x0200, ///< ? + AlarmStatus = 0x0200, + AlarmTriggered = 0x0300, + AlarmCleared = 0x0400, - String = 0xFFFF, + String = 0xFFFF, }; - static QString toHexString(quint16 vValue, bool vWith0x = true, quint8 vLen = 4); enum class GuiActionsIndx_Enum { PowerOff_ShowHide = 0, Index: sources/utility/format.cpp =================================================================== diff -u --- sources/utility/format.cpp (revision 0) +++ sources/utility/format.cpp (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -0,0 +1,27 @@ +/*! + * + * Copyright (c) 2019-2019 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 format.cpp + * date 12/16/2019 + * author Behrouz NematiPour + * + */ +#include "format.h" + +Format::Format() +{ + +} + +QString Format::toHexString(quint16 vValue, bool vWith0x, quint8 vLen) { + if ( vWith0x ) { + return "0x" + QString("%1").arg(vValue,0,16).rightJustified(vLen, '0'); + } else { + return QString("%1").arg(vValue,0,16).rightJustified(vLen, '0'); + } +} Index: sources/utility/format.h =================================================================== diff -u --- sources/utility/format.h (revision 0) +++ sources/utility/format.h (revision 4c1551d45b40987c2d59c11e95760e9b6c55fc68) @@ -0,0 +1,28 @@ +/*! + * + * Copyright (c) 2019-2019 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 format.h + * date 12/16/2019 + * author Behrouz NematiPour + * + */ +#pragma once + +// Qt +#include + +// Project + +class Format +{ + Format(); +public: + static QString toHexString(quint16 vValue, bool vWith0x = true, quint8 vLen = 4); + +}; +