Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a3dde98
Display record size information
Pavithra-aa-Anand Jun 10, 2025
36eb226
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jun 11, 2025
5922257
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jun 20, 2025
aafaf0f
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jun 21, 2025
6253db4
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jun 23, 2025
390ac88
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jun 25, 2025
b97c610
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 9, 2025
7f52789
Merge branch 'master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 11, 2025
8d2ab1e
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 15, 2025
fb267c9
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 16, 2025
7d6c575
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 21, 2025
c72e753
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 23, 2025
fafaac5
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 24, 2025
77d0a23
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 30, 2025
1f46c2b
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Jul 31, 2025
4c69f61
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Aug 1, 2025
c33be27
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Aug 2, 2025
7bbd76e
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Aug 5, 2025
f964900
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Aug 6, 2025
dcbca6f
Changes in mainwindow.ui
Pavithra-aa-Anand Aug 10, 2025
acde468
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Aug 13, 2025
0e70abc
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Aug 20, 2025
a216b87
Generating statistics of DLT file during the indexing.
Pavithra-aa-Anand Sep 1, 2025
de18704
Merge branch 'master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Sep 4, 2025
2728330
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Sep 10, 2025
853d377
Merge branch 'master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Sep 24, 2025
638c500
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Sep 30, 2025
6dbaacc
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Oct 6, 2025
518205f
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Oct 7, 2025
8b240fc
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Oct 9, 2025
0c8bd9f
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Oct 15, 2025
53d5973
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Oct 23, 2025
d837aa7
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Oct 31, 2025
43334dd
Merge branch 'COVESA:master' into Feature-DisplayRecordSizeInfo
Pavithra-aa-Anand Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 159 additions & 1 deletion qdlt/qdltfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,41 @@ int QDltFile::sizeFilter() const
return size();
}

int QDltFile::calculateHeaderSize(quint8 htyp)
{
// Base DLT standard header size (HTYP (1) + MCNT (1) + LEN (2))
int size = 4;

// Add standard header extra fields using DLT constants
if (DLT_IS_HTYP_WEID(htyp)) size += DLT_SIZE_WEID; // ECU ID
if (DLT_IS_HTYP_WSID(htyp)) size += DLT_SIZE_WSID; // Session ID
if (DLT_IS_HTYP_WTMS(htyp)) size += DLT_SIZE_WTMS; // Timestamp

// Add extended header if UEH flag is set
if (DLT_IS_HTYP_UEH(htyp)) {
size += 10; // Extended header: MSIN (1) + NOAR (1) + APID (4) + CTID (4)
}
return size;
}

quint32 QDltFile::alignedStorageSize(quint32 size)
{
constexpr int STORAGE_ALIGNMENT = 4;
return ((size + STORAGE_ALIGNMENT - 1) / STORAGE_ALIGNMENT) * STORAGE_ALIGNMENT;
}

bool QDltFile::open(QString _filename, bool append)
{
qDebug() << "Open file" << _filename << "started";

/* check if file is already opened */
if(!append)
if(!append) {
clear();
// Reset size counters when opening new file
totalStorageSize = 0;
totalPayloadSize = 0;
totalMessageSize = 0;
}

/* create new file item */
QDltFileItem *item = new QDltFileItem();
Expand All @@ -156,12 +184,38 @@ bool QDltFile::open(QString _filename, bool append)
return true;
}

quint64 QDltFile::getTotalStorageSize() {
if (totalStorageSize == 0 && size() > 0) {
calculateTotalSizes();
}
return totalStorageSize;
}

quint64 QDltFile::getTotalPayloadSize() {
if (totalPayloadSize == 0 && size() > 0) {
calculateTotalSizes();
}
return totalPayloadSize;
}

quint64 QDltFile::getTotalMessageSize() {
if (totalMessageSize == 0 && size() > 0) {
calculateTotalSizes();
}
return totalMessageSize;
}

