Skip to content

Commit

Permalink
Remove inheritence of QDltArgument 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 4, 2025
1 parent f9a2ec9 commit b7a5e7d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 43 deletions.
60 changes: 30 additions & 30 deletions qdlt/qdltargument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ QString QDltArgument::getTypeInfoString() const
return QString(qDltTypeInfo[typeInfo]);
}

bool QDltArgument::setArgument(QByteArray &payload,unsigned int &offset,DltEndiannessDef _endianess)
bool QDltArgument::setArgument(QByteArray &payload,unsigned int &offset, QDlt::DltEndiannessDef _endianess)
{
unsigned short length=0,length2=0,length3=0;

Expand All @@ -98,7 +98,7 @@ bool QDltArgument::setArgument(QByteArray &payload,unsigned int &offset,DltEndia
/* get type info */
if((unsigned int)payload.size()<(offset+sizeof(unsigned int)))
return false;
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
dltType = *((unsigned int*) (payload.constData()+offset));
else
dltType = DLT_SWAP_32((*((unsigned int*) (payload.constData()+offset))));
Expand Down Expand Up @@ -150,7 +150,7 @@ bool QDltArgument::setArgument(QByteArray &payload,unsigned int &offset,DltEndia
{
if((unsigned int)payload.size()<(offset+sizeof(unsigned short)))
return false;
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
length = *((unsigned short*) (payload.constData()+offset));
else
length = DLT_SWAP_16((*((unsigned short*) (payload.constData()+offset))));
Expand All @@ -163,7 +163,7 @@ bool QDltArgument::setArgument(QByteArray &payload,unsigned int &offset,DltEndia
{
if((unsigned int)payload.size()<(offset+sizeof(unsigned short)))
return false;
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
length2 = *((unsigned short*) (payload.constData()+offset));
else
length2 = DLT_SWAP_16((*((unsigned short*) (payload.constData()+offset))));
Expand All @@ -172,7 +172,7 @@ bool QDltArgument::setArgument(QByteArray &payload,unsigned int &offset,DltEndia
{
if((unsigned int)payload.size()<(offset+sizeof(unsigned short)))
return false;
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
length3 = *((unsigned short*) (payload.constData()+offset));
else
length3 = DLT_SWAP_16((*((unsigned short*) (payload.constData()+offset))));
Expand Down Expand Up @@ -389,7 +389,7 @@ QString QDltArgument::toString(bool binary) const
text.reserve(1024);

if(binary) {
return toAscii(data);
return QDlt::toAscii(data);
}

switch(getTypeInfo()) {
Expand Down Expand Up @@ -423,19 +423,19 @@ QString QDltArgument::toString(bool binary) const
text += QString("%1").arg((short)(*(char*)(data.constData())));
break;
case 2:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((short)(*(short*)(data.constData())));
else
text += QString("%1").arg((short)DLT_SWAP_16((short)(*(short*)(data.constData()))));
break;
case 4:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((int)(*(int*)(data.constData())));
else
text += QString("%1").arg((int)DLT_SWAP_32((int)(*(int*)(data.constData()))));
break;
case 8:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((long long)(*(long long*)(data.constData())));
else
text += QString("%1").arg((long long)DLT_SWAP_64((long long)(*(long long*)(data.constData()))));
Expand All @@ -449,20 +449,20 @@ QString QDltArgument::toString(bool binary) const
if ((dltType & DLT_TYPE_INFO_SCOD)==DLT_SCOD_BIN)
{
if((dltType & DLT_TYPE_INFO_TYLE)==DLT_TYLE_8BIT)
text += toAscii(data,2,1); // show binary
text += QDlt::toAscii(data,2,1); // show binary
else if((dltType & DLT_TYPE_INFO_TYLE)==DLT_TYLE_16BIT)
text += toAscii(data,2,2); // show binary
text += QDlt::toAscii(data,2,2); // show binary
}
else if ((dltType & DLT_TYPE_INFO_SCOD)==DLT_SCOD_HEX)
{
if((dltType & DLT_TYPE_INFO_TYLE)==DLT_TYLE_8BIT)
text += toAscii(data,0,1); // show 8 bit hex
text += QDlt::toAscii(data,0,1); // show 8 bit hex
else if((dltType & DLT_TYPE_INFO_TYLE)==DLT_TYLE_16BIT)
text += toAscii(data,0,2); // show 16 bit hex
text += QDlt::toAscii(data,0,2); // show 16 bit hex
else if((dltType & DLT_TYPE_INFO_TYLE)==DLT_TYLE_32BIT)
text += toAscii(data,0,4); // show 32 bit hex
text += QDlt::toAscii(data,0,4); // show 32 bit hex
else if((dltType & DLT_TYPE_INFO_TYLE)==DLT_TYLE_64BIT)
text += toAscii(data,0,8); // show 64 bit hex
text += QDlt::toAscii(data,0,8); // show 64 bit hex
}
else
{
Expand All @@ -472,19 +472,19 @@ QString QDltArgument::toString(bool binary) const
text += QString("%1").arg((unsigned short)(*(unsigned char*)(data.constData())));
break;
case 2:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((unsigned short)(*(unsigned short*)(data.constData())));
else
text += QString("%1").arg((unsigned short)DLT_SWAP_16((unsigned short)(*(unsigned short*)(data.constData()))));
break;
case 4:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((unsigned int)(*(unsigned int*)(data.constData())));
else
text += QString("%1").arg((unsigned int)DLT_SWAP_32((unsigned int)(*(unsigned int*)(data.constData()))));
break;
case 8:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((unsigned long long)(*(unsigned long long*)(data.constData())));
else
text += QString("%1").arg((unsigned long long)DLT_SWAP_64((unsigned long long)(*(unsigned long long*)(data.constData()))));
Expand All @@ -498,7 +498,7 @@ QString QDltArgument::toString(bool binary) const
switch(data.size())
{
case 4:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((double)(*(float*)(data.constData())), 0, 'f', 8);
else
{
Expand All @@ -508,7 +508,7 @@ QString QDltArgument::toString(bool binary) const
}
break;
case 8:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
text += QString("%1").arg((double)(*(double*)(data.constData())), 0, 'f', 8);
else {
const auto tmp = DLT_SWAP_64((unsigned long long)(*(unsigned long long*)(data.constData())));
Expand All @@ -521,7 +521,7 @@ QString QDltArgument::toString(bool binary) const
}
break;
case DltTypeInfoRawd:
text += toAscii(data,0); // show raw format (no leading 0x)
text += QDlt::toAscii(data,0); // show raw format (no leading 0x)
break;
case DltTypeInfoTrai:
text += QString("?");
Expand Down Expand Up @@ -559,17 +559,17 @@ QVariant QDltArgument::getValue() const
case 1:
return QVariant((short)(*(char*)(data.constData())));
case 2:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((short)(*(short*)(data.constData())));
else
return QVariant(DLT_SWAP_16((short)(*(short*)(data.constData()))));
case 4:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((int)(*(int*)(data.constData())));
else
return QVariant(DLT_SWAP_32((int)(*(int*)(data.constData()))));
case 8:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((long long)(*(long long*)(data.constData())));
else
return QVariant(DLT_SWAP_64((long long)(*(long long*)(data.constData()))));
Expand All @@ -583,17 +583,17 @@ QVariant QDltArgument::getValue() const
case 1:
return QVariant((unsigned short)(*(unsigned char*)(data.constData())));
case 2:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((unsigned short)(*(unsigned short*)(data.constData())));
else
return QVariant(DLT_SWAP_16((unsigned short)(*(unsigned short*)(data.constData()))));
case 4:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((unsigned int)(*(unsigned int*)(data.constData())));
else
return QVariant(DLT_SWAP_32((unsigned int)(*(unsigned int*)(data.constData()))));
case 8:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((unsigned long long)(*(unsigned long long*)(data.constData())));
else
return QVariant(DLT_SWAP_64((unsigned long long)(*(unsigned long long*)(data.constData()))));
Expand All @@ -606,7 +606,7 @@ QVariant QDltArgument::getValue() const
switch(data.size())
{
case 4:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((double)(*(float*)(data.constData())));
else
{
Expand All @@ -616,7 +616,7 @@ QVariant QDltArgument::getValue() const
return QVariant((double)(*((float*)buf)));
}
case 8:
if(endianness == DltEndiannessLittleEndian)
if(endianness == QDlt::DltEndiannessLittleEndian)
return QVariant((double)(*(double*)(data.constData())));
else {
const auto tmp = DLT_SWAP_64((unsigned long long)(*(unsigned long long*)(data.constData())));
Expand All @@ -643,7 +643,7 @@ bool QDltArgument::setValue(QVariant value, bool verboseMode)
{
Q_UNUSED(verboseMode);

endianness = QDltArgument::DltEndiannessLittleEndian;
endianness = QDlt::DltEndiannessLittleEndian;

switch(value.type())
{
Expand Down
11 changes: 5 additions & 6 deletions qdlt/qdltargument.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
This class contains one argument of a DLT message.
A QDltMessage contains several Arguments.
*/
class QDLT_EXPORT QDltArgument : public QDlt
class QDLT_EXPORT QDltArgument
{
public:

Expand Down Expand Up @@ -99,14 +99,14 @@ class QDLT_EXPORT QDltArgument : 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 Argument.
/*!
\sa DltEndiannessDef
\param _endianess The endianness of the argument.
*/
void setEndianness(DltEndiannessDef _endianess) { endianness = (QDlt::DltEndiannessDef)_endianess; }
void setEndianness(QDlt::DltEndiannessDef _endianess) { endianness = _endianess; }

//! Get the byte data of the parameter.
/*!
Expand Down Expand Up @@ -163,7 +163,7 @@ class QDLT_EXPORT QDltArgument : public QDlt
\param _endianess The new endianness of the argument
\return The name of the unit of the variable.
*/
bool setArgument(QByteArray &payload,unsigned int &offset,DltEndiannessDef _endianess);
bool setArgument(QByteArray &payload,unsigned int &offset, QDlt::DltEndiannessDef _endianess);

//! Get argument as byte array and appends it to data.
/*!
Expand Down Expand Up @@ -192,7 +192,7 @@ class QDLT_EXPORT QDltArgument : public QDlt
private:

//! The endianness of the argument.
DltEndiannessDef endianness;
QDlt::DltEndiannessDef endianness;

//! This type of the argument linked in the DLT message header
unsigned int dltType;
Expand All @@ -217,7 +217,6 @@ class QDLT_EXPORT QDltArgument : public QDlt
This is an optional parameter.
*/
QString unit;

};


Expand Down
2 changes: 1 addition & 1 deletion qdlt/qdltconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ bool QDltConnection::parseAscii(QDltMsg &msg)
// add one argument as String
QDltArgument arg;
arg.setTypeInfo(QDltArgument::DltTypeInfoStrg);
arg.setEndianness(QDltArgument::DltEndiannessLittleEndian);
arg.setEndianness(QDlt::DltEndiannessLittleEndian);
arg.setOffsetPayload(0);
arg.setData(QByteArray(cbuf,num)+QByteArray("",1));
msg.addArgument(arg);
Expand Down
12 changes: 6 additions & 6 deletions qdlt/qdltimporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,15 +889,15 @@ bool QDltImporter::ipcFromEthernetFrame(QByteArray &record,int pos,quint16 ether
// add PLP Header Data
QDltArgument arg1;
arg1.setTypeInfo(QDltArgument::DltTypeInfoRawd);
arg1.setEndianness(QDltArgument::DltEndiannessLittleEndian);
arg1.setEndianness(QDlt::DltEndiannessLittleEndian);
arg1.setOffsetPayload(0);
arg1.setData(record.mid(pos-sizeof(plp_header_data_t),sizeof(plp_header_data_t)));
msg.addArgument(arg1);

// add IPC Header
QDltArgument arg2;
arg2.setTypeInfo(QDltArgument::DltTypeInfoRawd);
arg2.setEndianness(QDltArgument::DltEndiannessLittleEndian);
arg2.setEndianness(QDlt::DltEndiannessLittleEndian);
arg2.setOffsetPayload(0);
if(endOfSegment)
{
Expand All @@ -912,7 +912,7 @@ bool QDltImporter::ipcFromEthernetFrame(QByteArray &record,int pos,quint16 ether
// add IPC Data
QDltArgument arg3;
arg3.setTypeInfo(QDltArgument::DltTypeInfoRawd);
arg3.setEndianness(QDltArgument::DltEndiannessLittleEndian);
arg3.setEndianness(QDlt::DltEndiannessLittleEndian);
arg3.setOffsetPayload(0);
if(endOfSegment)
{
Expand Down Expand Up @@ -981,7 +981,7 @@ bool QDltImporter::ipcFromPlpRaw(mdf_plpRaw_t *plpRaw,QByteArray &record,quint32
// add PLP Header Data
QDltArgument arg1;
arg1.setTypeInfo(QDltArgument::DltTypeInfoRawd);
arg1.setEndianness(QDltArgument::DltEndiannessLittleEndian);
arg1.setEndianness(QDlt::DltEndiannessLittleEndian);
arg1.setOffsetPayload(0);
plp_header_data_t plpHeaderData;
plpHeaderData.busSpecId=0;
Expand All @@ -995,7 +995,7 @@ bool QDltImporter::ipcFromPlpRaw(mdf_plpRaw_t *plpRaw,QByteArray &record,quint32
// add IPC Header
QDltArgument arg2;
arg2.setTypeInfo(QDltArgument::DltTypeInfoRawd);
arg2.setEndianness(QDltArgument::DltEndiannessLittleEndian);
arg2.setEndianness(QDlt::DltEndiannessLittleEndian);
arg2.setOffsetPayload(0);
if(endOfSegment)
{
Expand All @@ -1010,7 +1010,7 @@ bool QDltImporter::ipcFromPlpRaw(mdf_plpRaw_t *plpRaw,QByteArray &record,quint32
// add IPC Data
QDltArgument arg3;
arg3.setTypeInfo(QDltArgument::DltTypeInfoRawd);
arg3.setEndianness(QDltArgument::DltEndiannessLittleEndian);
arg3.setEndianness(QDlt::DltEndiannessLittleEndian);
arg3.setOffsetPayload(0);
if(endOfSegment)
{
Expand Down

0 comments on commit b7a5e7d

Please sign in to comment.