Skip to content

Commit

Permalink
Remove inheritence of QDltMsg from QDlt
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Kopp <[email protected]>
  • Loading branch information
vifactor committed Jan 5, 2025
1 parent 8fd9e42 commit 4ae95d5
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 41 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
38 changes: 19 additions & 19 deletions qdlt/qdltmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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 +292,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 +501,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 +543,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 +553,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 +627,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 +876,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 +961,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 +1017,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 +1136,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 +1157,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 +1181,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 +1191,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 +1200,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 +1215,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 +1520,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
10 changes: 4 additions & 6 deletions qdlt/qdltmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 Down Expand Up @@ -228,14 +228,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 +546,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 +567,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
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
14 changes: 7 additions & 7 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;num<count_app_ids;num++)
{
char apid[DLT_ID_SIZE+1];
Expand All @@ -4518,7 +4518,7 @@ void MainWindow::controlMessage_ReceiveControlMessage(EcuItem *ecuitem, const QD

uint16_t count_context_ids=0,count_context_ids_tmp=0;
DLT_MSG_READ_VALUE(count_context_ids_tmp,ptr,length,uint16_t);
count_context_ids=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDltMsg::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0), count_context_ids_tmp);
count_context_ids=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDlt::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0), count_context_ids_tmp);

for (int32_t num2=0;num2<count_context_ids;num2++)
{
Expand All @@ -4538,7 +4538,7 @@ void MainWindow::controlMessage_ReceiveControlMessage(EcuItem *ecuitem, const QD
{
uint16_t context_description_length=0,context_description_length_tmp=0;
DLT_MSG_READ_VALUE(context_description_length_tmp,ptr,length,uint16_t);
context_description_length=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDltMsg::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0),context_description_length_tmp);
context_description_length=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDlt::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0),context_description_length_tmp);

if (length<context_description_length)
{
Expand All @@ -4560,7 +4560,7 @@ void MainWindow::controlMessage_ReceiveControlMessage(EcuItem *ecuitem, const QD
QString applicationDescription;
uint16_t application_description_length=0,application_description_length_tmp=0;
DLT_MSG_READ_VALUE(application_description_length_tmp,ptr,length,uint16_t);
application_description_length=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDltMsg::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0),application_description_length_tmp);
application_description_length=DLT_ENDIAN_GET_16(((msg.getEndianness()==QDlt::DltEndiannessBigEndian)?DLT_HTYP_MSBF:0),application_description_length_tmp);
applicationDescription = QString(QByteArray((char*)ptr,application_description_length));
controlMessage_SetApplication(ecuitem,QString(apid),applicationDescription);
ptr+=application_description_length;
Expand Down Expand Up @@ -4613,7 +4613,7 @@ void MainWindow::controlMessage_ReceiveControlMessage(EcuItem *ecuitem, const QD
DltServiceTimezone *service;
service = (DltServiceTimezone*) payload.constData();

if(msg.getEndianness() == QDltMsg::DltEndiannessLittleEndian)
if(msg.getEndianness() == QDlt::DltEndiannessLittleEndian)
controlMessage_Timezone(service->timezone, service->isdst);
else
controlMessage_Timezone(DLT_SWAP_32(service->timezone), service->isdst);
Expand Down Expand Up @@ -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__ ;
Expand Down

0 comments on commit 4ae95d5

Please sign in to comment.