add isotp ascii decoding and autoscroll
This commit is contained in:
+2
-1
@@ -172,6 +172,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->btnCollapseAll, &QAbstractButton::clicked, this, &MainWindow::collapseAllRows);
|
connect(ui->btnCollapseAll, &QAbstractButton::clicked, this, &MainWindow::collapseAllRows);
|
||||||
|
|
||||||
connect(ui->tableSimpleSender, SIGNAL(cellChanged(int,int)), this, SLOT(onSenderCellChanged(int,int)));
|
connect(ui->tableSimpleSender, SIGNAL(cellChanged(int,int)), this, SLOT(onSenderCellChanged(int,int)));
|
||||||
|
ui->tableSimpleSender->setVisible(false);
|
||||||
|
|
||||||
lbStatusConnected.setText(tr("Connected to 0 buses"));
|
lbStatusConnected.setText(tr("Connected to 0 buses"));
|
||||||
lbHelp.setText(tr("Press F1 on any screen for help"));
|
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(5, settings.value("Main/BusColumn", 40).toUInt()); //bus
|
||||||
ui->canFramesView->setColumnWidth(6, settings.value("Main/LengthColumn", 40).toUInt()); //length
|
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(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())
|
if (settings.value("Main/AutoScroll", false).toBool())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector<CANFrame> *frames
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(Qt::Window);
|
setWindowFlags(Qt::Window);
|
||||||
modelFrames = frames;
|
modelFrames = frames;
|
||||||
|
m_isAutoScrolling = false;
|
||||||
|
|
||||||
decoder = new ISOTP_HANDLER;
|
decoder = new ISOTP_HANDLER;
|
||||||
udsDecoder = new UDS_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->btnClearList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::clearList);
|
||||||
connect(ui->btnSaveList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::saveList);
|
connect(ui->btnSaveList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::saveList);
|
||||||
connect(ui->cbUseExtendedAddressing, SIGNAL(toggled(bool)), this, SLOT(useExtendedAddressing(bool)));
|
connect(ui->cbUseExtendedAddressing, SIGNAL(toggled(bool)), this, SLOT(useExtendedAddressing(bool)));
|
||||||
|
connect(ui->tableIsoFrames->verticalScrollBar(), &QScrollBar::valueChanged, this, &ISOTP_InterpreterWindow::onManualScroll);
|
||||||
|
|
||||||
QStringList headers;
|
QStringList headers;
|
||||||
headers << "Timestamp" << "ID" << "Bus" << "Dir" << "Length" << "Data";
|
headers << "Timestamp" << "ID" << "Bus" << "Dir" << "Length" << "Data";
|
||||||
@@ -322,6 +324,25 @@ void ISOTP_InterpreterWindow::newUDSMessage(UDS_MESSAGE msg)
|
|||||||
ui->txtFrameDetails->setPlainText(buildText);
|
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)
|
void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
|
||||||
{
|
{
|
||||||
int rowNum;
|
int rowNum;
|
||||||
@@ -357,8 +378,21 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
|
|||||||
|
|
||||||
for (int i = 0; i < dataLen; i++)
|
for (int i = 0; i < dataLen; i++)
|
||||||
{
|
{
|
||||||
tempString.append(Utility::formatNumber(data[i]));
|
// if last character is the newline
|
||||||
tempString.append(" ");
|
if (i == dataLen -1 && data[i] == '\n') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tempString.append(QString(QChar(data[i])));
|
||||||
}
|
}
|
||||||
ui->tableIsoFrames->setItem(rowNum, 5, new QTableWidgetItem(tempString));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ private slots:
|
|||||||
void interpretCapturedFrames();
|
void interpretCapturedFrames();
|
||||||
void useExtendedAddressing(bool checked);
|
void useExtendedAddressing(bool checked);
|
||||||
void headerClicked(int logicalIndex);
|
void headerClicked(int logicalIndex);
|
||||||
|
void onManualScroll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ISOTP_InterpreterWindow *ui;
|
Ui::ISOTP_InterpreterWindow *ui;
|
||||||
@@ -42,6 +43,7 @@ private:
|
|||||||
const QVector<CANFrame> *modelFrames;
|
const QVector<CANFrame> *modelFrames;
|
||||||
QVector<ISOTP_MESSAGE> messages;
|
QVector<ISOTP_MESSAGE> messages;
|
||||||
QHash<int, bool> idFilters;
|
QHash<int, bool> idFilters;
|
||||||
|
bool m_isAutoScrolling;
|
||||||
|
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|||||||
@@ -63,6 +63,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Reference in New Issue
Block a user