add isotp ascii decoding and autoscroll

This commit is contained in:
Leopixelo
2026-06-08 15:13:13 +02:00
parent be85c1e413
commit 1b77ee8a35
4 changed files with 50 additions and 3 deletions
+2 -1
View File
@@ -172,6 +172,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->btnCollapseAll, &QAbstractButton::clicked, this, &MainWindow::collapseAllRows);
connect(ui->tableSimpleSender, SIGNAL(cellChanged(int,int)), this, SLOT(onSenderCellChanged(int,int)));
ui->tableSimpleSender->setVisible(false);
lbStatusConnected.setText(tr("Connected to 0 buses"));
lbHelp.setText(tr("Press F1 on any screen for help"));
@@ -396,7 +397,7 @@ void MainWindow::readSettings()
ui->canFramesView->setColumnWidth(5, settings.value("Main/BusColumn", 40).toUInt()); //bus
ui->canFramesView->setColumnWidth(6, settings.value("Main/LengthColumn", 40).toUInt()); //length
ui->canFramesView->setColumnWidth(7, settings.value("Main/AsciiColumn", 50).toUInt()); //ascii
//ui->canFramesView->setColumnWidth(8, settings.value("Main/DataColumn", 225).toUInt()); //data
ui->canFramesView->setColumnWidth(8, settings.value("Main/DataColumn", 400).toUInt()); //data
}
if (settings.value("Main/AutoScroll", false).toBool())
{
+36 -2
View File
@@ -11,6 +11,7 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector<CANFrame> *frames
ui->setupUi(this);
setWindowFlags(Qt::Window);
modelFrames = frames;
m_isAutoScrolling = false;
decoder = new ISOTP_HANDLER;
udsDecoder = new UDS_HANDLER;
@@ -33,6 +34,7 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector<CANFrame> *frames
connect(ui->btnClearList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::clearList);
connect(ui->btnSaveList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::saveList);
connect(ui->cbUseExtendedAddressing, SIGNAL(toggled(bool)), this, SLOT(useExtendedAddressing(bool)));
connect(ui->tableIsoFrames->verticalScrollBar(), &QScrollBar::valueChanged, this, &ISOTP_InterpreterWindow::onManualScroll);
QStringList headers;
headers << "Timestamp" << "ID" << "Bus" << "Dir" << "Length" << "Data";
@@ -322,6 +324,25 @@ void ISOTP_InterpreterWindow::newUDSMessage(UDS_MESSAGE msg)
ui->txtFrameDetails->setPlainText(buildText);
}
void ISOTP_InterpreterWindow::onManualScroll()
{
// If the user manually scrolls, check if they're at the bottom
if (!m_isAutoScrolling)
{
QScrollBar *scrollBar = ui->tableIsoFrames->verticalScrollBar();
if (scrollBar->value() == scrollBar->maximum())
{
// At bottom - enable autoscroll
ui->cbAutoscroll->setChecked(true);
}
else
{
// Not at bottom - disable autoscroll
ui->cbAutoscroll->setChecked(false);
}
}
}
void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
{
int rowNum;
@@ -357,8 +378,21 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
for (int i = 0; i < dataLen; i++)
{
tempString.append(Utility::formatNumber(data[i]));
tempString.append(" ");
// if last character is the newline
if (i == dataLen -1 && data[i] == '\n') {
continue;
}
tempString.append(QString(QChar(data[i])));
}
ui->tableIsoFrames->setItem(rowNum, 5, new QTableWidgetItem(tempString));
// autoscroll to the newly added row if autoscroll is enabled
if (ui->cbAutoscroll->isChecked())
{
m_isAutoScrolling = true;
ui->tableIsoFrames->scrollToItem(ui->tableIsoFrames->item(rowNum, 0), QAbstractItemView::PositionAtBottom);
// scroll down one additional row height
ui->tableIsoFrames->verticalScrollBar()->setValue(ui->tableIsoFrames->verticalScrollBar()->value() + ui->tableIsoFrames->rowHeight(rowNum));
m_isAutoScrolling = false;
}
}
+2
View File
@@ -33,6 +33,7 @@ private slots:
void interpretCapturedFrames();
void useExtendedAddressing(bool checked);
void headerClicked(int logicalIndex);
void onManualScroll();
private:
Ui::ISOTP_InterpreterWindow *ui;
@@ -42,6 +43,7 @@ private:
const QVector<CANFrame> *modelFrames;
QVector<ISOTP_MESSAGE> messages;
QHash<int, bool> idFilters;
bool m_isAutoScrolling;
void closeEvent(QCloseEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
+10
View File
@@ -63,6 +63,16 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QCheckBox" name="cbAutoscroll">
<property name="text">
<string>Autoscroll to new messages</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>