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.
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); 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.
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
int refID = frameCache[0].ID;
|
||||
bool needRefresh = false;
|
||||
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.
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
int currID = ui->listFrameID->currentItem()->text().toInt(NULL, 16);
|
||||
bool foundID = false;
|
||||
for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++)
|
||||
|
||||
@@ -110,6 +110,7 @@ void FrameSenderWindow::updatedFrames(int numFrames)
|
||||
}
|
||||
else //just got some new frames. See if they are relevant.
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
qDebug() << "New frames in sender window";
|
||||
//run through the supposedly new frames in order
|
||||
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.
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||
{
|
||||
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.
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); 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
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); 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.
|
||||
if (numFrames > 0)
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
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
|
||||
//notify the script and do that if applicable.
|
||||
|
||||
+55
-29
@@ -10,8 +10,12 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||
|
||||
modelFrames = frames;
|
||||
|
||||
waitTimer = new QTimer;
|
||||
waitTimer->setInterval(500);
|
||||
|
||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
||||
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
|
||||
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
|
||||
|
||||
ui->cbBuses->addItem("0");
|
||||
ui->cbBuses->addItem("1");
|
||||
@@ -22,50 +26,51 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||
UDSScanWindow::~UDSScanWindow()
|
||||
{
|
||||
delete ui;
|
||||
waitTimer->stop();
|
||||
delete waitTimer;
|
||||
}
|
||||
|
||||
void UDSScanWindow::scanUDS()
|
||||
{
|
||||
ui->listResults->clear();
|
||||
sendingFrames.clear();
|
||||
|
||||
CANFrame *frame;
|
||||
CANFrame frame;
|
||||
|
||||
int buses = ui->cbBuses->currentIndex();
|
||||
buses++;
|
||||
if (buses < 1) buses = 1;
|
||||
for (int typ = 1; typ < 5; typ++)
|
||||
{
|
||||
for (int id = 0x7E0; id < 0x7E8; id++)
|
||||
{
|
||||
frame.ID = id;
|
||||
frame.len = 8;
|
||||
frame.extended = false;
|
||||
frame.data[0] = 2;
|
||||
frame.data[1] = 0x10;
|
||||
frame.data[2] = typ;
|
||||
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
|
||||
frame.data[6] = 0;frame.data[7] = 0;
|
||||
|
||||
if (buses & 1)
|
||||
{
|
||||
frame = new CANFrame;
|
||||
frame->ID = id;
|
||||
frame->len = 8;
|
||||
frame->extended = false;
|
||||
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 = 0;
|
||||
emit sendCANFrame(frame, 0);
|
||||
frame.bus = 0;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
if (buses & 2)
|
||||
{
|
||||
frame = new CANFrame;
|
||||
frame->ID = id;
|
||||
frame->len = 8;
|
||||
frame->extended = false;
|
||||
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);
|
||||
frame.bus = 1;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waitTimer->start();
|
||||
currIdx = -1;
|
||||
sendNextMsg();
|
||||
}
|
||||
|
||||
void UDSScanWindow::updatedFrames(int numFrames)
|
||||
{
|
||||
CANFrame thisFrame;
|
||||
@@ -79,23 +84,44 @@ void UDSScanWindow::updatedFrames(int numFrames)
|
||||
}
|
||||
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++)
|
||||
{
|
||||
thisFrame = modelFrames->at(i);
|
||||
id = thisFrame.ID;
|
||||
if (id >= 0x7E8 && id <= 0x7EF)
|
||||
{
|
||||
if (thisFrame.data[1] == 0x50)
|
||||
{
|
||||
result = "ECU at 0x" + QString::number(id, 16) + " bus " + QString::number(thisFrame.bus) + " accepts UDS standard diag";
|
||||
id -= 8; //back to original ECU id
|
||||
result = "ECU at bus " + QString::number(thisFrame.bus) + " ID: " + QString::number(id, 16) + " responds to mode "
|
||||
+ QString::number(sendingFrames[currIdx].data[2]) + " with: " + QString::number(thisFrame.data[0], 16) + " "
|
||||
+ QString::number(thisFrame.data[1], 16) + " " + QString::number(thisFrame.data[2], 16)
|
||||
+ " " + QString::number(thisFrame.data[3], 16);
|
||||
ui->listResults->addItem(result);
|
||||
sendNextMsg();
|
||||
}
|
||||
if (thisFrame.data[i] == 0x7f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UDSScanWindow::timeOut()
|
||||
{
|
||||
result = "ECU at 0x" + QString::number(id, 16) + " bus " + QString::number(thisFrame.bus) + " rejects UDS standard diag";
|
||||
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:
|
||||
void updatedFrames(int numFrames);
|
||||
void scanUDS();
|
||||
void timeOut();
|
||||
|
||||
private:
|
||||
Ui::UDSScanWindow *ui;
|
||||
const QVector<CANFrame> *modelFrames;
|
||||
QTimer *waitTimer;
|
||||
QList<CANFrame> sendingFrames;
|
||||
int currIdx = 0;
|
||||
|
||||
void sendNextMsg();
|
||||
};
|
||||
|
||||
#endif // UDSSCANWINDOW_H
|
||||
|
||||
Reference in New Issue
Block a user