Skip to content

Commit 3b5dada

Browse files
author
Mich
committed
Serial data can now be presented in HEX and BIN formats !
1 parent 2fe3be2 commit 3b5dada

File tree

10 files changed

+185
-59
lines changed

10 files changed

+185
-59
lines changed

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ Universal serial monitor with data plotting capabilities, based on [Qt](https://
1616
-
1717
---
1818

19-
**Work in progress:**
20-
21-
- "What’s this ?" popups for less obvious widgets and an introduction
22-
text/html doc displayed in the main text browser on first run.
23-
24-
- 3D Orientation Demo - for IMU testing (user will be able to toggle between chart view
25-
and a simple 3D scene containing an object rotating accordingly to received roll,
26-
pitch and yaw values, representing the sensor's orientation)
27-
28-
- Improvements, fixes etc.
29-
30-
----
31-
3219
***Notes:***
3320

3421
* The app uses a custom-written parser, which searches the incoming message for plottable data in form of label-value set. At the moment, all labels and values **must be separated with a whitespace** in order to be recognized. Its possible to use separators like "=" and "," - parser will be replace them with whitespace before processing. If no label is found, a generic name will be used i.e. "Graph 0".*

src/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef CONFIG_H
22
#define CONFIG_H
33

4-
#define VERSION "1.1"
4+
#define VERSION "1.2"
55
#define CHANGELOG_TEXT ""
66

77
#endif // CONFIG_H

src/infodialog.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
14-
<string>Dialog</string>
14+
<string>About this application</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout">
1717
<item row="1" column="1">
@@ -40,7 +40,7 @@
4040
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
4141
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
4242
p, li { white-space: pre-wrap; }
43-
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;&quot;&gt;
43+
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
4444
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:9pt;&quot;&gt;Universal serial monitor with data plotting capabilities, based on &lt;/span&gt;&lt;a href=&quot;https://www.qt.io/&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:9pt; text-decoration: underline; color:#0000ff;&quot;&gt;Qt&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:9pt;&quot;&gt;. Designed with all sorts of &lt;/span&gt;&lt;a href=&quot;https://www.arduino.cc/&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:9pt; text-decoration: underline; color:#0000ff;&quot;&gt;Arduino&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:9pt;&quot;&gt; projects in mind, as a handy tool for debugging and experimentation :)&lt;/span&gt;&lt;/p&gt;
4545
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:9pt; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
4646
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:9pt; font-weight:600;&quot;&gt;Author:&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:9pt;&quot;&gt; mich-w&lt;/span&gt;&lt;/p&gt;

src/mainwindow.cpp

Lines changed: 75 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void MainWindow::settingsLoadAll()
119119
}
120120

121121
if (appSettings.value("Info/organizationName").value<QString>() != appSettings.organizationName() &&
122-
appSettings.value("Info/applicationName").value<QString>() != appSettings.applicationName())
122+
appSettings.value("Info/applicationName").value<QString>() != appSettings.applicationName())
123123
{
124124
qDebug() << "Abort loading settings ! organizationName or applicationName incorrect. Config file might be missing.";
125125
return;
@@ -168,7 +168,7 @@ void MainWindow::settingsLoadAll()
168168
ui->comboBoxRAMSaveMode->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxRAMSaveMode.currentIndex").value<int>());
169169

170170
ui->checkBoxDTR->setChecked(appSettings.value("GUI_Elements/checkBoxDTR.isChecked").value<bool>());
171-
ui->checkBoxTrim->setChecked(appSettings.value("GUI_Elements/checkBoxTrim.isChecked").value<bool>());
171+
ui->checkBoxSimplify->setChecked(appSettings.value("GUI_Elements/checkBoxSimplify.isChecked").value<bool>());
172172
ui->checkBoxSendKey->setChecked(appSettings.value("GUI_Elements/checkBoxSendKey.isChecked").value<bool>());
173173
ui->checkBoxWrapText->setChecked(appSettings.value("GUI_Elements/checkBoxWrapText.isChecked").value<bool>());
174174
ui->checkBoxAutoTrack->setChecked(appSettings.value("GUI_Elements/checkBoxAutoTrack.isChecked").value<bool>());
@@ -249,7 +249,7 @@ void MainWindow::settingsSaveAll()
249249
appSettings.setValue("GUI_Elements/comboBoxRAMSaveMode.currentIndex", ui->comboBoxRAMSaveMode->currentIndex());
250250

251251
appSettings.setValue("GUI_Elements/checkBoxDTR.isChecked", ui->checkBoxDTR->isChecked());
252-
appSettings.setValue("GUI_Elements/checkBoxTrim.isChecked", ui->checkBoxTrim->isChecked());
252+
appSettings.setValue("GUI_Elements/checkBoxSimplify.isChecked", ui->checkBoxSimplify->isChecked());
253253
appSettings.setValue("GUI_Elements/checkBoxSendKey.isChecked", ui->checkBoxSendKey->isChecked());
254254
appSettings.setValue("GUI_Elements/checkBoxWrapText.isChecked", ui->checkBoxWrapText->isChecked());
255255
appSettings.setValue("GUI_Elements/checkBoxAutoTrack.isChecked", ui->checkBoxAutoTrack->isChecked());
@@ -724,9 +724,9 @@ void MainWindow::tracerShowPointValue(QMouseEvent *event)
724724
"<td>Y: %L3</td>"
725725
"</tr>"
726726
"</table>")
727-
.arg(graph->name())
728-
.arg(QTime::fromMSecsSinceStartOfDay(temp.x() * 1000).toString("hh:mm:ss:zzz"))
729-
.arg(QString::number(temp.y(), 'f', 5)),
727+
.arg(graph->name())
728+
.arg(QTime::fromMSecsSinceStartOfDay(temp.x() * 1000).toString("hh:mm:ss:zzz"))
729+
.arg(QString::number(temp.y(), 'f', 5)),
730730
ui->widgetChart, ui->widgetChart->rect());
731731
}
732732