void QDltFile::clearIndex()
{
for(int num=0;num<files.size();num++)
{
files[num]->indexAll.clear();
}

// Reset size counters when clearing index
totalStorageSize = 0;
totalPayloadSize = 0;
totalMessageSize = 0;
}

bool QDltFile::createIndex()
Expand All @@ -178,6 +232,7 @@ bool QDltFile::createIndex()
ret = updateIndex();

//qDebug() << "Create index finished - " << size() << "messages found";
calculateTotalSizes();

return ret;
}
Expand Down Expand Up @@ -544,6 +599,10 @@ void QDltFile::close()
{
/* close file */
clear();
// Reset size counters when closing
totalPayloadSize = 0;
totalMessageSize = 0;
totalStorageSize = 0;
}

QByteArray QDltFile::getMsg(int index) const
Expand Down Expand Up @@ -779,3 +838,102 @@ bool QDltFile::applyRegExStringMsg(QDltMsg &msg) const
{
return filterList.applyRegExStringMsg(msg);
}

void QDltFile::calculateTotalSizes()
{
// Structure to hold per-message size info
struct QDltMsgSizeInfo {
quint32 storageSize;
quint32 messageSize;
quint32 payloadSize;
};

// Get total number of indexed messages
const int totalMessages = size();
if (totalMessages == 0) {
totalStorageSize = 0;
totalMessageSize = 0;
totalPayloadSize = 0;
return;
}

// Create cache for per-message size info
QVector<QDltMsgSizeInfo> msgSizeCache(totalMessages);

// Progress reporting interval for large files
const int progressInterval = qMax(1, qMin(totalMessages / 20, 10000));
for (int msgIndex = 0; msgIndex < totalMessages; msgIndex++) {
// Print progress for large files
if (totalMessages > 10000 && (msgIndex % progressInterval) == 0) {
int percentage = (msgIndex * 100) / totalMessages;
qDebug() << "Caching sizes:" << percentage << "% (" << msgIndex << "/" << totalMessages << ")";
}

QByteArray msgData = getMsg(msgIndex);
QDltMsgSizeInfo info = {0, 0, 0};
if (msgData.isEmpty() || msgData.size() < 20) {
msgSizeCache[msgIndex] = info;
continue;
}

// Parse storage header
const char *data = msgData.constData();
const int msgDataSize = msgData.size();
const quint8 storageHeaderVersion = static_cast<quint8>(data[3]);
int storageHeaderSize = 16;
if (storageHeaderVersion == 2) {
// DLTv2: storage header size depends on ECU ID length
if (msgDataSize < 14) {
msgSizeCache[msgIndex] = info;
continue;
}
const quint8 ecuIdLength = static_cast<quint8>(data[13]);
storageHeaderSize = 14 + ecuIdLength;
}

// Validate enough data for DLT header
if (msgDataSize < storageHeaderSize + 4) {
msgSizeCache[msgIndex] = info;
continue;
}

// Parse DLT protocol header
const char* dltHeaderData = data + storageHeaderSize;
const quint8 htyp = static_cast<quint8>(dltHeaderData[0]);
const quint16 dltMessageLength = (static_cast<quint8>(dltHeaderData[2]) << 8) |
static_cast<quint8>(dltHeaderData[3]);

// Validate message length
if (dltMessageLength == 0 || dltMessageLength > 65535 ||
dltMessageLength > (msgDataSize - storageHeaderSize)) {
msgSizeCache[msgIndex] = info;
continue;
}

// Calculate header and payload sizes
const int headerSize = calculateHeaderSize(htyp);
const int payloadSize = dltMessageLength - headerSize;
if (payloadSize < 0) {
msgSizeCache[msgIndex] = info;
continue;
}

info.storageSize = alignedStorageSize(msgDataSize);
info.messageSize = dltMessageLength;
info.payloadSize = payloadSize;
msgSizeCache[msgIndex] = info;
}
if (totalMessages > 10000) {
qDebug() << "Size caching completed: processed" << totalMessages << "messages";
}

// Accumulate totals from cache
totalStorageSize = 0;
totalMessageSize = 0;
totalPayloadSize = 0;
for (int i = 0; i < msgSizeCache.size(); ++i) {
totalStorageSize += msgSizeCache[i].storageSize;
totalMessageSize += msgSizeCache[i].messageSize;
totalPayloadSize += msgSizeCache[i].payloadSize;
}
}
39 changes: 38 additions & 1 deletion qdlt/qdltfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,41 @@ class QDLT_EXPORT QDltFile : public QDlt
*/
bool applyRegExStringMsg(QDltMsg &msg) const;

