Skip to content

Commit

Permalink
Remove inheritence of QDltMsg from QDlt
Browse files Browse the repository at this point in the history
Remove unnecessary code

Signed-off-by: Viktor Kopp <[email protected]>
  • Loading branch information
vifactor authored and alexmucde committed Jan 7, 2025
1 parent 17346f7 commit 5a66b24
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 64 deletions.
4 changes: 2 additions & 2 deletions plugin/dltdbusplugin/dltdbusplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void DltDBusPlugin::selectedIdxMsg(int /*index*/, QDltMsg &msg)
text += QString("<tr><td>Destination</td><td>%1</td></tr>").arg(dbusMsg.getDestination());
text += QString("<tr><td>Sender</td><td>%1</td></tr>").arg(dbusMsg.getSender());
QByteArray signature = dbusMsg.getSignature();
text += QString("<tr><td>Signature</td><td>%1</td></tr>").arg(msg.toAsciiTable(signature,false,false,true,256,256,false));
text += QString("<tr><td>Signature</td><td>%1</td></tr>").arg(QDlt::toAsciiTable(signature,false,false,true,256,256,false));
text += QString("<tr><td>UnixFds</td><td>%1</td></tr>").arg(dbusMsg.getUnixFds());

text += QString("</table>");
Expand All @@ -315,7 +315,7 @@ void DltDBusPlugin::selectedIdxMsg(int /*index*/, QDltMsg &msg)
/* DBus message payload Hex*/
QByteArray payload = dbusMsg.getPayload();
text = QString("<h3>Size: %1</h3>").arg(payload.size());
text += msg.toAsciiTable(payload,true,true,false);
text += QDlt::toAsciiTable(payload,true,true,false);
form->setTextBrowserPayloadHex(text);

/* decode DBus payload */
Expand Down
6 changes: 3 additions & 3 deletions plugin/dltviewerplugin/dltviewerplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}


Expand Down
2 changes: 1 addition & 1 deletion plugin/nonverboseplugin/nonverboseplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
2 changes: 0 additions & 2 deletions qdlt/qdltargument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* @licence end@
*/

#include <QVariant>

#include "qdltargument.h"

extern "C"
Expand Down
1 change: 1 addition & 0 deletions qdlt/qdltargument.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define QDLT_ARGUMENT_H

#include <QString>
#include <QVariant>

#include "qdltbase.h"
#include "export_rules.h"
Expand Down
49 changes: 22 additions & 27 deletions qdlt/qdltmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
* @licence end@
*/

#include <QtDebug>
#include <QtEndian>

#include "qdltmsg.h"

extern "C"
{
#include "dlt_common.h"
}

#include <QtEndian>
#include <QDateTime>

namespace {
constexpr const char * const qDltMessageType[] = {"log","app_trace","nw_trace","control","","","",""};
constexpr const char * const qDltLogInfo[] = {"","fatal","error","warn","info","debug","verbose","","","","","","","","",""};
Expand All @@ -49,11 +49,6 @@ QDltMsg::QDltMsg()
clear();
}

QDltMsg::~QDltMsg()
{

}

QString QDltMsg::getStringFromId(const char *text)
{
if(text[1]==0)
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 {
Expand All @@ -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()));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1017,7 +1012,7 @@ void QDltMsg::clear()
type = DltTypeUnknown;
subtype = DltLogUnknown;
mode = DltModeUnknown;
endianness = DltEndiannessUnknown;
endianness = QDlt::DltEndiannessUnknown;
time = 0;
microseconds = 0;
timestamp = 0;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)
{
Expand All @@ -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)
Expand All @@ -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));
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
20 changes: 4 additions & 16 deletions qdlt/qdltmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
#ifndef QDLT_MSG_H
#define QDLT_MSG_H

#include <QObject>
#include <QString>
#include <QFile>
#include <QDateTime>
#include <QMutex>
#include <time.h>

#include "export_rules.h"
#include "qdltbase.h"
Expand All @@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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.
/*!
Expand Down Expand Up @@ -546,8 +536,6 @@ class QDLT_EXPORT QDltMsg : public QDlt
int getIndex() const;
void setIndex(int newIndex);

protected:

private:

//! The header parameter ECU Id.
Expand All @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions qdlt/qdltsegmentedmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
* @licence end@
*/

#include <QByteArray>

#include "qdltsegmentedmsg.h"


QDltSegmentedMsg::QDltSegmentedMsg()
{

Expand Down
6 changes: 3 additions & 3 deletions src/dltfileindexerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void DltFileIndexerThread::processMessage(QSharedPointer<QDltMsg> &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);
}
Expand All @@ -83,7 +83,7 @@ void DltFileIndexerThread::processMessage(QSharedPointer<QDltMsg> &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);
Expand Down Expand Up @@ -163,7 +163,7 @@ void DltFileIndexerThread::processMessage(QSharedPointer<QDltMsg> &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)
{
Expand Down
Loading

0 comments on commit 5a66b24

Please sign in to comment.