More changes to UDS scanner to make it better able to find UDS nodes even if they don't quite match standard UDS conventions, Ability to start/stop UDS scan when it was running.
This commit is contained in:
+32
-7
@@ -10,6 +10,8 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
|
|
||||||
modelFrames = frames;
|
modelFrames = frames;
|
||||||
|
|
||||||
|
currentlyRunning = false;
|
||||||
|
|
||||||
waitTimer = new QTimer;
|
waitTimer = new QTimer;
|
||||||
waitTimer->setInterval(300);
|
waitTimer->setInterval(300);
|
||||||
|
|
||||||
@@ -32,6 +34,14 @@ UDSScanWindow::~UDSScanWindow()
|
|||||||
|
|
||||||
void UDSScanWindow::scanUDS()
|
void UDSScanWindow::scanUDS()
|
||||||
{
|
{
|
||||||
|
if (currentlyRunning)
|
||||||
|
{
|
||||||
|
waitTimer->stop();
|
||||||
|
sendingFrames.clear();
|
||||||
|
currentlyRunning = false;
|
||||||
|
ui->btnScan->setText("Start Scan");
|
||||||
|
}
|
||||||
|
|
||||||
ui->listResults->clear();
|
ui->listResults->clear();
|
||||||
sendingFrames.clear();
|
sendingFrames.clear();
|
||||||
|
|
||||||
@@ -98,6 +108,8 @@ void UDSScanWindow::scanUDS()
|
|||||||
|
|
||||||
waitTimer->start();
|
waitTimer->start();
|
||||||
currIdx = -1;
|
currIdx = -1;
|
||||||
|
currentlyRunning = true;
|
||||||
|
ui->btnScan->setText("Abort Scan");
|
||||||
sendNextMsg();
|
sendNextMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +118,9 @@ void UDSScanWindow::updatedFrames(int numFrames)
|
|||||||
CANFrame thisFrame;
|
CANFrame thisFrame;
|
||||||
QString result;
|
QString result;
|
||||||
int id;
|
int id;
|
||||||
|
int offset = ui->spinReplyOffset->value();
|
||||||
|
bool gotReply = false;
|
||||||
|
|
||||||
if (numFrames == -1) //all frames deleted. We don't care
|
if (numFrames == -1) //all frames deleted. We don't care
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -120,32 +135,40 @@ void UDSScanWindow::updatedFrames(int numFrames)
|
|||||||
thisFrame = modelFrames->at(i);
|
thisFrame = modelFrames->at(i);
|
||||||
id = thisFrame.ID;
|
id = thisFrame.ID;
|
||||||
|
|
||||||
id -= ui->spinReplyOffset->value(); //back to original ECU id
|
if (id == (sendingFrames[currIdx].ID + offset) || ui->cbAllowAdaptiveOffset->isChecked())
|
||||||
if (id == sendingFrames[currIdx].ID)
|
{
|
||||||
|
int temp = thisFrame.data[0] >> 4;
|
||||||
|
if (temp == 0 || temp == 1)
|
||||||
{
|
{
|
||||||
if (thisFrame.data[1] == 0x40 + sendingFrames[currIdx].data[1])
|
if (thisFrame.data[1] == 0x40 + sendingFrames[currIdx].data[1])
|
||||||
{
|
{
|
||||||
result = "ECU at bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " responds to mode "
|
result = "Request on bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " got response to mode "
|
||||||
+ QString::number(sendingFrames[currIdx].data[1], 16)
|
+ QString::number(sendingFrames[currIdx].data[1], 16)
|
||||||
+ " " + QString::number(sendingFrames[currIdx].data[2], 16) + " with affirmation.";
|
+ " " + QString::number(sendingFrames[currIdx].data[2], 16) + " with affirmation from ID " + QString::number(id, 16) + ".";
|
||||||
|
gotReply = true;
|
||||||
}
|
}
|
||||||
else if ( thisFrame.data[1] == 0x7F)
|
else if ( thisFrame.data[1] == 0x7F)
|
||||||
{
|
{
|
||||||
result = "ECU at bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " responds to mode "
|
result = "Request on bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " got response to mode "
|
||||||
+ QString::number(sendingFrames[currIdx].data[1], 16)
|
+ QString::number(sendingFrames[currIdx].data[1], 16)
|
||||||
+ " " + QString::number(sendingFrames[currIdx].data[2], 16) + " with an error.";
|
+ " " + QString::number(sendingFrames[currIdx].data[2], 16) + " with an error from ID " + QString::number(id, 16) + ".";
|
||||||
|
gotReply = true;
|
||||||
}
|
}
|
||||||
|
if (gotReply)
|
||||||
|
{
|
||||||
ui->listResults->addItem(result);
|
ui->listResults->addItem(result);
|
||||||
sendNextMsg();
|
sendNextMsg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UDSScanWindow::timeOut()
|
void UDSScanWindow::timeOut()
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
result = "ECU at bus " + QString::number(sendingFrames[currIdx].bus) + " ID: " + QString::number(sendingFrames[currIdx].ID, 16) + " did not respond to mode "
|
result = "Request on bus " + QString::number(sendingFrames[currIdx].bus) + " ID: " + QString::number(sendingFrames[currIdx].ID, 16) + " got no response to mode "
|
||||||
+ QString::number(sendingFrames[currIdx].data[1], 16) + " " + QString::number(sendingFrames[currIdx].data[2], 16);
|
+ QString::number(sendingFrames[currIdx].data[1], 16) + " " + QString::number(sendingFrames[currIdx].data[2], 16);
|
||||||
ui->listResults->addItem(result);
|
ui->listResults->addItem(result);
|
||||||
|
|
||||||
@@ -162,5 +185,7 @@ void UDSScanWindow::sendNextMsg()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
waitTimer->stop();
|
waitTimer->stop();
|
||||||
|
ui->btnScan->setText("Start Scan");
|
||||||
|
currentlyRunning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ private:
|
|||||||
QTimer *waitTimer;
|
QTimer *waitTimer;
|
||||||
QList<CANFrame> sendingFrames;
|
QList<CANFrame> sendingFrames;
|
||||||
int currIdx = 0;
|
int currIdx = 0;
|
||||||
|
bool currentlyRunning;
|
||||||
|
|
||||||
void sendNextMsg();
|
void sendNextMsg();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -84,6 +84,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbAllowAdaptiveOffset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Allow adaptive reply offset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
Reference in New Issue
Block a user