protected:
//! Get the total storage size of all indexed DLT messages in bytes.
/*!
* \return Total storage size in bytes (octets), 0 if no messages indexed
**/
quint64 getTotalStorageSize();

//! Get the total payload size of all indexed DLT messages in bytes.
/*!
* \return Total payload size in bytes (octets), 0 if no messages indexed
**/
quint64 getTotalPayloadSize() ;

//! Get the total message size of all indexed DLT messages in bytes.
/*!
* \return Total message size in bytes (octets), 0 if no messages indexed
**/
quint64 getTotalMessageSize();

//! Calculate DLT header size based on header type flags.
/*!
* \return Total header size in bytes
**/
int calculateHeaderSize(quint8 htyp);

//! Align size to 4-byte boundary for DLT storage format.
/*!
* \return Size rounded up to next 4-byte boundary
**/
quint32 alignedStorageSize(quint32 size);


private:
// Calculates total storage, message, and payload sizes for all indexed DLT messages.
void calculateTotalSizes();

//! Mutex to lock critical path for infile
mutable QMutex mutexQDlt;

Expand Down Expand Up @@ -351,6 +383,11 @@ class QDLT_EXPORT QDltFile : public QDlt
QCache<int,QDltMsg> cache;
bool cacheEnable;

// Size calculation variables
quint64 totalStorageSize = 0;
quint64 totalMessageSize = 0;
quint64 totalPayloadSize = 0;

//! DLTv2 Support.
/*!
true dltv2 support is enabled.
Expand Down
20 changes: 20 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,7 @@ void MainWindow::reloadLogFile(bool update, bool multithreaded)
for(int num=0;num<openFileNames.size();num++)
{
bool back = qfile.open(openFileNames[num],num!=0);

if ( false == back )
{
qDebug() << "ERROR opening file (s)" << openFileNames[num] << __FILE__ << __LINE__;
Expand Down Expand Up @@ -2353,6 +2354,25 @@ void MainWindow::applySettings()
qfile.setDLTv2Support(settings->supportDLTv2Decoding);
}

void MainWindow::on_action_menuFile_DLTFilesize_triggered()
{
quint64 payloadSize = qfile.getTotalPayloadSize();
quint64 messageSize = qfile.getTotalMessageSize();
quint64 storageSize = qfile.getTotalStorageSize();

if (payloadSize == 0 && messageSize == 0 && storageSize == 0) {
QMessageBox::warning(this, "No Data", "Please open a valid DLT file first.");
return;
}

QString message = QString(
"Payload Size (octets): %1\n"
"Message Size (octets): %2\n"
"Storage Size (octets): %3"
).arg(payloadSize).arg(messageSize).arg(storageSize);

QMessageBox::information(this, "DLT File Size Information", message);
}

void MainWindow::on_action_menuFile_Settings_triggered()
{
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ class MainWindow : public QMainWindow
void openSupportedFile(const QString& path);

void getSelectedItems(EcuItem **ecuitem,ApplicationItem** appitem,ContextItem** conitem);

void reloadLogFile(bool update=false, bool multithreaded = true);
void populateEcusTree(EcuTree&& ecuTree);

Expand Down Expand Up @@ -425,6 +424,7 @@ private slots:
void on_action_menuFile_Open_triggered();
void on_actionAppend_triggered();
void on_actionExport_triggered();
void on_action_menuFile_DLTFilesize_triggered();


public slots:
Expand Down
Loading
Loading