Fixes to UDS scan window.

This commit is contained in:
Collin Kidder
2016-02-28 16:10:34 -05:00
parent 96d9f40193
commit 07b63ac127
+35 -13
View File
@@ -119,6 +119,7 @@ void UDSScanWindow::updatedFrames(int numFrames)
QString result; QString result;
int id; int id;
int offset = ui->spinReplyOffset->value(); int offset = ui->spinReplyOffset->value();
CANFrame sentFrame;
bool gotReply = false; bool gotReply = false;
if (numFrames == -1) //all frames deleted. We don't care if (numFrames == -1) //all frames deleted. We don't care
@@ -130,40 +131,60 @@ 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; 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++) for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
{ {
if (currIdx >= numSending) return;
thisFrame = modelFrames->at(i); thisFrame = modelFrames->at(i);
id = thisFrame.ID; id = thisFrame.ID;
int numFrames = sendingFrames.length(); if ((id == (sentFrame.ID + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
if (numFrames > 0 && numFrames > currIdx && id == (sendingFrames[currIdx].ID + offset) || ui->cbAllowAdaptiveOffset->isChecked())
{ {
int temp = thisFrame.data[0] >> 4; int temp = thisFrame.data[0] >> 4;
if (temp == 0 || temp == 1) if (temp == 0) //single frame reply (maybe)
{ {
if (thisFrame.data[1] == 0x40 + sendingFrames[currIdx].data[1]) if (thisFrame.data[1] == 0x40 + sendingFrames[currIdx].data[1])
{ {
result = "Request on bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " got response to mode " result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
+ QString::number(sendingFrames[currIdx].data[1], 16) + QString::number(sentFrame.data[1], 16)
+ " " + QString::number(sendingFrames[currIdx].data[2], 16) + " with affirmation from ID " + QString::number(id, 16) + "."; + " " + QString::number(sentFrame.data[2], 16) + " with affirmation from ID " + QString::number(id, 16)
+ " on bus " + QString::number(thisFrame.bus) + ".";
gotReply = true; gotReply = true;
} }
else if ( thisFrame.data[1] == 0x7F) else if ( thisFrame.data[1] == 0x7F)
{ {
result = "Request on bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " got response to mode " result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
+ QString::number(sendingFrames[currIdx].data[1], 16) + QString::number(sentFrame.data[1], 16)
+ " " + QString::number(sendingFrames[currIdx].data[2], 16) + " with an error from ID " + QString::number(id, 16) + "."; + " " + QString::number(sentFrame.data[2], 16) + " with an error from ID " + QString::number(id, 16)
+ " on bus " + QString::number(thisFrame.bus) + ".";
gotReply = true; gotReply = true;
} }
if (gotReply) }
if (temp == 1) //start of a multiframe reply
{
if (thisFrame.data[2] == 0x40 + sendingFrames[currIdx].data[1])
{ {
ui->listResults->addItem(result); result = "Request on bus " + QString::number(sentFrame.bus) + " ID: " + QString::number(sentFrame.ID, 16) + " got response to mode "
sendNextMsg(); + 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)
{
ui->listResults->addItem(result);
sendNextMsg();
}
} }
} }
@@ -183,6 +204,7 @@ void UDSScanWindow::sendNextMsg()
if (currIdx < sendingFrames.count()) if (currIdx < sendingFrames.count())
{ {
emit sendCANFrame(&sendingFrames[currIdx], sendingFrames[currIdx].bus); emit sendCANFrame(&sendingFrames[currIdx], sendingFrames[currIdx].bus);
waitTimer->start();
} }
else else
{ {