@@ -797,17 +797,55 @@ void MainWindow::addLog(QString text)
797797
}
798798
}
799799

800+
void MainWindow::addLogBytes(QString prefix, QByteArray bytes, bool hexToBinary)
801+
{
802+
if (ui->pushButtonTextLogToggle->isChecked() == false)
803+
{
804+
QString currentDateTime = QDateTime::currentDateTime().toString("hh:mm:ss:zzz ");
805+
806+
QString bytesText;
807+
808+
if (hexToBinary == false)
809+
bytesText = prefix + bytes.toHex(' ');
810+
else
811+
{
812+
bytesText.append(prefix);
813+
for (auto i = 0; i < bytes.size(); ++i)
814+
{
815+
bytesText.append(QString::number(bytes[i], 2) + ' ');
816+
}
817+
}
818+
819+
if (ui->checkBoxShowTime->isChecked())
820+
bytesText = currentDateTime + bytesText;
821+
822+
ui->textBrowserLogs->append(bytesText);
823+
}
824+
}
825+
800826
void MainWindow::processSerial()
801827
{
802-
QString serialInput = serial.getString();
828+
QString serialInput = serial.getString().trimmed();
829+
QByteArray serialInputBytes = serial.getBytes();
803830

804-
if (serialInput.isEmpty() == false)
831+
if (ui->comboBoxFormat->currentIndex() == 0 && serialInput.isEmpty() == false)
805832
{
806-
if (ui->checkBoxTrim->isChecked()) // Append text to textBrowser
807-
addLog("Serial <<\t" + serialInput.trimmed());
833+
if (ui->checkBoxSimplify->isChecked()) // Append text to textBrowser
834+
addLog("Serial <<\t" + serialInput.simplified());
808835
else
809836
addLog("Serial <<\t" + serialInput);
837+
}
838+
else if (ui->comboBoxFormat->currentIndex() == 1 && serialInputBytes.length() > 0)
839+
{
840+
addLogBytes("Serial (HEX) <<\t", serialInputBytes);
841+
}
842+
else if (ui->comboBoxFormat->currentIndex() == 2 && serialInputBytes.length() > 0)
843+
{
844+
addLogBytes("Serial (BIN) <<\t", serialInputBytes, true);
845+
}
810846

847+
if (serialInput.isEmpty() == false)
848+
{
811849
parser.parse(serialInput, ui->checkBoxSyncSystemClock->isChecked(), ui->checkBoxExternalTimeReference->isChecked(), ui->lineEditExternalClockLabel->text()); // Parse string - split into labels + numeric data
812850
QStringList labelList = parser.getStringListLabels();
813851
QList<double> numericDataList = parser.getListNumericValues();
@@ -834,14 +872,27 @@ void MainWindow::writeLogToFile(QString rawLine, QStringList labelList, QList<do
834872

835873
void MainWindow::processUDP()
836874
{
837-
QString udpInput = networkUDP.readString();
838-
if (udpInput.isEmpty() == false)
875+
QString udpInput = networkUDP.readString().trimmed();
876+
QByteArray udpInputBytes = networkUDP.readBytes();
877+
878+
if (ui->comboBoxFormat->currentIndex() == 0 && udpInput.isEmpty() == false)
839879
{
840-
if (ui->checkBoxTrim->isChecked())
841-
addLog("UDP <<\t" + udpInput.trimmed());
880+
if (ui->checkBoxSimplify->isChecked())
881+
addLog("UDP <<\t" + udpInput.simplified());
842882
else
843883
addLog("UDP <<\t" + udpInput);
884+
}
885+
else if (ui->comboBoxFormat->currentIndex() == 1 && udpInputBytes.length() > 0)
886+
{
887+
addLogBytes("UDP (HEX) <<\t", udpInputBytes);
888+
}
889+
else if (ui->comboBoxFormat->currentIndex() == 2 && udpInputBytes.length() > 0)
890+
{
891+
addLogBytes("UDP (BIN) <<\t", udpInputBytes, true);
892+
}
844893

894+
if (udpInput.isEmpty() == false)
895+
{
845896
parser.parse(udpInput, ui->checkBoxSyncSystemClock->isChecked(), ui->checkBoxExternalTimeReference->isChecked(), ui->lineEditExternalClockLabel->text()); // Parse string - split into labels + numeric data
846897
QStringList labelList = parser.getStringListLabels();
847898
QList<double> numericDataList = parser.getListNumericValues();
@@ -877,9 +928,9 @@ void MainWindow::processChart(QStringList labelList, QList<double> numericDataLi
877928
}
878929

879930
if (canAddGraph && ui->widgetChart->graphCount() < ui->spinBoxMaxGraphs->value() &&
880-
((ui->comboBoxGraphDisplayMode->currentIndex() == 0) ||
881-
(ui->comboBoxGraphDisplayMode->currentIndex() == 1 &&
882-
ui->lineEditCustomParsingRules->text().simplified().contains(label, Qt::CaseSensitivity::CaseSensitive))))
931+
((ui->comboBoxGraphDisplayMode->currentIndex() == 0) ||
932+
(ui->comboBoxGraphDisplayMode->currentIndex() == 1 &&
933+
ui->lineEditCustomParsingRules->text().simplified().contains(label, Qt::CaseSensitivity::CaseSensitive))))
883934
{
884935
ui->widgetChart->addGraph();
885936
ui->widgetChart->graph()->setName(label);
@@ -1031,9 +1082,9 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
10311082
void MainWindow::sendSerial(QString message)
10321083
{
10331084
if (serial.send(message))
1034-
this->addLog("S >>\t" + message);
1085+
this->addLog("Serial >>\t" + message);
10351086
else
1036-
this->addLog("S >>\t Unable to send! Serial port closed !");
1087+
this->addLog("Serial >>\t Unable to send! Serial port closed !");
10371088
}
10381089

10391090
void MainWindow::on_checkBoxAutoRefresh_toggled(bool checked)
@@ -1559,7 +1610,7 @@ void MainWindow::sendDatagram(QString message)
15591610
networkUDP.write(message, QHostAddress(ui->lineEditUDPTargetIP->text()), ui->spinBoxUDPTargetPort->value());
15601611
}
15611612

1562-
addLog("App >>\t" + message);
1613+
addLog("UDP >>\t" + message);
15631614
}
15641615

15651616
void MainWindow::on_comboBoxUDPSendMode_currentIndexChanged(const QString &arg1)
@@ -1925,7 +1976,7 @@ void MainWindow::loadFromRAM(bool loadText)
19251976
{
19261977
QStringList RAMText = parser.getTextList();
19271978
foreach (auto line, RAMText)
1928-
addLog(line);
1979+
addLog("Mem >>\t" + line);
19291980
}
19301981

19311982
if (RAMLabels.isEmpty() || RAMData.isEmpty() || RAMTime.isEmpty())
@@ -1973,18 +2024,18 @@ void MainWindow::on_pushButtonLoadFile_clicked()
19732024

19742025
if (fileReader.readAllAtOnce(&inputFile))
19752026
{
1976-
addLog("Read file succesfully... ");
2027+
addLog("App >>\t Read file succesfully... ");
19772028
}
19782029
else
19792030
{
1980-
addLog("invalid file !");
2031+
addLog("App >>\t invalid file !");
19812032
ui->pushButtonLoadFile->setText("Load File");
19822033
ui->progressBarLoadFile->setValue(0);
19832034
}
19842035
}
19852036
else
19862037
{
1987-
addLog("File Reader - Invalid file path !");
2038+
addLog("App >>\t file reader error - invalid file path !");
19882039
ui->pushButtonLoadFile->setText("Load File");
19892040
ui->progressBarLoadFile->setValue(0);
19902041
}

src/mainwindow.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public slots:
5454
void updateProgressBar(float *percent);
5555
private slots:
5656
void aboutToQuitSlot();
57+
void chartBeforeReplotSlot();
5758
void chartContextMenuRequest(QPoint pos);
5859
void chartMouseDoubleClickHandler(QMouseEvent *event);
5960
void chartMousePressHandler(QMouseEvent *event);
60-
void chartBeforeReplotSlot();
6161
void chartSelectionChanged();
6262
void comboBoxSendReturnPressedSlot();
6363
void hideAllGraphs();
@@ -68,12 +68,14 @@ private slots:
6868
void on_actionAbout_Qt_triggered();
6969
void on_actionFull_chart_triggered();
7070
void on_actionFull_text_view_triggered();
71+
void on_actionInfo_triggered();
7172
void on_actionPlotter_triggered();
7273
void on_actionPrint_Graph_triggered();
7374
void on_actionPrint_log_triggered();
7475
void on_actionQuit_triggered();
7576
void on_actionSave_As_triggered();
7677
void on_actionSave_graph_as_triggered();
78+
void on_actionUser_guide_triggered();
7779
void on_actionWhat_s_new_triggered();
7880
void on_checkBoxAutoLogging_toggled(bool checked);
7981
void on_checkBoxAutoRefresh_toggled(bool checked);
@@ -85,6 +87,7 @@ private slots:
8587
void on_checkBoxSyncSystemClock_toggled(bool checked);
8688
void on_checkBoxWrapText_toggled(bool checked);
8789
void on_comboBoxGraphDisplayMode_currentIndexChanged(const QString &arg1);
90+
void on_comboBoxLoggingMode_currentIndexChanged(int index);
8891
void on_comboBoxSerialReadMode_currentIndexChanged(int index);
8992
void on_comboBoxTracerStyle_currentIndexChanged(const QString &arg1);
9093
void on_comboBoxUDPReceiveMode_currentIndexChanged(const QString &arg1);
@@ -128,16 +131,14 @@ private slots:
128131
void processSerial();
129132
void processUDP();
130133
void showAllGraphs();
131-
void tracerShowPointValue(QMouseEvent *event);
132134
void showSelectedGraph();
133135
void showSelectedGraphExclusively();
136+
void tracerShowPointValue(QMouseEvent *event);
134137
void updateSerialDeviceList();
135-
void on_actionUser_guide_triggered();
136-
void on_actionInfo_triggered();
137-
void on_comboBoxLoggingMode_currentIndexChanged(int index);
138138
private:
139139
// QCompleter *completer;
140140
FileReader fileReader;
141+
InfoDialog infoDialog;
141142
Logger fileLogger;
142143
NetworkUDP networkUDP;
143144
Parser parser;
@@ -150,8 +151,8 @@ private slots:
150151
QTimer *udpStringProcessingTimer;
151152
Serial serial;
152153
Ui::MainWindow *ui;
153-
InfoDialog infoDialog;
154154
void addLog(QString text);
155+
void addLogBytes(QString prefix, QByteArray bytes, bool hexToBinary = false);
155156
void chartPrintPreview();
156157
void clearGraphData(bool replot);
157158
void clearGraphs(bool replot);
@@ -173,7 +174,6 @@ private slots:
173174
void setupGUI();
174175
void setupTable();
175176
void writeLogToFile(QString rawLine, QStringList labelList, QList<double> dataList, QList<long> timeList);
176-
177177
protected:
178178
void keyPressEvent(QKeyEvent *event);
179179
};

src/mainwindow.ui

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,15 +1543,15 @@
15431543
</widget>
15441544
</item>
15451545
<item>
1546-
<widget class="QCheckBox" name="checkBoxTrim">
1546+
<widget class="QCheckBox" name="checkBoxSimplify">
15471547
<property name="maximumSize">
15481548
<size>
15491549
<width>16777215</width>
15501550
<height>25</height>
15511551
</size>
15521552
</property>
15531553
<property name="text">
1554-
<string>Trim</string>
1554+
<string>Simplify</string>
15551555
</property>
15561556
</widget>
15571557
</item>
@@ -1562,6 +1562,31 @@
15621562
</property>
15631563
</widget>
15641564
</item>
1565+
<item>
1566+
<widget class="QComboBox" name="comboBoxFormat">
1567+
<property name="sizePolicy">
1568+
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
1569+
<horstretch>0</horstretch>
1570+
<verstretch>0</verstretch>
1571+
</sizepolicy>
1572+
</property>
1573+
<item>
1574+
<property name="text">
1575+
<string>TEXT</string>
1576+
</property>
1577+
</item>
1578+
<item>
1579+
<property name="text">
1580+
<string>HEX</string>
1581+
</property>
1582+
</item>
1583+
<item>
1584+
<property name="text">
1585+
<string>BIN</string>
1586+
</property>
1587+
</item>
1588+
</widget>
1589+
</item>
15651590
<item>
15661591
<spacer name="horizontalSpacer_2">
15671592
<property name="maximumSize">
@@ -2489,7 +2514,7 @@
24892514
</customwidgets>
24902515
<tabstops>
24912516
<tabstop>lineEditHighlight</tabstop>
2492-
<tabstop>checkBoxTrim</tabstop>
2517+
<tabstop>checkBoxSimplify</tabstop>
24932518
<tabstop>pushButtonScrollToButtom</tabstop>
24942519
<tabstop>pushButtonClear</tabstop>
24952520
<tabstop>tabWidgetConnectivity</tabstop>

0 commit comments

Comments
 (0)