diff --git a/qdlt/dlt_protocol.h b/qdlt/dlt_protocol.h index 729eb7aa..3b0dcfb3 100644 --- a/qdlt/dlt_protocol.h +++ b/qdlt/dlt_protocol.h @@ -164,7 +164,10 @@ #define DLT_SCOD_HEX 0x00010000 #define DLT_SCOD_BIN 0x00018000 /* - * Definitions of DLT services. + * Definitions of DLT service IDs. + * + * Should correspond to AUTOSAR DLT protocol specification the DLT service + * implementation conforms to. */ #define DLT_SERVICE_ID_SET_LOG_LEVEL 0x01 /**< Service ID: Set log level */ #define DLT_SERVICE_ID_SET_TRACE_STATUS 0x02 /**< Service ID: Set trace status */ diff --git a/qdlt/dltmessagematcher.h b/qdlt/dltmessagematcher.h index 88cf41b8..318577b2 100644 --- a/qdlt/dltmessagematcher.h +++ b/qdlt/dltmessagematcher.h @@ -11,6 +11,17 @@ class QDltMsg; +/** + * A class which can be used to set search parameters for matching on potential DLT messages. + * + * Offers functions to search different parts of a DLT message. + * Offers the option to search either the header, the payload, or both. + * Searches can be case-sensitive - default is case-insensitive. + * The pattern to search a payload can be either a regular expression or plain text. + * + * Currently used by the UI search dialog. + * @see SearchDialog + */ class QDLT_EXPORT DltMessageMatcher { public: @@ -46,9 +57,32 @@ class QDLT_EXPORT DltMessageMatcher m_messageIdFormat = msgIdFormat; } + /** + * + * @return `true` if `msg` matches all of: + * - application ID set in `this` + * - context ID set in `this` + * - timestamp range set in `this` + * - pattern matches either the `msg` header or payload + * `false` otherwise. + * + * @see SearchDialog::findMessages + */ bool match(const QDltMsg& message, const Pattern& pattern) const; + private: + + /** + * Match the application ID in `appId` against `this` + * + * @return `true` if `this` has no application ID set or the IDs match exactly, false otherwise + */ bool matchAppId(const QString& appId) const; + /** + * Match the context ID in `ctxId` against `this` + * + * @return `true` if `this` has no application ID set or the IDs match exactly, false otherwise + */ bool matchCtxId(const QString& ctxId) const; bool matchTimestampRange(unsigned int ts) const; private: diff --git a/qdlt/fieldnames.h b/qdlt/fieldnames.h index 447d2434..80acd5e0 100644 --- a/qdlt/fieldnames.h +++ b/qdlt/fieldnames.h @@ -6,6 +6,12 @@ #include #include +/** + * Class to obtain human-readable names for DLT message parts, + * and UI element properties. + * + * @see MainWindow::initView + */ class QDLT_EXPORT FieldNames : public QObject { Q_OBJECT @@ -42,9 +48,9 @@ class QDLT_EXPORT FieldNames : public QObject static bool getColumnShown(Fields cn,QDltSettingsManager *settings = NULL); signals: - + public slots: - + }; #endif // FIELDNAMES_H diff --git a/qdlt/qdltargument.h b/qdlt/qdltargument.h index 04c53ea1..581c49ff 100644 --- a/qdlt/qdltargument.h +++ b/qdlt/qdltargument.h @@ -31,7 +31,8 @@ //! One argument of a DLT message. /*! This class contains one argument of a DLT message. - A QDltMessage contains several Arguments. + A QDltMessage contains several QDltArgument, like a DLT message contains + multiple arguments. */ class QDLT_EXPORT QDltArgument { diff --git a/qdlt/qdltbase.h b/qdlt/qdltbase.h index bccc7496..219ee969 100644 --- a/qdlt/qdltbase.h +++ b/qdlt/qdltbase.h @@ -28,10 +28,11 @@ constexpr const auto DLT_MAX_MESSAGE_LEN = 1024*64; -//! Base class for all DLT classes. -/*! - This class contains helper functions needed for all DLT operations and classes. -*/ +/** + * Base class for all DLT classes. + * + * This class contains helper functions needed for all DLT operations and classes. + */ class QDLT_EXPORT QDlt { public: diff --git a/qdlt/qdltconnection.h b/qdlt/qdltconnection.h index 656f29c3..fe5e4c78 100644 --- a/qdlt/qdltconnection.h +++ b/qdlt/qdltconnection.h @@ -82,6 +82,11 @@ class QDLT_EXPORT QDltDataView int m_position; }; +/** + * Base class for classes representing a connection for user commands & UI. + * + * Has concrete methods. + */ class QDLT_EXPORT QDltConnection { @@ -102,6 +107,11 @@ class QDLT_EXPORT QDltConnection bool parseAscii(QDltMsg &msg); void clear(); + /** + * Add data to a connection, to be parsed. + * + * @see MainWindow::read + */ void add(const QByteArray &bytes); QByteArray data; diff --git a/qdlt/qdltcontrol.h b/qdlt/qdltcontrol.h index 4c1abac6..6455f1ef 100644 --- a/qdlt/qdltcontrol.h +++ b/qdlt/qdltcontrol.h @@ -32,6 +32,17 @@ #include "export_rules.h" +/** + * This class contains various signals used in MainWindow, corresponding to user commands. + * Execution of the commands is in UI code. Signals defined here are + * connected to slots in e.g. MainWindow. + * (rem. private slots can be invoked by arbitrary components) + * + * Also passed to plugins via MainWindow -> QDltPluginManager + * + * @see MainWindow::sendInjection + * @see MainWindow::jumpToMsgSignal + */ class QDLT_EXPORT QDltControl : public QObject { Q_OBJECT diff --git a/qdlt/qdltctrlmsg.h b/qdlt/qdltctrlmsg.h index acda8b41..252de83c 100644 --- a/qdlt/qdltctrlmsg.h +++ b/qdlt/qdltctrlmsg.h @@ -12,6 +12,16 @@ namespace qdlt::msg::payload { +/** + * Most DLT service IDs referenced here can be found in the AUTOSAR DLT specification. + * + * Note the AUTOSAR spec does not reserve IDs. + */ + +/** + * A struct associated with the `GetLogInfo` DLT service command, + * to retrieve log levels for all registered contexts. + */ struct GetLogInfo { struct App { struct Ctx { @@ -30,15 +40,27 @@ struct GetLogInfo { std::vector apps; }; +/** + * A struct associated with the `GetSoftwareVersion` DLT service command, + * to retrieve a string denoting the system's software version. + */ struct GetSoftwareVersion { }; +/** + * A struct associated with the `GetDefaultLogLevel` DLT service command, + * to retrieve the currently set default log level. + */ struct GetDefaultLogLevel { uint8_t logLevel; uint8_t status; }; +/** + * A struct associated with the `GetDefaultLogLevel` DLT service command, + * to set a log level. + */ struct SetLogLevel { uint8_t status; }; diff --git a/qdlt/qdltdefaultfilter.h b/qdlt/qdltdefaultfilter.h index b1adf642..4d3bbdf8 100644 --- a/qdlt/qdltdefaultfilter.h +++ b/qdlt/qdltdefaultfilter.h @@ -36,6 +36,12 @@ #include "qdltfilterlist.h" +/** + * "Default" filters loaded by MainWindow - initialises the indexer. + * this ∋ `QDltFilterList` ∋ `QDltFilter` + * + * @see MainWindow + */ class QDLT_EXPORT QDltDefaultFilter { public: diff --git a/qdlt/qdltexporter.h b/qdlt/qdltexporter.h index a4652cea..e84d9bcb 100644 --- a/qdlt/qdltexporter.h +++ b/qdlt/qdltexporter.h @@ -15,6 +15,13 @@ #define QDLT_DEFAULT_EXPORT_SIGNATURE "ITSOEACNYUMRP" #define QDLT_DEFAULT_EXPORT_DELIMITER ',' +/** + * Class used for UI export functions. Currently implemented as a thread that must be fed + * messages to export. + * + * There is no interface toward a collection of DLT messages, but instead + * functions are referencing single QDltMsg instances. This is suboptimal. + */ class QDLT_EXPORT QDltExporter : public QThread { Q_OBJECT diff --git a/qdlt/qdltfile.h b/qdlt/qdltfile.h index 1b508645..600af53c 100644 --- a/qdlt/qdltfile.h +++ b/qdlt/qdltfile.h @@ -35,6 +35,9 @@ #include #include +/** + * Object containing a single QFile and an index to offsets of DLT messages in it. + */ class QDLT_EXPORT QDltFileItem { public: @@ -49,11 +52,12 @@ class QDLT_EXPORT QDltFileItem }; -//! Access to a DLT log file. -/*! - This class provide access to DLT log file. - This class is currently not thread safe. -*/ +/** + * Access to a DLT log file. + * + * This class provide access to DLT log file. + * This class is currently not thread safe. + */ class QDLT_EXPORT QDltFile : public QDlt { public: diff --git a/qdlt/qdltfilter.h b/qdlt/qdltfilter.h index ccf4f11b..770442fd 100644 --- a/qdlt/qdltfilter.h +++ b/qdlt/qdltfilter.h @@ -36,6 +36,9 @@ #include "qdltmsg.h" +/** + * Represents a filter set in the UI. + */ class QDLT_EXPORT QDltFilter { public: diff --git a/qdlt/qdltfilterindex.h b/qdlt/qdltfilterindex.h index 62eeb237..54329639 100644 --- a/qdlt/qdltfilterindex.h +++ b/qdlt/qdltfilterindex.h @@ -32,6 +32,11 @@ #include "export_rules.h" #include "qdltfilterlist.h" +/** + * Maybe supposed to represent a file with filters applied to it. Unclear usage of index. + * + * Missing getters / interface. + */ class QDLT_EXPORT QDltFilterIndex { public: diff --git a/qdlt/qdltfilterlist.h b/qdlt/qdltfilterlist.h index 62da6cc6..8ad6c832 100644 --- a/qdlt/qdltfilterlist.h +++ b/qdlt/qdltfilterlist.h @@ -35,7 +35,9 @@ #include #include - +/** + * A list of filters applied in the UI + */ class QDLT_EXPORT QDltFilterList { public: diff --git a/qdlt/qdltimporter.h b/qdlt/qdltimporter.h index c9e92fea..bdff0256 100644 --- a/qdlt/qdltimporter.h +++ b/qdlt/qdltimporter.h @@ -156,6 +156,12 @@ typedef struct mdf_hdr { quint64 link_count; /* number of links in link section */ } PACKED mdf_hdr_t; +/** + * Class used for UI import functions. Currently implemented as a thread that must be fed + * messages individually - this is suboptimal. + * + * Function names are nondescript. + */ class QDLT_EXPORT QDltImporter : public QThread { Q_OBJECT diff --git a/qdlt/qdltipconnection.h b/qdlt/qdltipconnection.h index 19095ad4..d0478f98 100644 --- a/qdlt/qdltipconnection.h +++ b/qdlt/qdltipconnection.h @@ -32,6 +32,15 @@ #include "export_rules.h" #include "qdltconnection.h" +/** + * A (conceptual) connection toward a DLT service. + * + * Currently set up as an inheritance scheme - QDltConnection has concrete functions + * for parsing. + * This class keeps track of the remote host(name). Also port, although IP has no port info. + * + * Used by the UI (main window). + */ class QDLT_EXPORT QDltIPConnection : public QDltConnection { public: diff --git a/qdlt/qdltmessagedecoder.h b/qdlt/qdltmessagedecoder.h index 3e073a7a..a0aa3bb9 100644 --- a/qdlt/qdltmessagedecoder.h +++ b/qdlt/qdltmessagedecoder.h @@ -27,6 +27,12 @@ class QDltMsg; +/** + * An interface for modifying a QDltMsg based on plugin-specific functionality. + * + * Designing the decoding to be done by expecting a message to be its own object + * is suboptimal and does not allow efficient organisation (memory, temporal, or otherwise). + */ class QDLT_EXPORT QDltMessageDecoder { public: diff --git a/qdlt/qdltmsg.cpp b/qdlt/qdltmsg.cpp index 5b8b23b3..b6bf7794 100644 --- a/qdlt/qdltmsg.cpp +++ b/qdlt/qdltmsg.cpp @@ -309,6 +309,15 @@ quint32 QDltMsg::checkMsgSize(const char *data,quint32 size,bool supportDLTv2) } } +/** + * Attempt to parse a valid DLT message from `buf`, with an optional storage header. + * + * It will attempt to parse DLTv1 only if `supportDLTv2` is `false`. + * + * @return `false` if there is not enough data in `buf` for a valid message header or + * the entire message as indicated in the header's length field. Also `false` if + * arguments could not be parsed correctly. Otherwise, `true`. + */ bool QDltMsg::setMsg(const QByteArray& buf, bool withStorageHeader,bool supportDLTv2) { unsigned int offset; @@ -926,6 +935,14 @@ bool QDltMsg::parseArguments() return true; } +/** + * Attempt to create a valid DLT messages in `buf`, optionally + * preceded by a storage header, from the state of `this` object. + * + * Modifies `this.payload` to contain the message's arguments. + * + * @return `false` if calling `QDltArgument::getArgument` fails, `true` otherwise + */ bool QDltMsg::getMsg(QByteArray &buf,bool withStorageHeader) { DltStorageHeader storageheader; DltStandardHeader standardheader; @@ -1073,6 +1090,12 @@ int QDltMsg::sizeArguments() const return arguments.size(); } +/** + * Set `argument` to the argument of this message at `index`. + * + * @return `false` if `index` is outside the range of currently contained arguments, `true` + * otherwise. + */ bool QDltMsg::getArgument(int index,QDltArgument &argument) const { if(index<0 || index>=arguments.size()) diff --git a/qdlt/qdltmsg.h b/qdlt/qdltmsg.h index aebd9e60..6b7018c1 100644 --- a/qdlt/qdltmsg.h +++ b/qdlt/qdltmsg.h @@ -28,18 +28,18 @@ #include "qdltbase.h" #include "qdltargument.h" -//! Access to a DLT message. -/*! - This class provide access to a single DLT message from a DLT log file. - This class is currently not thread safe. -*/ +/** + * An object modelling a DLT message. + * Can be used to create custom messages and to parse valid DLT messages (e.g. from a file). + * + * @warning No functions in this class are thread-safe. + */ class QDLT_EXPORT QDltMsg { public: - //! Constructor. - /*! - This call clears all variables of the argument. - */ + /** + * Constructor. Clears all variables of the argument. + */ QDltMsg(); //! The type of the DLT message. diff --git a/qdlt/qdltoptmanager.h b/qdlt/qdltoptmanager.h index 8ce3cd57..6175c847 100644 --- a/qdlt/qdltoptmanager.h +++ b/qdlt/qdltoptmanager.h @@ -41,6 +41,9 @@ enum class e_inputmode SERIAL = 2, }; +/** + * Holder for & parser of application options (from command-line / argv). + */ class QDLT_EXPORT QDltOptManager { public: diff --git a/qdlt/qdltplugin.h b/qdlt/qdltplugin.h index 5bb4688a..8d6b65c6 100644 --- a/qdlt/qdltplugin.h +++ b/qdlt/qdltplugin.h @@ -8,10 +8,10 @@ #include "export_rules.h" -//! Access class to a DLT Plugin to decode, view and control DLT messages -/*! - This class loads a DLT Viewer Plugin library and provides functions to access the plugin. -*/ +/** + * Class representing a DLT plugin. Plugins can be used to decode, view and control DLT messages. + * This class loads a DLT Viewer Plugin library and provides functions to access the plugin. + */ class QDLT_EXPORT QDltPlugin { public: diff --git a/qdlt/qdltsegmentedmsg.h b/qdlt/qdltsegmentedmsg.h index 8c03daf5..58a6b74b 100644 --- a/qdlt/qdltsegmentedmsg.h +++ b/qdlt/qdltsegmentedmsg.h @@ -26,10 +26,14 @@ #include -//! Combine segmented network messages -/*! - This class combines several segmented network message to a single message -*/ +/** + * Combine segmented network messages + * This class combines several segmented network message to a single message. + * Must first add those messages using the `add()` function. + * + * this -> DltSegmentationPlugin::decodeMsg -> QDltMsg + * + */ class QDLT_EXPORT QDltSegmentedMsg { public: diff --git a/qdlt/qdltserialconnection.h b/qdlt/qdltserialconnection.h index fcd918ff..c4932b9b 100644 --- a/qdlt/qdltserialconnection.h +++ b/qdlt/qdltserialconnection.h @@ -35,6 +35,16 @@ class QSerialPort; +/** + * Represents a serial connection for the purposes of the UI. + * + * Currently set up as an inheritance scheme - QDltConnection has concrete functions + * for parsing. + * + * @see QDltIPConnection + * @see QDltTCPConnection + * @see QDltUDPConnection + */ class QDLT_EXPORT QDltSerialConnection : public QDltConnection { public: diff --git a/qdlt/qdltsettingsmanager.h b/qdlt/qdltsettingsmanager.h index 7cc64fca..1a2d2fc4 100644 --- a/qdlt/qdltsettingsmanager.h +++ b/qdlt/qdltsettingsmanager.h @@ -30,6 +30,12 @@ #define DEFAULT_REFRESH_RATE 20 +/** + * Application options. Used by the UI. + * + * @see MainWindow + * @see SettingsDialog + */ class QDLT_EXPORT QDltSettingsManager { // Singleton pattern diff --git a/qdlt/qdlttcpconnection.h b/qdlt/qdlttcpconnection.h index f650bf8d..c11c8687 100644 --- a/qdlt/qdlttcpconnection.h +++ b/qdlt/qdlttcpconnection.h @@ -34,6 +34,16 @@ class QTcpSocket; +/** + * Represents a TCP connection for the purposes of the UI. + * + * Currently set up as an inheritance scheme - QDltConnection has concrete functions + * for parsing. + * + * @see QDltIPConnection + * @see QDltSerialConnection + * @see QDltUDPConnection + */ class QDLT_EXPORT QDltTCPConnection : public QDltIPConnection { public: diff --git a/qdlt/qdltudpconnection.h b/qdlt/qdltudpconnection.h index 208eee19..10f6c8bb 100644 --- a/qdlt/qdltudpconnection.h +++ b/qdlt/qdltudpconnection.h @@ -34,6 +34,16 @@ class QUdpSocket; +/** + * Represents receiving messages from a UDP remote endpoint for the purposes of the UI. + * + * Currently set up as an inheritance scheme - QDltConnection has concrete functions + * for parsing. + * + * @see QDltIPConnection + * @see QDltSerialConnection + * @see QDltTCPConnection + */ class QDLT_EXPORT QDltUDPConnection : public QDltIPConnection { public: diff --git a/src/searchdialog.cpp b/src/searchdialog.cpp index 1d0da1b0..504798ee 100644 --- a/src/searchdialog.cpp +++ b/src/searchdialog.cpp @@ -192,6 +192,14 @@ void SearchDialog::focusRow(long int searchLine) model->modelChanged(); } +/** + * Called from findNextClicked and findPreviousClicked + * + * @return 2 if an invalid context or application ID is set for search, + * 1 if a match of the search text is found or an invalid regular expression is given in search + * text, + * 0 otherwise. + */ int SearchDialog::find() { isSearchCancelled = false; @@ -337,6 +345,9 @@ int SearchDialog::find() fIs_APID_CTID_requested = false; } + /* Actual search taking place here, + * will set this->match accordingly. + */ findMessages(startLine,searchBorder,searchTextRegExpression); emit searchProgressChanged(false); @@ -437,6 +448,10 @@ void SearchDialog::findMessages(long int searchLine, long int searchBorder, QReg pluginManager->decodeMsg(msg, fSilentMode); } + /* + * Search for a match + * Note the message `msg` is decoded here (see above) + */ const bool matchFound = getRegExp() ? matcher.match(msg, searchTextRegExp) : matcher.match(msg, getText()); if (!matchFound) {