Skip to content

Commit

Permalink
Logging only filtered messages feature (#418)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Wenzel <[email protected]>
  • Loading branch information
alexmucde authored Feb 1, 2024
1 parent a601ea5 commit 2e25b0d
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 45 deletions.
7 changes: 7 additions & 0 deletions qdlt/qdltsettingsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void QDltSettingsManager::writeSettingsLocal(QXmlStreamWriter &xml)
xml.writeTextElement("updateContextLoadingFile",QString("%1").arg(updateContextLoadingFile));
xml.writeTextElement("updateContextsUnregister",QString("%1").arg(updateContextsUnregister));
xml.writeTextElement("loggingOnlyMode",QString("%1").arg(loggingOnlyMode));
xml.writeTextElement("loggingOnlyFilteredMessages",QString("%1").arg(loggingOnlyFilteredMessages));
xml.writeTextElement("splitlogfile",QString("%1").arg(splitlogfile));
xml.writeTextElement("fmaxFileSizeMB",QString("%1").arg(fmaxFileSizeMB));
xml.writeTextElement("appendDateTime",QString("%1").arg(appendDateTime));
Expand Down Expand Up @@ -186,6 +187,7 @@ void QDltSettingsManager::writeSettings()
settings->setValue("startup/autoMarkWarn",autoMarkWarn);
settings->setValue("startup/autoMarkMarker",autoMarkMarker);
settings->setValue("startup/loggingOnlyMode",loggingOnlyMode);
settings->setValue("startup/loggingOnlyFilteredMessages",loggingOnlyFilteredMessages);
settings->setValue("startup/splitfileyesno",splitlogfile);
settings->setValue("startup/maxFileSizeMB",fmaxFileSizeMB);
settings->setValue("startup/appendDateTime",appendDateTime);
Expand Down Expand Up @@ -358,6 +360,10 @@ void QDltSettingsManager::readSettingsLocal(QXmlStreamReader &xml)
{
loggingOnlyMode = xml.readElementText().toInt();
}
if(xml.name() == QString("loggingOnlyFilteredMessages"))
{
loggingOnlyFilteredMessages = xml.readElementText().toInt();
}
if(xml.name() == QString("markercolor"))
{
markercolor.setNamedColor(xml.readElementText());
Expand Down Expand Up @@ -430,6 +436,7 @@ void QDltSettingsManager::readSettings()
autoMarkWarn = settings->value("startup/autoMarkWarn",0).toInt();
autoMarkMarker = settings->value("startup/autoMarkMarker",1).toInt();
loggingOnlyMode = settings->value("startup/loggingOnlyMode",0).toInt();
loggingOnlyFilteredMessages = settings->value("startup/loggingOnlyFilteredMessages",0).toInt();
splitlogfile = settings->value("startup/splitfileyesno",0).toInt();
fmaxFileSizeMB = settings->value("startup/maxFileSizeMB",100).toFloat();
appendDateTime = settings->value("startup/appendDateTime",0).toInt();
Expand Down
1 change: 1 addition & 0 deletions qdlt/qdltsettingsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class QDLT_EXPORT QDltSettingsManager
int updateContextLoadingFile; // project and local setting
int updateContextsUnregister; // project and local setting
int loggingOnlyMode; // project and local setting
int loggingOnlyFilteredMessages; // project and local setting
int splitlogfile; // local and project setting
float fmaxFileSizeMB; // local and project setting
int appendDateTime; // local and project setting
Expand Down
49 changes: 43 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4273,7 +4273,26 @@ void MainWindow::read(EcuItem* ecuitem)
{
// DLT message found, write it with storage header
QByteArray empty;
writeDLTMessageToFile(empty,dataPtr,sizeMsg,ecuitem);
if(settings->loggingOnlyFilteredMessages)
{
// write only messages which match filter
bool silentMode = !QDltOptManager::getInstance()->issilentMode();
QDltMsg qmsg;
qmsg.setMsg(QByteArray(dataPtr,sizeMsg),false);
if ( true == pluginsEnabled ) // we check the general plugin enabled/disabled switch
{
pluginManager.decodeMsg(qmsg,silentMode);
}
if(qfile.checkFilter(qmsg))
{
writeDLTMessageToFile(empty,dataPtr,sizeMsg,ecuitem);
}
}
else
{
// write all messages
writeDLTMessageToFile(empty,dataPtr,sizeMsg,ecuitem);
}
totalBytesRcvd+=sizeMsg;
if(sizeMsg<=dataSize)
{
Expand Down Expand Up @@ -4330,18 +4349,36 @@ void MainWindow::read(EcuItem* ecuitem)
(ecuitem->interfacetype == EcuItem::INTERFACETYPE_SERIAL_DLT && ecuitem->serialcon.parseDlt(qmsg)) ||
(ecuitem->interfacetype == EcuItem::INTERFACETYPE_SERIAL_ASCII && ecuitem->serialcon.parseAscii(qmsg)) )
{
/* analyse received message, check if DLT control message response */
if ( (qmsg.getType()==QDltMsg::DltTypeControl) && (qmsg.getSubtype()==QDltMsg::DltControlResponse))
{
controlMessage_ReceiveControlMessage(ecuitem,qmsg);
}

/* write message to file */
QByteArray bufferHeader;
QByteArray bufferPayload;
bufferHeader = qmsg.getHeader();
bufferPayload = qmsg.getPayload();
writeDLTMessageToFile(bufferHeader,bufferPayload.data(),bufferPayload.size(),ecuitem);

/* analyse received message, check if DLT control message response */
if ( (qmsg.getType()==QDltMsg::DltTypeControl) && (qmsg.getSubtype()==QDltMsg::DltControlResponse))
if(settings->loggingOnlyFilteredMessages)
{
controlMessage_ReceiveControlMessage(ecuitem,qmsg);
// write only messages which match filter
bool silentMode = !QDltOptManager::getInstance()->issilentMode();
if ( true == pluginsEnabled ) // we check the general plugin enabled/disabled switch
{
pluginManager.decodeMsg(qmsg,silentMode);
}
if(qfile.checkFilter(qmsg))
{
writeDLTMessageToFile(bufferHeader,bufferPayload.data(),bufferPayload.size(),ecuitem);
}
}
else
{
// write all messages
writeDLTMessageToFile(bufferHeader,bufferPayload.data(),bufferPayload.size(),ecuitem);
}

} //end while

if(ecuitem->interfacetype == EcuItem::INTERFACETYPE_TCP)
Expand Down
2 changes: 2 additions & 0 deletions src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void SettingsDialog::writeDlg()
ui->checkBoxAutoMarkWarn->setCheckState(settings->autoMarkWarn?Qt::Checked:Qt::Unchecked);
ui->checkBoxAutoMarkMarker->setCheckState(settings->autoMarkMarker?Qt::Checked:Qt::Unchecked);
ui->checkBoxLoggingOnlyMode->setCheckState(settings->loggingOnlyMode?Qt::Checked:Qt::Unchecked);
ui->checkBoxLoggingOnlyFilteredMessages->setCheckState(settings->loggingOnlyFilteredMessages?Qt::Checked:Qt::Unchecked);
ui->groupBoxMaxFileSizeMB->setChecked(settings->splitlogfile?Qt::Checked:Qt::Unchecked);
ui->lineEditMaxFileSizeMB->setText(QString("%1").arg(settings->fmaxFileSizeMB));
ui->checkBoxAppendDateTime->setCheckState(settings->appendDateTime?Qt::Checked:Qt::Unchecked);
Expand Down Expand Up @@ -412,6 +413,7 @@ void SettingsDialog::readDlg()
settings->autoMarkWarn = (ui->checkBoxAutoMarkWarn->checkState() == Qt::Checked);
settings->autoMarkMarker = (ui->checkBoxAutoMarkMarker->checkState() == Qt::Checked);
settings->loggingOnlyMode = (ui->checkBoxLoggingOnlyMode->checkState() == Qt::Checked);
settings->loggingOnlyFilteredMessages = (ui->checkBoxLoggingOnlyFilteredMessages->checkState() == Qt::Checked);
settings->splitlogfile = ui->groupBoxMaxFileSizeMB->isChecked();
if(settings->splitlogfile != 0)
{
Expand Down
85 changes: 46 additions & 39 deletions src/settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -842,51 +842,31 @@
<string>Other</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxAutoMarkFatalError">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Automatically mark all messages of subtype ( loglevel ) &amp;quot;fatal&amp;quot; and &amp;quot;error&amp;quot; with red color&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Auto mark fatal/error messages</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QCheckBox" name="checkBoxAppendDateTime">
<property name="text">
<string>Append Date/Time to filename when closing DLT Viewer</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBoxUpdateContextLoadingFile">
<property name="text">
<string>Update Contexts when loading log file</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxAutoConnect">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If this chechbox is enabled the last ECU connected is tried to be connected automatically.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBoxUpdateContextUnregister">
<property name="text">
<string>Auto connect to ECUs at start</string>
<string>Update Context Unregister</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxAutoScroll">
<item row="7" column="0">
<widget class="QCheckBox" name="checkBoxLoggingOnlyMode">
<property name="text">
<string>Auto scroll</string>
<string>Logging only mode (Disables View and Plugins)</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkBoxLoggingOnlyMode">
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxAutoMarkMarker">
<property name="text">
<string>Logging only mode (Disables View and Plugins)</string>
<string>Auto mark Marker messages</string>
</property>
</widget>
</item>
Expand All @@ -897,7 +877,7 @@
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QGroupBox" name="groupBox_MarkerColor">
<property name="title">
<string>Manual marker color</string>
Expand Down Expand Up @@ -972,14 +952,24 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxAutoMarkMarker">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxAutoConnect">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If this chechbox is enabled the last ECU connected is tried to be connected automatically.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Auto mark Marker messages</string>
<string>Auto connect to ECUs at start</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="5" column="0">
<widget class="QCheckBox" name="checkBoxUpdateContextLoadingFile">
<property name="text">
<string>Update Contexts when loading log file</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QGroupBox" name="groupBoxMaxFileSizeMB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
Expand Down Expand Up @@ -1018,7 +1008,7 @@
<item>
<widget class="QLineEdit" name="lineEditMaxFileSizeMB">
<property name="enabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
Expand All @@ -1037,10 +1027,27 @@
</layout>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBoxUpdateContextUnregister">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxAutoScroll">
<property name="text">
<string>Update Context Unregister</string>
<string>Auto scroll</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxAutoMarkFatalError">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Automatically mark all messages of subtype ( loglevel ) &amp;quot;fatal&amp;quot; and &amp;quot;error&amp;quot; with red color&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Auto mark fatal/error messages</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checkBoxLoggingOnlyFilteredMessages">
<property name="text">
<string>Logging only filtered DLT Messages</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 2e25b0d

Please sign in to comment.