Fixes to allow for rapid frame updating in screens that need it, more
implementation of UDS scanner (and fixes to make it work with current code base)
This commit is contained in:
+4
-3
@@ -49,12 +49,12 @@ CANFrameModel::CANFrameModel(QObject *parent)
|
||||
if (QSysInfo::WordSize > 32)
|
||||
{
|
||||
qDebug() << "64 bit OS detected. Requesting a large preallocation";
|
||||
preallocSize = 20000000;
|
||||
preallocSize = 10000000;
|
||||
}
|
||||
else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down.
|
||||
{
|
||||
qDebug() << "32 bit OS detected. Requesting a much restricted prealloc";
|
||||
preallocSize = 4000000;
|
||||
preallocSize = 2000000;
|
||||
}
|
||||
|
||||
frames.reserve(preallocSize);
|
||||
@@ -423,8 +423,9 @@ void CANFrameModel::sendRefresh()
|
||||
mutex.lock();
|
||||
beginResetModel();
|
||||
filteredFrames.clear();
|
||||
filteredFrames.append(tempContainer);
|
||||
filteredFrames.reserve(preallocSize);
|
||||
filteredFrames.append(tempContainer);
|
||||
|
||||
lastUpdateNumFrames = filteredFrames.count();
|
||||
endResetModel();
|
||||
mutex.unlock();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 166
|
||||
#define VERSION 167
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
|
||||
@@ -17,7 +17,7 @@ CANConManager* CANConManager::getInstance()
|
||||
CANConManager::CANConManager(QObject *parent): QObject(parent)
|
||||
{
|
||||
connect(&mTimer, SIGNAL(timeout()), this, SLOT(refreshCanList()));
|
||||
mTimer.setInterval(125); /*tick 8 times a second */
|
||||
mTimer.setInterval(62); /*tick 16 times a second */
|
||||
mTimer.setSingleShot(false);
|
||||
mTimer.start();
|
||||
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ signals:
|
||||
void suspendCapturing(bool);
|
||||
|
||||
//-1 = frames cleared, -2 = a new file has been loaded (so all frames are different), otherwise # of new frames
|
||||
void framesUpdated(int numFrames); //something has updated the frame list
|
||||
void framesUpdated(int numFrames); //something has updated the frame list (send at gui update frequency)
|
||||
void frameUpdateRapid(int numFrames);
|
||||
void settingsUpdated();
|
||||
void sendCenterTimeID(int32_t ID, double timestamp);
|
||||
|
||||
+47
-41
@@ -17,7 +17,7 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||
waitTimer->setInterval(100);
|
||||
|
||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
||||
connect(MainWindow::getReference(), SIGNAL(frameUpdateRapid(int)), this, SLOT(rapidFrames(int)));
|
||||
connect(CANConManager::getInstance(), &CANConManager::framesReceived, this, &UDSScanWindow::rapidFrames);
|
||||
connect(ui->btnScan, &QPushButton::clicked, this, &UDSScanWindow::scanUDS);
|
||||
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
|
||||
|
||||
@@ -33,6 +33,23 @@ UDSScanWindow::~UDSScanWindow()
|
||||
delete waitTimer;
|
||||
}
|
||||
|
||||
void UDSScanWindow::sendOnBuses(CANFrame &frame, int buses)
|
||||
{
|
||||
if (buses < ui->cbBuses->count()- 1)
|
||||
{
|
||||
frame.bus = buses;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
|
||||
{
|
||||
frame.bus = c;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UDSScanWindow::scanUDS()
|
||||
{
|
||||
if (currentlyRunning)
|
||||
@@ -43,6 +60,8 @@ void UDSScanWindow::scanUDS()
|
||||
ui->btnScan->setText("Start Scan");
|
||||
}
|
||||
|
||||
waitTimer->setInterval(ui->spinDelay->value());
|
||||
|
||||
ui->listResults->clear();
|
||||
sendingFrames.clear();
|
||||
|
||||
@@ -54,61 +73,50 @@ void UDSScanWindow::scanUDS()
|
||||
|
||||
int buses = ui->cbBuses->currentIndex();
|
||||
|
||||
//start out by sending tester present to every address to see if anyone replies
|
||||
for (id = startID; id <= endID; id++)
|
||||
{
|
||||
frame.ID = id;
|
||||
frame.len = 8;
|
||||
frame.extended = false;
|
||||
|
||||
if (ui->ckTester->isChecked())
|
||||
{
|
||||
frame.data[0] = 2;
|
||||
frame.data[1] = 0x3E; //tester present
|
||||
frame.data[2] = 0;
|
||||
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
|
||||
frame.data[6] = 0;frame.data[7] = 0;
|
||||
|
||||
if (buses < ui->cbBuses->count()- 1)
|
||||
{
|
||||
frame.bus = buses;
|
||||
sendingFrames.append(frame);
|
||||
sendOnBuses(frame, buses);
|
||||
}
|
||||
else
|
||||
if (ui->ckSession->isChecked())
|
||||
{
|
||||
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
|
||||
for (typ = 1; typ < 4; typ++) //try each type of session access
|
||||
{
|
||||
frame.bus = c;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//then try asking for the various diagnostic session types
|
||||
for (typ = 1; typ < 5; typ++)
|
||||
{
|
||||
for (id = startID; id <= endID; 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 < ui->cbBuses->count()- 1)
|
||||
{
|
||||
frame.bus = buses;
|
||||
sendingFrames.append(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
|
||||
{
|
||||
frame.bus = c;
|
||||
sendingFrames.append(frame);
|
||||
sendOnBuses(frame, buses);
|
||||
}
|
||||
}
|
||||
if (ui->ckReset->isChecked()) //try to command a reset of the ECU. You're likely to know if it works. ;)
|
||||
{
|
||||
frame.data[0] = 2;
|
||||
frame.data[1] = 0x11; //Reset
|
||||
frame.data[2] = 1; //hard reset. 2 = key off/on 3 = soft reset
|
||||
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
|
||||
frame.data[6] = 0;frame.data[7] = 0;
|
||||
sendOnBuses(frame, buses);
|
||||
}
|
||||
if (ui->ckSecurity->isChecked()) //try to enter security mode - very likely to get a response if an ECU exists.
|
||||
{
|
||||
frame.data[0] = 2;
|
||||
frame.data[1] = 0x27; //request security mode
|
||||
frame.data[2] = 1; //request seed from ECU
|
||||
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
|
||||
frame.data[6] = 0;frame.data[7] = 0;
|
||||
sendOnBuses(frame, buses);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,26 +143,24 @@ void UDSScanWindow::updatedFrames(int numFrames)
|
||||
|
||||
//Updates here are nearly once per millisecond if there is heavy traffic. That's more like it!
|
||||
//TODO: I really doubt this works anymore with the new connection system. This breaks the UDS scanner for now! ;(
|
||||
void UDSScanWindow::rapidFrames(int numFrames)
|
||||
void UDSScanWindow::rapidFrames(const CANConnection* conn, const QVector<CANFrame>& pFrames)
|
||||
{
|
||||
CANFrame thisFrame;
|
||||
QString result;
|
||||
uint32_t id;
|
||||
int offset = ui->spinReplyOffset->value();
|
||||
CANFrame sentFrame;
|
||||
bool gotReply = false;
|
||||
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
if (pFrames.length() <= 0) 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++)
|
||||
foreach(const CANFrame& thisFrame, pFrames)
|
||||
{
|
||||
if (currIdx >= numSending) return;
|
||||
thisFrame = modelFrames->at(i);
|
||||
id = thisFrame.ID;
|
||||
|
||||
if ((id == (uint32_t)(sentFrame.ID + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
|
||||
|
||||
+3
-1
@@ -2,6 +2,7 @@
|
||||
#define UDSSCANWINDOW_H
|
||||
|
||||
#include "can_structs.h"
|
||||
#include "connections/canconnection.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
@@ -19,7 +20,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void updatedFrames(int numFrames);
|
||||
void rapidFrames(int numFrames);
|
||||
void rapidFrames(const CANConnection* conn, const QVector<CANFrame>& pFrames);
|
||||
void scanUDS();
|
||||
void timeOut();
|
||||
|
||||
@@ -32,6 +33,7 @@ private:
|
||||
bool currentlyRunning;
|
||||
|
||||
void sendNextMsg();
|
||||
void sendOnBuses(CANFrame &frame, int buses);
|
||||
};
|
||||
|
||||
#endif // UDSSCANWINDOW_H
|
||||
|
||||
+71
-1
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>742</width>
|
||||
<height>527</height>
|
||||
<height>628</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -64,6 +64,8 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
@@ -91,6 +93,49 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Scan Types:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckTester">
|
||||
<property name="text">
|
||||
<string>Tester Present</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckSession">
|
||||
<property name="text">
|
||||
<string>Session Control</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckReset">
|
||||
<property name="text">
|
||||
<string>ECU Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckSecurity">
|
||||
<property name="text">
|
||||
<string>Security Access</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@@ -101,6 +146,31 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbBuses"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Maximum reply delay</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinDelay">
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnScan">
|
||||
<property name="text">
|
||||
|
||||
Reference in New Issue
Block a user