From d694407d5a68b0b5bc9a16427d60aa09af77b30d Mon Sep 17 00:00:00 2001 From: Viktor Kopp Date: Sun, 5 Jan 2025 11:48:00 +0100 Subject: [PATCH] Remove inheritence of QDltMsg from QDlt Remove unnecessary code Signed-off-by: Viktor Kopp --- plugin/dltdbusplugin/dltdbusplugin.cpp | 4 +- plugin/dltviewerplugin/dltviewerplugin.cpp | 6 +-- plugin/nonverboseplugin/nonverboseplugin.cpp | 2 +- qdlt/qdltargument.cpp | 2 - qdlt/qdltargument.h | 1 + qdlt/qdltmsg.cpp | 49 +++++++++----------- qdlt/qdltmsg.h | 20 ++------ qdlt/qdltsegmentedmsg.cpp | 3 -- src/dltfileindexerthread.cpp | 6 +-- src/mainwindow.cpp | 14 +++--- 10 files changed, 43 insertions(+), 64 deletions(-) diff --git a/plugin/dltdbusplugin/dltdbusplugin.cpp b/plugin/dltdbusplugin/dltdbusplugin.cpp index bbf78b3d..f9072550 100644 --- a/plugin/dltdbusplugin/dltdbusplugin.cpp +++ b/plugin/dltdbusplugin/dltdbusplugin.cpp @@ -305,7 +305,7 @@ void DltDBusPlugin::selectedIdxMsg(int /*index*/, QDltMsg &msg) text += QString("Destination%1").arg(dbusMsg.getDestination()); text += QString("Sender%1").arg(dbusMsg.getSender()); QByteArray signature = dbusMsg.getSignature(); - text += QString("Signature%1").arg(msg.toAsciiTable(signature,false,false,true,256,256,false)); + text += QString("Signature%1").arg(QDlt::toAsciiTable(signature,false,false,true,256,256,false)); text += QString("UnixFds%1").arg(dbusMsg.getUnixFds()); text += QString(""); @@ -315,7 +315,7 @@ void DltDBusPlugin::selectedIdxMsg(int /*index*/, QDltMsg &msg) /* DBus message payload Hex*/ QByteArray payload = dbusMsg.getPayload(); text = QString("

Size: %1

").arg(payload.size()); - text += msg.toAsciiTable(payload,true,true,false); + text += QDlt::toAsciiTable(payload,true,true,false); form->setTextBrowserPayloadHex(text); /* decode DBus payload */ diff --git a/plugin/dltviewerplugin/dltviewerplugin.cpp b/plugin/dltviewerplugin/dltviewerplugin.cpp index ac3e193a..4e90d27a 100644 --- a/plugin/dltviewerplugin/dltviewerplugin.cpp +++ b/plugin/dltviewerplugin/dltviewerplugin.cpp @@ -288,13 +288,13 @@ void DltViewerPlugin::selectedIdxMsg(int index, QDltMsg &msg) { QByteArray bytes_payload = msg.getPayload(); /* Show Ascii output */ - form->setTextBrowserAscii(msg.toAsciiTable(bytes_header,false,false,true,8,64)+msg.toAsciiTable(bytes_payload,false,false,true,8,64)); + form->setTextBrowserAscii(QDlt::toAsciiTable(bytes_header,false,false,true,8,64)+QDlt::toAsciiTable(bytes_payload,false,false,true,8,64)); /* Show Binary output */ - form->setTextBrowserBinary(msg.toAsciiTable(bytes_header,true,true,false)+msg.toAsciiTable(bytes_payload,true,true,false)); + form->setTextBrowserBinary(QDlt::toAsciiTable(bytes_header,true,true,false)+QDlt::toAsciiTable(bytes_payload,true,true,false)); /* Show Mixed output */ - form->setTextBrowserMixed(msg.toAsciiTable(bytes_header,true,true,true)+msg.toAsciiTable(bytes_payload,true,true,true)); + form->setTextBrowserMixed(QDlt::toAsciiTable(bytes_header,true,true,true)+QDlt::toAsciiTable(bytes_payload,true,true,true)); } diff --git a/plugin/nonverboseplugin/nonverboseplugin.cpp b/plugin/nonverboseplugin/nonverboseplugin.cpp index 01eb179e..c30eaa21 100644 --- a/plugin/nonverboseplugin/nonverboseplugin.cpp +++ b/plugin/nonverboseplugin/nonverboseplugin.cpp @@ -636,7 +636,7 @@ bool NonverbosePlugin::decodeMsg(QDltMsg &msg, int triggeredByUser) { if((unsigned int)payload.size()<(offset+sizeof(unsigned short))) break; - if(argument.getEndianness() == QDltMsg::DltEndiannessLittleEndian) + if(argument.getEndianness() == QDlt::DltEndiannessLittleEndian) length = *((unsigned short*) (payload.constData()+offset)); else length = DLT_SWAP_16(*((unsigned short*) (payload.constData()+offset))); diff --git a/qdlt/qdltargument.cpp b/qdlt/qdltargument.cpp index 2f1cfe51..8c6dc70a 100644 --- a/qdlt/qdltargument.cpp +++ b/qdlt/qdltargument.cpp @@ -19,8 +19,6 @@ * @licence end@ */ -#include - #include "qdltargument.h" extern "C" diff --git a/qdlt/qdltargument.h b/qdlt/qdltargument.h index 477332b8..04c53ea1 100644 --- a/qdlt/qdltargument.h +++ b/qdlt/qdltargument.h @@ -23,6 +23,7 @@ #define QDLT_ARGUMENT_H #include +#include #include "qdltbase.h" #include "export_rules.h" diff --git a/qdlt/qdltmsg.cpp b/qdlt/qdltmsg.cpp index 381039b1..f9eed48a 100644 --- a/qdlt/qdltmsg.cpp +++ b/qdlt/qdltmsg.cpp @@ -19,9 +19,6 @@ * @licence end@ */ -#include -#include - #include "qdltmsg.h" extern "C" @@ -29,6 +26,9 @@ extern "C" #include "dlt_common.h" } +#include +#include + namespace { constexpr const char * const qDltMessageType[] = {"log","app_trace","nw_trace","control","","","",""}; constexpr const char * const qDltLogInfo[] = {"","fatal","error","warn","info","debug","verbose","","","","","","","","",""}; @@ -49,11 +49,6 @@ QDltMsg::QDltMsg() clear(); } -QDltMsg::~QDltMsg() -{ - -} - QString QDltMsg::getStringFromId(const char *text) { if(text[1]==0) @@ -69,7 +64,7 @@ QString QDltMsg::getStringFromId(const char *text) QString QDltMsg::getTypeString() const { - return QString((type>=0 && type<=7)?qDltMessageType[type]:""); + return (type >= 0 && type <= 7) ? qDltMessageType[type] : ""; } QString QDltMsg::getSubtypeString() const @@ -292,7 +287,7 @@ quint32 QDltMsg::checkMsgSize(const char *data,quint32 size,bool supportDLTv2) withTags = htyp2 & 0x0200; withSourceFileNameLineNumber = htyp2 & 0x0100; /* TODO: Endianess of payload not defined in DLTv2, undefined, set to LittleEndian by default */ - endianness = DltEndiannessLittleEndian; + endianness = QDlt::DltEndiannessLittleEndian; /* get Message Counter */ messageCounter = *((quint8*) (data + 4 + sizeStorageHeader)); @@ -501,10 +496,10 @@ bool QDltMsg::setMsg(const QByteArray& buf, bool withStorageHeader,bool supportD /* extract endianness */ if(DLT_IS_HTYP_MSBF(standardheader->htyp)) { - endianness = DltEndiannessBigEndian; + endianness = QDlt::DltEndiannessBigEndian; } else { - endianness = DltEndiannessLittleEndian; + endianness = QDlt::DltEndiannessLittleEndian; } /* extract time */ @@ -543,7 +538,7 @@ bool QDltMsg::setMsg(const QByteArray& buf, bool withStorageHeader,bool supportD /* set messageid if non verbose */ if((mode == DltModeNonVerbose) && payload.size()>=4) { /* message id is always in big endian format */ - if(endianness == DltEndiannessLittleEndian) { + if(endianness == QDlt::DltEndiannessLittleEndian) { messageId = (*((unsigned int*) payload.constData())); } else { @@ -553,7 +548,7 @@ bool QDltMsg::setMsg(const QByteArray& buf, bool withStorageHeader,bool supportD /* set service id if message of type control */ if((type == DltTypeControl) && payload.size()>=4) { - if(endianness == DltEndiannessLittleEndian) + if(endianness == QDlt::DltEndiannessLittleEndian) ctrlServiceId = *((unsigned int*) payload.constData()); else ctrlServiceId = DLT_SWAP_32(*((unsigned int*) payload.constData())); @@ -627,7 +622,7 @@ bool QDltMsg::setMsg(const QByteArray& buf, bool withStorageHeader,bool supportD withTags = htyp2 & 0x0200; withSourceFileNameLineNumber = htyp2 & 0x0100; /* TODO: Endianess of payload not defined in DLTv2, undefined, set to LittleEndian by default */ - endianness = DltEndiannessLittleEndian; + endianness = QDlt::DltEndiannessLittleEndian; /* get Message Counter : always*/ messageCounter = *((quint8*) (buf.constData() + 4 + sizeStorageHeader)); @@ -876,7 +871,7 @@ bool QDltMsg::setMsg(const QByteArray& buf, bool withStorageHeader,bool supportD /* set service id if message of type control */ if((type == DltTypeControl) && payload.size()>=4) { - if(endianness == DltEndiannessLittleEndian) + if(endianness == QDlt::DltEndiannessLittleEndian) ctrlServiceId = *((unsigned int*) payload.constData()); else ctrlServiceId = DLT_SWAP_32(*((unsigned int*) payload.constData())); @@ -961,7 +956,7 @@ bool QDltMsg::getMsg(QByteArray &buf,bool withStorageHeader) { /* write standardheader */ standardheader.htyp = 0x01 << 5; /* intialise with version number 0x1 */ - if(endianness == DltEndiannessBigEndian) { + if(endianness == QDlt::DltEndiannessBigEndian) { standardheader.htyp |= DLT_HTYP_MSBF; } if(mode == DltModeVerbose) { @@ -1017,7 +1012,7 @@ void QDltMsg::clear() type = DltTypeUnknown; subtype = DltLogUnknown; mode = DltModeUnknown; - endianness = DltEndiannessUnknown; + endianness = QDlt::DltEndiannessUnknown; time = 0; microseconds = 0; timestamp = 0; @@ -1136,9 +1131,9 @@ QString QDltMsg::toStringPayload() const data = payload.mid(4,(payload.size()>260)?256:(payload.size()-4)); if(!data.isEmpty()) { - text += toAsciiTable(data,false,false,true,1024,1024,false); + text += QDlt::toAsciiTable(data,false,false,true,1024,1024,false); text += "|"; - text += toAscii(data, false); + text += QDlt::toAscii(data, false); } return text; } @@ -1157,7 +1152,7 @@ QString QDltMsg::toStringPayload() const { // Skip the ServiceID, Status and Lenght bytes and start from the String containing the ECU Software Version data = payload.mid(9,(payload.size()>265)?256:(payload.size()-9)); - text += toAscii(data,true); + text += QDlt::toAscii(data,true); } else if(getCtrlServiceId() == DLT_SERVICE_ID_CONNECTION_INFO) { @@ -1181,7 +1176,7 @@ QString QDltMsg::toStringPayload() const else { data = payload.mid(5,(payload.size()>261)?256:(payload.size()-5)); - text += toAscii(data); + text += QDlt::toAscii(data); } } else if(getCtrlServiceId() == DLT_SERVICE_ID_TIMEZONE) @@ -1191,7 +1186,7 @@ QString QDltMsg::toStringPayload() const DltServiceTimezone *service; service = (DltServiceTimezone*) payload.constData(); - if(endianness == DltEndiannessLittleEndian) + if(endianness == QDlt::DltEndiannessLittleEndian) text += QString("%1 s").arg(service->timezone); else text += QString("%1 s").arg(DLT_SWAP_32(service->timezone)); @@ -1200,13 +1195,13 @@ QString QDltMsg::toStringPayload() const else { data = payload.mid(5,(payload.size()>261)?256:(payload.size()-5)); - text += toAscii(data); + text += QDlt::toAscii(data); } } else { data = payload.mid(5,(payload.size()>261)?256:(payload.size()-5)); - text += toAscii(data); + text += QDlt::toAscii(data); } return text; @@ -1215,7 +1210,7 @@ QString QDltMsg::toStringPayload() const if( getType()==QDltMsg::DltTypeControl) { text += QString("[%1] ").arg(getCtrlServiceIdString()); data = payload.mid(4,(payload.size()>260)?256:(payload.size()-4)); - text += toAscii(data); + text += QDlt::toAscii(data); return text; } @@ -1520,7 +1515,7 @@ void QDltMsg::genMsg() // write standardheader standardheader.htyp = 0x01 << 5; /* intialise with version number 0x1 */ - if(endianness == DltEndiannessBigEndian) { + if(endianness == QDlt::DltEndiannessBigEndian) { standardheader.htyp |= DLT_HTYP_MSBF; } if(mode == DltModeVerbose) { diff --git a/qdlt/qdltmsg.h b/qdlt/qdltmsg.h index becb392d..b89b0150 100644 --- a/qdlt/qdltmsg.h +++ b/qdlt/qdltmsg.h @@ -22,12 +22,7 @@ #ifndef QDLT_MSG_H #define QDLT_MSG_H -#include #include -#include -#include -#include -#include #include "export_rules.h" #include "qdltbase.h" @@ -38,7 +33,7 @@ This class provide access to a single DLT message from a DLT log file. This class is currently not thread safe. */ -class QDLT_EXPORT QDltMsg : public QDlt +class QDLT_EXPORT QDltMsg { public: //! Constructor. @@ -47,11 +42,6 @@ class QDLT_EXPORT QDltMsg : public QDlt */ QDltMsg(); - //! Destructor. - /*! - */ - ~QDltMsg(); - //! The type of the DLT message. typedef enum { DltTypeUnknown = -2, DltTypeLog = 0,DltTypeAppTrace,DltTypeNwTrace,DltTypeControl } DltTypeDef; @@ -228,14 +218,14 @@ class QDLT_EXPORT QDltMsg : public QDlt \sa DltEndiannessDef \return The endianness of the DLT message. */ - DltEndiannessDef getEndianness() const { return endianness; } + QDlt::DltEndiannessDef getEndianness() const { return endianness; } //! Set the endianness of the DLT message. /*! \sa DltEndiannessDef \param _endianness The endianness of the DLT message. */ - void setEndianness(DltEndiannessDef _endianness) { endianness = _endianness; } + void setEndianness(QDlt::DltEndiannessDef _endianness) { endianness = _endianness; } //! Get the text of the endianness of the DLT message. /*! @@ -546,8 +536,6 @@ class QDLT_EXPORT QDltMsg : public QDlt int getIndex() const; void setIndex(int newIndex); -protected: - private: //! The header parameter ECU Id. @@ -569,7 +557,7 @@ class QDLT_EXPORT QDltMsg : public QDlt DltModeDef mode; //! The endianness of the payload of the message. - DltEndiannessDef endianness; + QDlt::DltEndiannessDef endianness; //! The time, seconds part, of the message generated by the logger. time_t time; diff --git a/qdlt/qdltsegmentedmsg.cpp b/qdlt/qdltsegmentedmsg.cpp index afe9d725..3d6aae43 100644 --- a/qdlt/qdltsegmentedmsg.cpp +++ b/qdlt/qdltsegmentedmsg.cpp @@ -19,11 +19,8 @@ * @licence end@ */ -#include - #include "qdltsegmentedmsg.h" - QDltSegmentedMsg::QDltSegmentedMsg() { diff --git a/src/dltfileindexerthread.cpp b/src/dltfileindexerthread.cpp index c8ef7219..b4b5529c 100644 --- a/src/dltfileindexerthread.cpp +++ b/src/dltfileindexerthread.cpp @@ -66,7 +66,7 @@ void DltFileIndexerThread::processMessage(QSharedPointer &msg, int inde { QByteArray payload = msg->getPayload(); QByteArray data = payload.mid(9, (payload.size() > 262) ? 256 : (payload.size() - 9)); - QString version = msg->toAscii(data,true); + QString version = QDlt::toAscii(data,true); version = version.trimmed(); // remove all white spaces at beginning and end indexer->versionString(msg->getEcuid(),version); } @@ -83,7 +83,7 @@ void DltFileIndexerThread::processMessage(QSharedPointer &msg, int inde DltServiceTimezone *service; service = (DltServiceTimezone*) payload.constData(); - if(msg->getEndianness() == QDltMsg::DltEndiannessLittleEndian) + if(msg->getEndianness() == QDlt::DltEndiannessLittleEndian) indexer->timezone(service->timezone, service->isdst); else indexer->timezone(DLT_SWAP_32(service->timezone), service->isdst); @@ -163,7 +163,7 @@ void DltFileIndexerThread::processMessage(QSharedPointer &msg, int inde ptr = payload.constData(); length = payload.size(); DLT_MSG_READ_VALUE(service_id_tmp,ptr, length, uint32_t); - service_id=DLT_ENDIAN_GET_32(((msg->getEndianness() == QDltMsg::DltEndiannessBigEndian) ? DLT_HTYP_MSBF:0), service_id_tmp); + service_id=DLT_ENDIAN_GET_32(((msg->getEndianness() == QDlt::DltEndiannessBigEndian) ? DLT_HTYP_MSBF:0), service_id_tmp); if(service_id == DLT_SERVICE_ID_GET_LOG_INFO) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a0280955..ae7f9121 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4476,7 +4476,7 @@ void MainWindow::controlMessage_ReceiveControlMessage(EcuItem *ecuitem, const QD /* control message was received */ uint32_t service_id_tmp=0; DLT_MSG_READ_VALUE(service_id_tmp,ptr,length,uint32_t); - uint32_t service_id=DLT_ENDIAN_GET_32( ((msg.getEndianness()==QDltMsg::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0), service_id_tmp); + uint32_t service_id=DLT_ENDIAN_GET_32( ((msg.getEndianness()==QDlt::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0), service_id_tmp); switch (service_id) { @@ -4508,7 +4508,7 @@ void MainWindow::controlMessage_ReceiveControlMessage(EcuItem *ecuitem, const QD { uint16_t count_app_ids=0,count_app_ids_tmp=0; DLT_MSG_READ_VALUE(count_app_ids_tmp,ptr,length,uint16_t); - count_app_ids=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDltMsg::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0), count_app_ids_tmp); + count_app_ids=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDlt::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0), count_app_ids_tmp); for (int32_t num=0;numtimezone, service->isdst); else controlMessage_Timezone(DLT_SWAP_32(service->timezone), service->isdst); @@ -6341,7 +6341,7 @@ void MainWindow::versionString(const QDltMsg &msg) QByteArray payload = msg.getPayload(); QByteArray data = payload.mid(9,(payload.size()>262)?256:(payload.size()-9)); - target_version_string = msg.toAscii(data,true); + target_version_string = QDlt::toAscii(data,true); target_version_string = target_version_string.trimmed(); // remove all white spaces at beginning and end //qDebug() << "Versionstring"<< target_version_string << __LINE__ ;