Index: main.cpp =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- main.cpp (.../main.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ main.cpp (.../main.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -26,6 +26,7 @@ #include #include #include +#include // Project #include "maintimer.h" @@ -39,7 +40,9 @@ #include "usbwatcher.h" #include "threads.h" +// kernel #include + /*! * \brief signalhandler * \details When application terminates it quits gracefully. @@ -59,6 +62,74 @@ } } +int gFakeInterval = 0 ; +QByteArray gFakeData = "" ; +const char *gFakeData_default = "00" ; +bool gSendEmptyKeepAwake = true ; + +bool gConsoleoutFrameInterface = false ; +bool gConsoleoutCanInterface = false ; + +/*! + * \brief commandlineParse + * \details parses the command line arguments + */ +void commandlineParse() { + QCommandLineParser parser; + parser.setApplicationDescription(QApplication::applicationName()); + parser.addHelpOption(); + parser.addVersionOption(); + + QCommandLineOption optionConsoleoutCanInterface( + QStringList() << "c" << "canOut", + QCoreApplication::translate("main", "Show the Can Frame Output")); + parser.addOption(optionConsoleoutCanInterface); + + QCommandLineOption optionConsoleoutFrameInterface( + QStringList() << "m" << "msgOut", + QCoreApplication::translate("main", "Show the Message Output")); + parser.addOption(optionConsoleoutFrameInterface); + + QCommandLineOption optionSendEmptyKeepAwake(QStringList() << "0" << "disable-keep-awake", + QCoreApplication::translate("main", "Disable send low priority, empty message on the CANBus just to keep UI board CAN driver awake")); + parser.addOption(optionSendEmptyKeepAwake); + + QCommandLineOption optionFakeInterval( + QStringList() << "i" << "fake-interval", + QCoreApplication::translate("main", "Test fake message interval(ms)"), + QCoreApplication::translate("main", "interval")); + parser.addOption(optionFakeInterval); + + QCommandLineOption optionFakeData( + QStringList() << "f" << "fake-message", + QCoreApplication::translate("main", "Test fake message data\n" + "will use default sequenced long fake message if set to 00(default)\n" + "will used only if correct intger value assigned for interval option"), + QCoreApplication::translate("main", "data")); + parser.addOption(optionFakeData); + + parser.process(*qApp); + + + gConsoleoutCanInterface = parser.isSet(optionConsoleoutCanInterface ); + gConsoleoutFrameInterface = parser.isSet(optionConsoleoutFrameInterface ); + if (parser.isSet(optionSendEmptyKeepAwake)) gSendEmptyKeepAwake = false; + bool ok = false; + + if (parser.isSet(optionFakeInterval)) { + int interval = parser.value(optionFakeInterval).toInt(&ok); + if (ok) { + gFakeInterval = interval; + if (parser.isSet(optionFakeData)) { + gFakeData = parser.value(optionFakeData).toLatin1(); + } else { + gFakeData = gFakeData_default; + } + gFakeData = QByteArray::fromHex(gFakeData); + } + } +} + #ifdef UNIT_TEST #include TEST_CLASS_INCLUDE QTEST_MAIN(TEST_CLASS_NAME) @@ -88,17 +159,6 @@ QApplication app(argc, argv); app.thread()->setObjectName("Main Thread"); - // Test code for debugging can messages - bool _consoleoutFrameInterface = false; - bool _consoleoutCanInterface = false; - QStringList args = app.arguments(); - if (args.length() >= 2) { - _consoleoutFrameInterface = 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()) { @@ -109,6 +169,9 @@ .arg(VER_MINOR) .arg(ver_revis)); + //! - Parse the command line arguments + commandlineParse(); + //! - Translation initialization QTranslator translator; bool trLoaded = translator.load(QLocale(), app.applicationName(), QLatin1String("_"), QLatin1String(":/translations")); @@ -124,12 +187,19 @@ LOG_EVENT(QObject::tr("Application Started")); + if (gFakeInterval) { + qDebug() << " ~~ !!!!! APPLICATION RUNNING IN THE TEST MODE !!!!! ~~ " ; + LOG_EVENT(" \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " + " \n ~~ !!!!! APPLICATION RUNNING IN THE TEST MODE !!!!! ~~ " + " \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); + } + //! - Initializing USB Watcher _USBWatcher.init(Threads::_USBWatcher_Thread); //! - Initializing CanBus Interface if (_CanInterface.init(Threads::_CanFrame_Thread)) { - _CanInterface.enableConsoleOut(_consoleoutCanInterface); + _CanInterface.enableConsoleOut(gConsoleoutCanInterface); } //! - Initializing CanBus Message Handler @@ -140,7 +210,7 @@ //! - Initializing CanBus Message Dispatcher if (_MessageDispatcher.init(Threads::_CanMessage_Thread)) { - _MessageDispatcher.enableConsoleOut(_consoleoutFrameInterface); + _MessageDispatcher.enableConsoleOut(gConsoleoutFrameInterface); } //! - Initializing Application Controller Index: scripts/autostart =================================================================== diff -u -r3b9a656e9672a3db74f14b476bf1df249f016805 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- scripts/autostart (.../autostart) (revision 3b9a656e9672a3db74f14b476bf1df249f016805) +++ scripts/autostart (.../autostart) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -1,5 +1,7 @@ #!/bin/sh - +# +# This script will be in the /etc/init.d/ as an autostart. +# case "$1" in start) logger "Starting autostart scripts" Index: scripts/run.sh =================================================================== diff -u -r7d23aecac8db9b7495e7d505f55bba5a0d510360 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- scripts/run.sh (.../run.sh) (revision 7d23aecac8db9b7495e7d505f55bba5a0d510360) +++ scripts/run.sh (.../run.sh) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -1,5 +1,9 @@ #!/bin/sh - +# +# This script will be called by autostart script in the /etc/init.d/ +# to initialize the Denali UI Application Software environment +# and finaly calls the Application itself in background. +# HOME=/home/root SDCARD_DEV=/dev/mmcblk1p1 SDCARD_MNT=/media/sd-card @@ -32,9 +36,10 @@ fi #setting up can interface -ip link set can0 up type can bitrate 250000 -ifconfig can0 txqueuelen 4000 -sysctl net/core/netdev_max_backlog=4000 +# current settings can be retrieved by the command below +# $ ip -details -statistics link show can0 +ip link set can0 up type can bitrate 250000 restart-ms 100 +#ifconfig can0 txqueuelen 4000 if [ $? -eq 0 ]; then echo ":: Can interface setup" fi Index: sources/applicationcontroller.cpp =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -236,7 +236,58 @@ { #ifndef DISABLE_KEEP_ALIVE QVariantList mData; - mData += static_cast(GuiActionData::NoData); + int mFakeDataLen = gFakeData.length(); + if (mFakeDataLen) { + createFakeSequencedLongMessage(mData, mFakeDataLen); + } else { + mData += static_cast(GuiActionData::NoData); + } onActionTransmit(GuiActionType::KeepAlive, mData); #endif } + +/*! + * \brief ApplicationController::createFakeSequencedLongMessage + * \details This method is creating the fake message with frame sequence + * which we use for Denali Message test + * \param vFakeDataLen + */ +void ApplicationController::createFakeSequencedLongMessage(QVariantList &vData, const int vFakeDataLen) +{ + QByteArray data; + Types::U16 u16; + if (vFakeDataLen == 1 && gFakeData == QByteArray::fromHex(gFakeData_default)) { + static quint64 txCount = 0; + for (int i = 0; i < 13; i++) { + switch (i) { + case 0: + u16.value = txCount; + data += u16.bytes[0]; + data += u16.bytes[1]; + break; + + case 12: + for (int i = 0; i < 4; i++) { + data += (char)(0); + } + u16.value = txCount; + data += u16.bytes[0]; + data += u16.bytes[1]; + break; + + default: + for (int i = 0; i < 6; i++) { + data += (char)(0); + } + u16.value = txCount; + data += u16.bytes[0]; + data += u16.bytes[1]; + break; + } + Types::safeIncrement(txCount); + } + vData += QByteArray::fromHex(data.toHex()); + } else { + vData += gFakeData; + } +} Index: sources/applicationcontroller.h =================================================================== diff -u -r1ec7b44e6d1d66460d2da943ff65f3c0c0755d8f -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/applicationcontroller.h (.../applicationcontroller.h) (revision 1ec7b44e6d1d66460d2da943ff65f3c0c0755d8f) +++ sources/applicationcontroller.h (.../applicationcontroller.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -55,6 +55,8 @@ void keepAlive(); + void createFakeSequencedLongMessage(QVariantList &vData, const int vFakeDataLen); + private slots: // Should be private for thread safety and is connected internally. void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void onActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG Index: sources/canbus/caninterface.cpp =================================================================== diff -u -r94f7349bd073a732dba5295250fc0e26f740743c -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 94f7349bd073a732dba5295250fc0e26f740743c) +++ sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -25,8 +25,6 @@ // stl #include -#define FrameCount_MAX UINT64_MAX - // namespace using namespace Can; @@ -269,32 +267,37 @@ * \details count received frames up the size of the FrameCount type size * \return frame count */ -CanInterface::FrameCount CanInterface::rxCount() +FrameCount CanInterface::rxCount() { - if ( _rxFrameCount <= FrameCount_MAX ) { - ++_rxFrameCount; - } else { - _rxFrameCount = 1; - } + Types::safeIncrement(_rxFrameCount); return _rxFrameCount; + } /*! * \brief CanInterface::txCount * \details count transmitted frames up the size of the FrameCount type size * \return frame count */ -CanInterface::FrameCount CanInterface::txCount() +FrameCount CanInterface::txCount() { - if ( _txFrameCount <= FrameCount_MAX ) { - ++_txFrameCount; - } else { - _txFrameCount = 1; - } + Types::safeIncrement(_txFrameCount); return _txFrameCount; } /*! + * \brief CanInterface::erCount + * \details count errors happened + * \return error count + */ +FrameCount CanInterface::erCount() +{ + Types::safeIncrement(_erFrameCount); + return _erFrameCount; + +} + +/*! * \brief frameFlags * \details CANBUS message frame type as flags * \param vFrame - CANBUS message frame @@ -321,13 +324,15 @@ */ void CanInterface::onFrameError(QCanBusDevice::CanBusError vError) { + erCount(); switch (vError) { case QCanBusDevice::ReadError: case QCanBusDevice::WriteError: case QCanBusDevice::ConnectionError: case QCanBusDevice::ConfigurationError: case QCanBusDevice::UnknownError: _canStatus = _canDevice->errorString(); + LOG_ERROR(QString("%1 - %2").arg(_erFrameCount).arg(_canStatus)); break; default: break; @@ -343,10 +348,11 @@ * \param vFramesCount - The framesCount argument is set to the number of frames * that were written in this payload. */ -void CanInterface::onFrameWritten(qint64 /*vFramesCount*/) +void CanInterface::onFrameWritten(qint64 vFramesCount) { - //_txFrameCount = vFramesCount; - //qDebug() << "onFrameWritten::FramesCount : " << vFramesCount; + static FrameCount mFrameCount = 0; + Types::safeIncrement(mFrameCount, vFramesCount); + emit didFrameWritten(vFramesCount); } /*! Index: sources/canbus/caninterface.h =================================================================== diff -u -r94f7349bd073a732dba5295250fc0e26f740743c -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/canbus/caninterface.h (.../caninterface.h) (revision 94f7349bd073a732dba5295250fc0e26f740743c) +++ sources/canbus/caninterface.h (.../caninterface.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -19,7 +19,9 @@ // Project #include "main.h" +#include "messageglobals.h" + // Define #define _CanInterface Can::CanInterface::I() @@ -60,9 +62,9 @@ QThread *_thread = nullptr; bool _init = false; - typedef quint64 FrameCount; FrameCount _rxFrameCount = 0; FrameCount _txFrameCount = 0; + FrameCount _erFrameCount = 0; // Singleton SINGLETON(CanInterface) @@ -94,6 +96,7 @@ FrameCount rxCount(); FrameCount txCount(); + FrameCount erCount(); static QString frameFlags(const QCanBusFrame &vFrame); @@ -120,6 +123,15 @@ */ void didFrameTransmit(bool ok); + /*! + * \brief didFrameWritten + * \details After the frame transmission is done + * and acknowledged by a node on the CANBus, + * this signal is emmited. + * \param vCount is the number of frame which has been written + */ + void didFrameWritten(qint64 vCount); + public slots: private slots: void onFrameTransmit (const QCanBusFrame &vFrame); Index: sources/canbus/frameinterface.cpp =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/canbus/frameinterface.cpp (.../frameinterface.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ sources/canbus/frameinterface.cpp (.../frameinterface.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -16,6 +16,7 @@ // Qt #include #include +#include // Project #include "logger.h" @@ -44,6 +45,8 @@ initConnections(); + startTimer(1, Qt::PreciseTimer); + LOG_EVENT(QObject::tr("%1 Initialized").arg(metaObject()->className())); return true; @@ -91,6 +94,8 @@ // From CAN connect(&_CanInterface , SIGNAL( didFrameReceive( const QCanBusFrame &)), this , SLOT( onFrameReceive( const QCanBusFrame &))); + connect(&_CanInterface , SIGNAL( didFrameWritten(qint64 )), + this , SLOT( onFrameWritten(qint64 ))); } /*! @@ -195,19 +200,6 @@ } /*! - * \brief FrameInterface::onFrameTransmit - * \details This the slot connected to the MessageDispatcher didFrameTransmit signal. - * When a frame needs to be send to CANBUS, - * this slot will call transmitFrame method to do the job. - * \param vCan_Id - CANBUS Can Id target of the frame. - * \param vData - The data which this frame will carry. - */ -void FrameInterface::onFrameTransmit(Can_Id vCan_Id, const QByteArray &vData) -{ - transmitFrame(vCan_Id, vData); -} - -/*! * \brief FrameInterface::onFrameReceive * \details This the slot connected to the CanInterface didFrameReceive signal. * When a frame received over the CANBUS, @@ -221,7 +213,7 @@ quint32 mFrameId = vFrame.frameId(); ChannelGroup channelGroup = checkChannel(mFrameId, &ok); - if (!ok){ + if (!ok) { LOG_ERROR("Unexpected Channel\r\n" + Format::toHexString(mFrameId, false, eLenChannelDigits) + " -- " + vFrame.payload().toHex(' ')); return; @@ -234,3 +226,95 @@ Can_Id mCan_Id = static_cast(mFrameId); emit didFrameReceive(mCan_Id, vFrame.payload()); } + +/*! + * \brief FrameInterface::onFrameTransmit + * \details This the slot connected to the MessageDispatcher didFrameTransmit signal. + * When a frame needs to be send to CANBUS, + * this slot will call transmitFrame method to do the job. + * \param vCan_Id - CANBUS Can Id target of the frame. + * \param vData - The data which this frame will carry. + */ +void FrameInterface::onFrameTransmit(Can_Id vCan_Id, const QByteArray &vData) +{ + appendHead(vCan_Id, vData); + // Test : qDebug() << _timestamp << "apnd #" << _txFrameList.count(); +} + +/*! + * \brief FrameInterface::onFrameWritten + * \param vCount + */ +void FrameInterface::onFrameWritten(qint64 /*vCount*/) +{ + _transmitted = true; + removeHead(); + // Test : qDebug() << _timestamp << "Sent #" << _txFrameList.count() << vCount; +} + +/*! + * \brief FrameInterface::timerEvent + * \details This event handler is reimplemented in this subclass to receive timer events for this object. + */ +void FrameInterface::timerEvent(QTimerEvent *) +{ + static quint8 count = 0; + // Test : _timestamp = QTime::currentTime().toString("HH:mm:ss.zzz"); + + if (++count != _interval) return; + // Test : qDebug() << _timestamp; + count = 0; + _transmitted = false; + trnsmtHead(); +} + +/*! + * \brief FrameInterface::trnsmtHead + * \details Transmits the head of the trasmit buffer + * Sends an empty frame with lowest prioriority if the transmit buffer is empty + * to keep the UI board CANDriver awake. + */ +void FrameInterface::trnsmtHead() +{ + if ( _txFrameList.isEmpty() ) { + if ( gSendEmptyKeepAwake ) { + transmitFrame(eChlid_LOWEST,QByteArray()); // Keep the CANBus awake. + return; + } + } else { + Frame frame = _txFrameList.first(); + transmitFrame(frame.can_Id, frame.data); + // Test : qDebug() << _timestamp << "Tsmt #" << _txFrameList.count(); + } +} + +/*! + * \brief FrameInterface::removeHead + * \details Removes the frame from the head of the transmit buffer + * in case transmission has been confirmed by the CANBus driver + * in the FrameInterface::onFrameWritten slot + * which is connected to CanInterface::didFrameWritten. + */ +void FrameInterface::removeHead() +{ + if ( _txFrameList.isEmpty() ) { + return; + } + _txFrameList.removeFirst(); +} + +/*! + * \brief FrameInterface::appendHead + * \details Appends the frame to the transmit buffer to be sent later + * \param vCan_Id - the canbus id + * \param vData - the data to be sent + */ +void FrameInterface::appendHead(Can_Id vCan_Id, const QByteArray &vData) +{ + Frame frame = Frame(vCan_Id, vData); + if (_txFrameList.count() >= _txFrameList_Max) { + LOG_ERROR(tr("Transmit buffer overflow of %1").arg(_txFrameList_Max)); + return; + } + _txFrameList.append(frame); +} Index: sources/canbus/frameinterface.h =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/canbus/frameinterface.h (.../frameinterface.h) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ sources/canbus/frameinterface.h (.../frameinterface.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -60,9 +60,30 @@ QThread *_thread = nullptr; bool _init = false; + + struct Frame { + Can_Id can_Id; + QByteArray data ; + + Frame(Can_Id vCan_Id, const QByteArray &vData) { + can_Id = vCan_Id; + data = vData ; + } + }; + QList _txFrameList; + const quint16 _txFrameList_Max = 4000; // maximum number of frames in the transmit buffer + bool _transmitted = false; + + const quint8 _interval = 7; // keep awake call of the UI board in ms + + QString _timestamp; + // Singleton SINGLETON(FrameInterface) +protected: + void timerEvent(QTimerEvent *); + public slots: bool init(); bool init(QThread &vThread); @@ -76,12 +97,16 @@ void initThread(QThread &vThread); void quitThread(); - void transmitFrame(Can_Id vCan_Id, const QByteArray &vData = 0); ChannelGroup checkChannel(quint32 vFrameId, bool *vOK = nullptr); + void transmitFrame (Can_Id vCan_Id, const QByteArray &vData = 0); + void appendHead (Can_Id vCan_Id, const QByteArray &vData ); + void trnsmtHead (); + void removeHead (); private slots: // Should be private for thread safety and is connected internally. void onFrameTransmit(Can_Id vCan_Id, const QByteArray &vData ); // GUI => CAN void onFrameReceive ( const QCanBusFrame &vFrame ); // GUI <= CAN + void onFrameWritten (qint64 vCount ); // GUI <= CAN signals: /*! Index: sources/canbus/messageglobals.h =================================================================== diff -u -r56eea041fb0995182b3d3ea0c0ac19e4933a2d3d -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision 56eea041fb0995182b3d3ea0c0ac19e4933a2d3d) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -31,14 +31,20 @@ #define SEQUENCE_MAX INT16_MAX /*! + * \brief FrameCount + * \details The maximum unsigned integer value to be used as the frame count + */ +typedef quint64 FrameCount; + +/*! * \brief Payload Length * \details List of each ActionID required data (in byte) length in the message. * So the data collector has to collect this amount of bytes as payload of a message. */ const QHash payloadLen { {Gui::GuiActionType::PowerOff , 1 }, {Gui::GuiActionType::PowerOffBroadcast , 0 }, - {Gui::GuiActionType::KeepAlive , 0 }, + {Gui::GuiActionType::KeepAlive , 255 }, // 0 => 255 to be able to run a multi-frame test. {Gui::GuiActionType::BloodFlow , 7 * 4 }, // 7 parameters each 4bytes {Gui::GuiActionType::DialysateInletFlow , 7 * 4 }, // 7 parameters each 4bytes {Gui::GuiActionType::DialysateOutletFlow, 7 * 4 }, // 7 parameters each 4bytes @@ -82,7 +88,9 @@ * \details The Valid Can Bus MessageID of each frame */ enum Can_Id : quint16 { - eChlid_NONE = 0x000, + eChlid_LOWEST = 0x7FF, + eChlid_NONE = 0x7FF, + // Broadcasts //// Alarm eChlid_HD_Alarm = 0x001, ///< HD alarm broadcast Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r56eea041fb0995182b3d3ea0c0ac19e4933a2d3d -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 56eea041fb0995182b3d3ea0c0ac19e4933a2d3d) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -61,10 +61,14 @@ ok = false; } break; + case Gui::GuiActionType::KeepAlive: // Nothing needs to be done. // KeepAlive has No data. // Mentioned in the switch/case to be registered as a valid message. + // + // Note : added this line to be able to do the Fake Test + vPayload = Format::fromVariant(vData[0]); break; case Gui::GuiActionType::Acknow: @@ -131,7 +135,7 @@ QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + QString("%1 # %2 %3") - .arg(vMessage.can_id,3,16,QChar('0')) + .arg(vMessage.can_id, 3, 16, QChar('0')) .arg(mActionIdHexString) .arg(QString(vMessage.data.toHex('.'))); LOG_ERROR(logMessage); @@ -203,7 +207,6 @@ ok = true; break; - case Gui::GuiActionType::PressureOcclusion: printUnhandled (vMessage); ok = true; Index: sources/gui/guiview.cpp =================================================================== diff -u -r70a248b93720a46cb3a0f60b092698acd2acc7c1 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/gui/guiview.cpp (.../guiview.cpp) (revision 70a248b93720a46cb3a0f60b092698acd2acc7c1) +++ sources/gui/guiview.cpp (.../guiview.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -26,7 +26,7 @@ * \param parent - QObject parent owner object. * Qt handles the children destruction by their parent objects life-cycle. */ -GuiView::GuiView(QQuickItem *parent) +GuiView::GuiView(QObject *parent) { Q_UNUSED(parent) initConnections(); Index: sources/gui/guiview.h =================================================================== diff -u -rc6a09899d2e46dc0bda5a6b994aa257953626f97 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/gui/guiview.h (.../guiview.h) (revision c6a09899d2e46dc0bda5a6b994aa257953626f97) +++ sources/gui/guiview.h (.../guiview.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -25,12 +25,12 @@ // namespace namespace Gui { -class GuiView : public QQuickItem +class GuiView : public QObject { Q_OBJECT public: - explicit GuiView(QQuickItem *parent = nullptr); + explicit GuiView(QObject *parent = nullptr); private: void initConnections(); Index: sources/gui/qml/components/ModalDialog.qml =================================================================== diff -u -r1b060ccba8bfccf34d6a7a5ddd6d94eb6d149829 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/gui/qml/components/ModalDialog.qml (.../ModalDialog.qml) (revision 1b060ccba8bfccf34d6a7a5ddd6d94eb6d149829) +++ sources/gui/qml/components/ModalDialog.qml (.../ModalDialog.qml) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -59,7 +59,6 @@ } } - NumberAnimation { id: _autoHideAnimation running: false target: _root Index: sources/main.h =================================================================== diff -u -rc6a09899d2e46dc0bda5a6b994aa257953626f97 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/main.h (.../main.h) (revision c6a09899d2e46dc0bda5a6b994aa257953626f97) +++ sources/main.h (.../main.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -40,3 +40,8 @@ static vCLASS _instance; \ return _instance; \ } + +extern int gFakeInterval; +extern QByteArray gFakeData; +extern const char*gFakeData_default; +extern bool gSendEmptyKeepAwake; Index: sources/maintimer.cpp =================================================================== diff -u -r8c69137f18382bdc55a5678e6ed44a7683fe4dea -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/maintimer.cpp (.../maintimer.cpp) (revision 8c69137f18382bdc55a5678e6ed44a7683fe4dea) +++ sources/maintimer.cpp (.../maintimer.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -17,6 +17,7 @@ //Project #include "logger.h" +#include "filehandler.h" /*! * \brief MainTimer::MainTimer @@ -33,7 +34,11 @@ */ bool MainTimer::init() { - startTimer(_interval); + if (gFakeInterval) { + startTimer(gFakeInterval); + } else { + startTimer(_interval); + } LOG_EVENT(QObject::tr("Main Timer Initialized")); return true; } Index: sources/utility/format.cpp =================================================================== diff -u -rc6a09899d2e46dc0bda5a6b994aa257953626f97 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/utility/format.cpp (.../format.cpp) (revision c6a09899d2e46dc0bda5a6b994aa257953626f97) +++ sources/utility/format.cpp (.../format.cpp) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -13,12 +13,8 @@ */ #include "format.h" -Format::Format() -{ +Format::Format() { } -} - - QString Format::toHexString(quint16 vValue, bool vWith0x, quint8 vLen) { if ( vWith0x ) { return "0x" + QString("%1").arg(vValue,0,16).rightJustified(vLen, '0').toUpper(); @@ -43,9 +39,15 @@ QByteArray mData; if(vData.type() == QVariant::String) { mData += vData.toByteArray(); - } else { - mData += vData.toUInt(); + return mData; } + + if(vData.type() == QVariant::ByteArray) { + mData += vData.toByteArray(); + return mData; + } + + mData += vData.toUInt(); return mData; } Index: sources/utility/types.h =================================================================== diff -u -re58b907a69d4ca7daa77d69791593b886d1b80e8 -rbb8f39a014644c70b832dd2a784f62fa9f6b6106 --- sources/utility/types.h (.../types.h) (revision e58b907a69d4ca7daa77d69791593b886d1b80e8) +++ sources/utility/types.h (.../types.h) (revision bb8f39a014644c70b832dd2a784f62fa9f6b6106) @@ -17,6 +17,10 @@ #include #include #include + +// stl +#include + // Project #include "format.h" #include "logger.h" @@ -36,72 +40,84 @@ return tmp; } }; -/*! - * \brief The F32 union - * \details This is the union which will be used to extract the bytes of a float type value - * 4 bytes - */ -union F32{ - float value = 0; - quint8 bytes[sizeof(float)]; -}; -/*! - * \brief The U08 union - * \details This is the union which will be used to extract the byte of an unsigned char type value - * 1 byte - */ -union U08 { - quint8 value = 0; - quint8 bytes[sizeof(quint8)]; -}; + /*! + * \brief The F32 union + * \details This is the union which will be used to extract the bytes of a float type value + * 4 bytes + */ + union F32{ + float value = 0; + quint8 bytes[sizeof(float)]; + }; -/*! - * \brief The U16 union - * \details This is the union which will be used to extract the bytes of an unsigned char type value - * 2 bytes - */ -union U16 { - quint16 value = 0; - quint8 bytes[sizeof(quint16)]; -}; + /*! + * \brief The U08 union + * \details This is the union which will be used to extract the byte of an unsigned char type value + * 1 byte + */ + union U08 { + quint8 value = 0; + quint8 bytes[sizeof(quint8)]; + }; -/*! - * \brief The U32 union - * \details This is the union which will be used to extract the bytes of an unsigned int type value - * 4 bytes - */ -union U32 { - quint32 value = 0; - quint8 bytes[sizeof(quint32)]; -}; + /*! + * \brief The U16 union + * \details This is the union which will be used to extract the bytes of an unsigned char type value + * 2 bytes + */ + union U16 { + quint16 value = 0; + quint8 bytes[sizeof(quint16)]; + }; -/*! - * \brief The S32 union - * \details This is the union which will be used to extract the bytes of an signed int type value - * 4 bytes - */ -union S16 { - qint16 value = 0; - quint8 bytes[sizeof(qint16)]; -}; + /*! + * \brief The U32 union + * \details This is the union which will be used to extract the bytes of an unsigned int type value + * 4 bytes + */ + union U32 { + quint32 value = 0; + quint8 bytes[sizeof(quint32)]; + }; -/*! - * \brief The S32 union - * \details This is the union which will be used to extract the bytes of an signed int type value - * 4 bytes - */ -union S32 { - qint32 value = 0; - quint8 bytes[sizeof(qint32)]; -}; + /*! + * \brief The S32 union + * \details This is the union which will be used to extract the bytes of an signed int type value + * 4 bytes + */ + union S16 { + qint16 value = 0; + quint8 bytes[sizeof(qint16)]; + }; -static bool floatCompare(float f1, float f2); + /*! + * \brief The S32 union + * \details This is the union which will be used to extract the bytes of an signed int type value + * 4 bytes + */ + union S32 { + qint32 value = 0; + quint8 bytes[sizeof(qint32)]; + }; -template < typename T > -static bool getValue(const QByteArray &vData, int &vIndex, T &vValue); -static bool getBits (const QByteArray &vData, int &vIndex, QBitArray &vFlags, int vLen); + static bool floatCompare(float f1, float f2); + template < typename T > + static bool getValue(const QByteArray &vData, int &vIndex, T &vValue); + static bool getBits (const QByteArray &vData, int &vIndex, QBitArray &vFlags, int vLen); + + template < typename T > + static T safeIncrement(T &vValue, quint8 vStep = 1) { + if (!vStep) vStep = 1; // step can't be zero + T mMax = (T)(pow(2, sizeof(T) * 8) - 1); + if ( vValue <= mMax ) { + vValue += vStep; + } else { + vValue = vStep - (mMax - vStep); + } + return vValue; + } }; template < typename T >