Fixed crash bug found in many sub screens, made UDS scanner work better.
This commit is contained in:
@@ -44,6 +44,7 @@ void DiscreteStateWindow::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;
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
{
|
{
|
||||||
thisFrame = modelFrames->at(i);
|
thisFrame = modelFrames->at(i);
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ void FlowViewWindow::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 refID = frameCache[0].ID;
|
int refID = frameCache[0].ID;
|
||||||
bool needRefresh = false;
|
bool needRefresh = false;
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ void FrameInfoWindow::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 currID = ui->listFrameID->currentItem()->text().toInt(NULL, 16);
|
int currID = ui->listFrameID->currentItem()->text().toInt(NULL, 16);
|
||||||
bool foundID = false;
|
bool foundID = false;
|
||||||
for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++)
|
for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++)
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ void FrameSenderWindow::updatedFrames(int numFrames)
|
|||||||
buildFrameCache();
|
buildFrameCache();
|
||||||
}
|
}
|
||||||
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;
|
||||||
qDebug() << "New frames in sender window";
|
qDebug() << "New frames in sender window";
|
||||||
//run through the supposedly new frames in order
|
//run through the supposedly new frames in order
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ void FuzzingWindow::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;
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
{
|
{
|
||||||
id = modelFrames->at(i).ID;
|
id = modelFrames->at(i).ID;
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ void GraphingWindow::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;
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
{
|
{
|
||||||
thisFrame = modelFrames->at(i);
|
thisFrame = modelFrames->at(i);
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ void RangeStateWindow::updatedFrames(int numFrames)
|
|||||||
}
|
}
|
||||||
else //just got some new frames. See if we need to update the filters list. Otherwise nothing to do - no recalc happens until the button is pressed
|
else //just got some new frames. See if we need to update the filters list. Otherwise nothing to do - no recalc happens until the button is pressed
|
||||||
{
|
{
|
||||||
|
if (numFrames > modelFrames->count()) return;
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
{
|
{
|
||||||
thisFrame = modelFrames->at(i);
|
thisFrame = modelFrames->at(i);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ void ScriptingWindow::updatedFrames(int numFrames)
|
|||||||
//-1 means all frames deleted and -2 means a full refresh, neither of which we care about here.
|
//-1 means all frames deleted and -2 means a full refresh, neither of which we care about here.
|
||||||
if (numFrames > 0)
|
if (numFrames > 0)
|
||||||
{
|
{
|
||||||
|
if (numFrames > modelFrames->count()) return;
|
||||||
qDebug() << "Got frames into script window: " << numFrames;
|
qDebug() << "Got frames into script window: " << numFrames;
|
||||||
//for every new frame pass it on to each script container. The container will determine if it needs to actually
|
//for every new frame pass it on to each script container. The container will determine if it needs to actually
|
||||||
//notify the script and do that if applicable.
|
//notify the script and do that if applicable.
|
||||||
|
|||||||
+64
-38
@@ -10,8 +10,12 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
|
|
||||||
modelFrames = frames;
|
modelFrames = frames;
|
||||||
|
|
||||||
|
waitTimer = new QTimer;
|
||||||
|
waitTimer->setInterval(500);
|
||||||
|
|
||||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
||||||
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
|
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
|
||||||
|
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
|
||||||
|
|
||||||
ui->cbBuses->addItem("0");
|
ui->cbBuses->addItem("0");
|
||||||
ui->cbBuses->addItem("1");
|
ui->cbBuses->addItem("1");
|
||||||
@@ -22,48 +26,49 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
UDSScanWindow::~UDSScanWindow()
|
UDSScanWindow::~UDSScanWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
waitTimer->stop();
|
||||||
|
delete waitTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDSScanWindow::scanUDS()
|
void UDSScanWindow::scanUDS()
|
||||||
{
|
{
|
||||||
ui->listResults->clear();
|
ui->listResults->clear();
|
||||||
|
sendingFrames.clear();
|
||||||
|
|
||||||
CANFrame *frame;
|
CANFrame frame;
|
||||||
|
|
||||||
int buses = ui->cbBuses->currentIndex();
|
int buses = ui->cbBuses->currentIndex();
|
||||||
buses++;
|
buses++;
|
||||||
if (buses < 1) buses = 1;
|
if (buses < 1) buses = 1;
|
||||||
for (int id = 0x7E0; id < 0x7E8; id++)
|
for (int typ = 1; typ < 5; typ++)
|
||||||
{
|
{
|
||||||
if (buses & 1)
|
for (int id = 0x7E0; id < 0x7E8; id++)
|
||||||
{
|
{
|
||||||
frame = new CANFrame;
|
frame.ID = id;
|
||||||
frame->ID = id;
|
frame.len = 8;
|
||||||
frame->len = 8;
|
frame.extended = false;
|
||||||
frame->extended = false;
|
frame.data[0] = 2;
|
||||||
frame->data[0] = 2;
|
frame.data[1] = 0x10;
|
||||||
frame->data[1] = 0x10;
|
frame.data[2] = typ;
|
||||||
frame->data[2] = 1;
|
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
|
||||||
frame->data[3] = 0;frame->data[4] = 0;frame->data[5] = 0;
|
frame.data[6] = 0;frame.data[7] = 0;
|
||||||
frame->data[6] = 0;frame->data[7] = 0;
|
|
||||||
frame->bus = 0;
|
if (buses & 1)
|
||||||
emit sendCANFrame(frame, 0);
|
{
|
||||||
}
|
frame.bus = 0;
|
||||||
if (buses & 2)
|
sendingFrames.append(frame);
|
||||||
{
|
}
|
||||||
frame = new CANFrame;
|
if (buses & 2)
|
||||||
frame->ID = id;
|
{
|
||||||
frame->len = 8;
|
frame.bus = 1;
|
||||||
frame->extended = false;
|
sendingFrames.append(frame);
|
||||||
frame->data[0] = 2;
|
}
|
||||||
frame->data[1] = 0x10;
|
|
||||||
frame->data[2] = 1;
|
|
||||||
frame->data[3] = 0;frame->data[4] = 0;frame->data[5] = 0;
|
|
||||||
frame->data[6] = 0;frame->data[7] = 0;
|
|
||||||
frame->bus = 1;
|
|
||||||
emit sendCANFrame(frame, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitTimer->start();
|
||||||
|
currIdx = -1;
|
||||||
|
sendNextMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDSScanWindow::updatedFrames(int numFrames)
|
void UDSScanWindow::updatedFrames(int numFrames)
|
||||||
@@ -79,23 +84,44 @@ 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;
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||||
{
|
{
|
||||||
thisFrame = modelFrames->at(i);
|
thisFrame = modelFrames->at(i);
|
||||||
id = thisFrame.ID;
|
id = thisFrame.ID;
|
||||||
if (id >= 0x7E8 && id <= 0x7EF)
|
if (id >= 0x7E8 && id <= 0x7EF)
|
||||||
{
|
{
|
||||||
if (thisFrame.data[1] == 0x50)
|
id -= 8; //back to original ECU id
|
||||||
{
|
result = "ECU at bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " responds to mode "
|
||||||
result = "ECU at 0x" + QString::number(id, 16) + " bus " + QString::number(thisFrame.bus) + " accepts UDS standard diag";
|
+ QString::number(sendingFrames[currIdx].data[2]) + " with: " + QString::number(thisFrame.data[0], 16) + " "
|
||||||
ui->listResults->addItem(result);
|
+ QString::number(thisFrame.data[1], 16) + " " + QString::number(thisFrame.data[2], 16)
|
||||||
}
|
+ " " + QString::number(thisFrame.data[3], 16);
|
||||||
if (thisFrame.data[i] == 0x7f)
|
ui->listResults->addItem(result);
|
||||||
{
|
sendNextMsg();
|
||||||
result = "ECU at 0x" + QString::number(id, 16) + " bus " + QString::number(thisFrame.bus) + " rejects UDS standard diag";
|
|
||||||
ui->listResults->addItem(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDSScanWindow::timeOut()
|
||||||
|
{
|
||||||
|
QString result;
|
||||||
|
result = "ECU at bus " + QString::number(sendingFrames[currIdx].bus) + " ID: " + QString::number(sendingFrames[currIdx].ID, 16) + " did not respond to mode "
|
||||||
|
+ QString::number(sendingFrames[currIdx].data[2]);
|
||||||
|
ui->listResults->addItem(result);
|
||||||
|
|
||||||
|
sendNextMsg();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDSScanWindow::sendNextMsg()
|
||||||
|
{
|
||||||
|
currIdx++;
|
||||||
|
if (currIdx < sendingFrames.count())
|
||||||
|
{
|
||||||
|
emit sendCANFrame(&sendingFrames[currIdx], sendingFrames[currIdx].bus);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
waitTimer->stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,10 +23,16 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void updatedFrames(int numFrames);
|
void updatedFrames(int numFrames);
|
||||||
void scanUDS();
|
void scanUDS();
|
||||||
|
void timeOut();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::UDSScanWindow *ui;
|
Ui::UDSScanWindow *ui;
|
||||||
const QVector<CANFrame> *modelFrames;
|
const QVector<CANFrame> *modelFrames;
|
||||||
|
QTimer *waitTimer;
|
||||||
|
QList<CANFrame> sendingFrames;
|
||||||
|
int currIdx = 0;
|
||||||
|
|
||||||
|
void sendNextMsg();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UDSSCANWINDOW_H
|
#endif // UDSSCANWINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user