Added ability to save UDS scan log, fixed bug with aborting a UDS scan
This commit is contained in:
@@ -20,6 +20,7 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
connect(CANConManager::getInstance(), &CANConManager::framesReceived, this, &UDSScanWindow::rapidFrames);
|
connect(CANConManager::getInstance(), &CANConManager::framesReceived, this, &UDSScanWindow::rapidFrames);
|
||||||
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
|
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
|
||||||
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
|
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
|
||||||
|
connect(ui->btnSaveResults, &QPushButton::clicked, this, &UDSScanWindow::saveResults);
|
||||||
|
|
||||||
int numBuses = CANConManager::getInstance()->getNumBuses();
|
int numBuses = CANConManager::getInstance()->getNumBuses();
|
||||||
for (int n = 0; n < numBuses; n++) ui->cbBuses->addItem(QString::number(n));
|
for (int n = 0; n < numBuses; n++) ui->cbBuses->addItem(QString::number(n));
|
||||||
@@ -33,6 +34,44 @@ UDSScanWindow::~UDSScanWindow()
|
|||||||
delete waitTimer;
|
delete waitTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDSScanWindow::saveResults()
|
||||||
|
{
|
||||||
|
QString filename;
|
||||||
|
QFileDialog dialog(this);
|
||||||
|
|
||||||
|
QStringList filters;
|
||||||
|
filters.append(QString(tr("Text File (*.txt)")));
|
||||||
|
|
||||||
|
dialog.setFileMode(QFileDialog::AnyFile);
|
||||||
|
dialog.setNameFilters(filters);
|
||||||
|
dialog.setViewMode(QFileDialog::Detail);
|
||||||
|
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
filename = dialog.selectedFiles()[0];
|
||||||
|
if (!filename.contains('.')) filename += ".txt";
|
||||||
|
if (dialog.selectedNameFilter() == filters[0])
|
||||||
|
{
|
||||||
|
QFile *outFile = new QFile(filename);
|
||||||
|
|
||||||
|
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
delete outFile;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ui->listResults->count(); i++)
|
||||||
|
{
|
||||||
|
outFile->write(ui->listResults->item(i)->text().toUtf8());
|
||||||
|
outFile->write("\n");
|
||||||
|
}
|
||||||
|
outFile->close();
|
||||||
|
delete outFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UDSScanWindow::sendOnBuses(CANFrame &frame, int buses)
|
void UDSScanWindow::sendOnBuses(CANFrame &frame, int buses)
|
||||||
{
|
{
|
||||||
if (buses < ui->cbBuses->count()- 1)
|
if (buses < ui->cbBuses->count()- 1)
|
||||||
@@ -58,6 +97,7 @@ void UDSScanWindow::scanUDS()
|
|||||||
sendingFrames.clear();
|
sendingFrames.clear();
|
||||||
currentlyRunning = false;
|
currentlyRunning = false;
|
||||||
ui->btnScan->setText("Start Scan");
|
ui->btnScan->setText("Start Scan");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
waitTimer->setInterval(ui->spinDelay->value());
|
waitTimer->setInterval(ui->spinDelay->value());
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ private slots:
|
|||||||
void updatedFrames(int numFrames);
|
void updatedFrames(int numFrames);
|
||||||
void rapidFrames(const CANConnection* conn, const QVector<CANFrame>& pFrames);
|
void rapidFrames(const CANConnection* conn, const QVector<CANFrame>& pFrames);
|
||||||
void scanUDS();
|
void scanUDS();
|
||||||
|
void saveResults();
|
||||||
void timeOut();
|
void timeOut();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -24,6 +24,13 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="listResults"/>
|
<widget class="QListWidget" name="listResults"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnSaveResults">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save Scan Results</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Reference in New Issue
Block a user