Changed UDS window to work more quickly and use the new rapid frame
system.
This commit is contained in:
+60
-53
@@ -13,9 +13,10 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
currentlyRunning = false;
|
currentlyRunning = false;
|
||||||
|
|
||||||
waitTimer = new QTimer;
|
waitTimer = new QTimer;
|
||||||
waitTimer->setInterval(300);
|
waitTimer->setInterval(100);
|
||||||
|
|
||||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
||||||
|
connect(MainWindow::getReference(), SIGNAL(frameUpdateRapid(int)), this, SLOT(rapidFrames(int)));
|
||||||
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);
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ void UDSScanWindow::scanUDS()
|
|||||||
if (buses < 1) buses = 1;
|
if (buses < 1) buses = 1;
|
||||||
|
|
||||||
//start out by sending tester present to every address to see if anyone replies
|
//start out by sending tester present to every address to see if anyone replies
|
||||||
for (id = startID; id < endID; id++)
|
for (id = startID; id <= endID; id++)
|
||||||
{
|
{
|
||||||
frame.ID = id;
|
frame.ID = id;
|
||||||
frame.len = 8;
|
frame.len = 8;
|
||||||
@@ -113,15 +114,9 @@ void UDSScanWindow::scanUDS()
|
|||||||
sendNextMsg();
|
sendNextMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Updates here are sent about every 1/4 second. That's fine for most windows but not this one.
|
||||||
void UDSScanWindow::updatedFrames(int numFrames)
|
void UDSScanWindow::updatedFrames(int numFrames)
|
||||||
{
|
{
|
||||||
CANFrame thisFrame;
|
|
||||||
QString result;
|
|
||||||
int id;
|
|
||||||
int offset = ui->spinReplyOffset->value();
|
|
||||||
CANFrame sentFrame;
|
|
||||||
bool gotReply = false;
|
|
||||||
|
|
||||||
if (numFrames == -1) //all frames deleted. We don't care
|
if (numFrames == -1) //all frames deleted. We don't care
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -130,61 +125,73 @@ void UDSScanWindow::updatedFrames(int numFrames)
|
|||||||
}
|
}
|
||||||
else //just got some new frames. See if they are relevant.
|
else //just got some new frames. See if they are relevant.
|
||||||
{
|
{
|
||||||
if (numFrames > modelFrames->count()) return;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int numSending = sendingFrames.length();
|
//Updates here are nearly once per millisecond if there is heavy traffic. That's more like it!
|
||||||
if (numSending == 0) return;
|
void UDSScanWindow::rapidFrames(int numFrames)
|
||||||
|
{
|
||||||
|
CANFrame thisFrame;
|
||||||
|
QString result;
|
||||||
|
int id;
|
||||||
|
int offset = ui->spinReplyOffset->value();
|
||||||
|
CANFrame sentFrame;
|
||||||
|
bool gotReply = false;
|
||||||
|
|
||||||
|
if (numFrames > modelFrames->count()) return;
|
||||||
|
|
||||||
|
int numSending = sendingFrames.length();
|
||||||
|
if (numSending == 0) return;
|
||||||
|
if (currIdx >= numSending) return;
|
||||||
|
sentFrame = sendingFrames[currIdx];
|
||||||
|
|
||||||
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
|
{
|
||||||
if (currIdx >= numSending) return;
|
if (currIdx >= numSending) return;
|
||||||
sentFrame = sendingFrames[currIdx];
|
thisFrame = modelFrames->at(i);
|
||||||
|
id = thisFrame.ID;
|
||||||
|
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
if ((id == (sentFrame.ID + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
|
||||||
{
|
{
|
||||||
if (currIdx >= numSending) return;
|
int temp = thisFrame.data[0] >> 4;
|
||||||
thisFrame = modelFrames->at(i);
|
if (temp == 0) //single frame reply (maybe)
|
||||||
id = thisFrame.ID;
|
|
||||||
|
|
||||||
if ((id == (sentFrame.ID + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
|
|
||||||
{
|
{
|
||||||
int temp = thisFrame.data[0] >> 4;
|
if (thisFrame.data[1] == 0x40 + sendingFrames[currIdx].data[1])
|
||||||
if (temp == 0) //single frame reply (maybe)
|
|
||||||
{
|
{
|
||||||
if (thisFrame.data[1] == 0x40 + sendingFrames[currIdx].data[1])
|
result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
|
||||||
{
|
+ QString::number(sentFrame.data[1], 16)
|
||||||
result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
|
+ " " + QString::number(sentFrame.data[2], 16) + " with affirmation from ID " + QString::number(id, 16)
|
||||||
+ QString::number(sentFrame.data[1], 16)
|
+ " on bus " + QString::number(thisFrame.bus) + ".";
|
||||||
+ " " + QString::number(sentFrame.data[2], 16) + " with affirmation from ID " + QString::number(id, 16)
|
gotReply = true;
|
||||||
+ " on bus " + QString::number(thisFrame.bus) + ".";
|
|
||||||
gotReply = true;
|
|
||||||
}
|
|
||||||
else if ( thisFrame.data[1] == 0x7F)
|
|
||||||
{
|
|
||||||
result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
|
|
||||||
+ QString::number(sentFrame.data[1], 16)
|
|
||||||
+ " " + QString::number(sentFrame.data[2], 16) + " with an error from ID " + QString::number(id, 16)
|
|
||||||
+ " on bus " + QString::number(thisFrame.bus) + ".";
|
|
||||||
gotReply = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if ( thisFrame.data[1] == 0x7F)
|
||||||
if (temp == 1) //start of a multiframe reply
|
|
||||||
{
|
{
|
||||||
if (thisFrame.data[2] == 0x40 + sendingFrames[currIdx].data[1])
|
result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
|
||||||
{
|
+ QString::number(sentFrame.data[1], 16)
|
||||||
result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
|
+ " " + QString::number(sentFrame.data[2], 16) + " with an error from ID " + QString::number(id, 16)
|
||||||
+ QString::number(sentFrame.data[1], 16)
|
+ " on bus " + QString::number(thisFrame.bus) + ".";
|
||||||
+ " " + QString::number(sentFrame.data[2], 16) + " with affirmation from ID " + QString::number(id, 16)
|
gotReply = true;
|
||||||
+ " on bus " + QString::number(thisFrame.bus) + ".";
|
|
||||||
gotReply = true;
|
|
||||||
}
|
|
||||||
//error replies are never multiframe so the check doesn't have to be done here.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (temp == 1) //start of a multiframe reply
|
||||||
|
{
|
||||||
|
if (thisFrame.data[2] == 0x40 + sendingFrames[currIdx].data[1])
|
||||||
|
{
|
||||||
|
result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
|
||||||
|
+ QString::number(sentFrame.data[1], 16)
|
||||||
|
+ " " + QString::number(sentFrame.data[2], 16) + " with affirmation from ID " + QString::number(id, 16)
|
||||||
|
+ " on bus " + QString::number(thisFrame.bus) + ".";
|
||||||
|
gotReply = true;
|
||||||
|
}
|
||||||
|
//error replies are never multiframe so the check doesn't have to be done here.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gotReply)
|
}
|
||||||
{
|
if (gotReply)
|
||||||
ui->listResults->addItem(result);
|
{
|
||||||
sendNextMsg();
|
ui->listResults->addItem(result);
|
||||||
}
|
sendNextMsg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatedFrames(int numFrames);
|
void updatedFrames(int numFrames);
|
||||||
|
void rapidFrames(int numFrames);
|
||||||
void scanUDS();
|
void scanUDS();
|
||||||
void timeOut();
|
void timeOut();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user