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)
|
if (QSysInfo::WordSize > 32)
|
||||||
{
|
{
|
||||||
qDebug() << "64 bit OS detected. Requesting a large preallocation";
|
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.
|
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";
|
qDebug() << "32 bit OS detected. Requesting a much restricted prealloc";
|
||||||
preallocSize = 4000000;
|
preallocSize = 2000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
frames.reserve(preallocSize);
|
frames.reserve(preallocSize);
|
||||||
@@ -423,8 +423,9 @@ void CANFrameModel::sendRefresh()
|
|||||||
mutex.lock();
|
mutex.lock();
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
filteredFrames.clear();
|
filteredFrames.clear();
|
||||||
filteredFrames.append(tempContainer);
|
|
||||||
filteredFrames.reserve(preallocSize);
|
filteredFrames.reserve(preallocSize);
|
||||||
|
filteredFrames.append(tempContainer);
|
||||||
|
|
||||||
lastUpdateNumFrames = filteredFrames.count();
|
lastUpdateNumFrames = filteredFrames.count();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CONFIG
|
#ifndef CONFIG
|
||||||
#define CONFIG
|
#define CONFIG
|
||||||
|
|
||||||
#define VERSION 166
|
#define VERSION 167
|
||||||
|
|
||||||
//try to keep this in sync.
|
//try to keep this in sync.
|
||||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
//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)
|
CANConManager::CANConManager(QObject *parent): QObject(parent)
|
||||||
{
|
{
|
||||||
connect(&mTimer, SIGNAL(timeout()), this, SLOT(refreshCanList()));
|
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.setSingleShot(false);
|
||||||
mTimer.start();
|
mTimer.start();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ signals:
|
|||||||
void suspendCapturing(bool);
|
void suspendCapturing(bool);
|
||||||
|
|
||||||
//-1 = frames cleared, -2 = a new file has been loaded (so all frames are different), otherwise # of new frames
|
//-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 frameUpdateRapid(int numFrames);
|
||||||
void settingsUpdated();
|
void settingsUpdated();
|
||||||
void sendCenterTimeID(int32_t ID, double timestamp);
|
void sendCenterTimeID(int32_t ID, double timestamp);
|
||||||
|
|||||||
+55
-49
@@ -17,7 +17,7 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
waitTimer->setInterval(100);
|
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(CANConManager::getInstance(), &CANConManager::framesReceived, this, &UDSScanWindow::rapidFrames);
|
||||||
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);
|
||||||
|
|
||||||
@@ -33,6 +33,23 @@ UDSScanWindow::~UDSScanWindow()
|
|||||||
delete waitTimer;
|
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()
|
void UDSScanWindow::scanUDS()
|
||||||
{
|
{
|
||||||
if (currentlyRunning)
|
if (currentlyRunning)
|
||||||
@@ -43,6 +60,8 @@ void UDSScanWindow::scanUDS()
|
|||||||
ui->btnScan->setText("Start Scan");
|
ui->btnScan->setText("Start Scan");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitTimer->setInterval(ui->spinDelay->value());
|
||||||
|
|
||||||
ui->listResults->clear();
|
ui->listResults->clear();
|
||||||
sendingFrames.clear();
|
sendingFrames.clear();
|
||||||
|
|
||||||
@@ -54,62 +73,51 @@ void UDSScanWindow::scanUDS()
|
|||||||
|
|
||||||
int buses = ui->cbBuses->currentIndex();
|
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++)
|
for (id = startID; id <= endID; id++)
|
||||||
{
|
{
|
||||||
frame.ID = id;
|
frame.ID = id;
|
||||||
frame.len = 8;
|
frame.len = 8;
|
||||||
frame.extended = false;
|
frame.extended = false;
|
||||||
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)
|
if (ui->ckTester->isChecked())
|
||||||
{
|
{
|
||||||
frame.bus = buses;
|
|
||||||
sendingFrames.append(frame);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
|
|
||||||
{
|
|
||||||
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[0] = 2;
|
||||||
frame.data[1] = 0x10;
|
frame.data[1] = 0x3E; //tester present
|
||||||
frame.data[2] = typ;
|
frame.data[2] = 0;
|
||||||
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;
|
||||||
|
sendOnBuses(frame, buses);
|
||||||
if (buses < ui->cbBuses->count()- 1)
|
}
|
||||||
|
if (ui->ckSession->isChecked())
|
||||||
|
{
|
||||||
|
for (typ = 1; typ < 4; typ++) //try each type of session access
|
||||||
{
|
{
|
||||||
frame.bus = buses;
|
frame.data[0] = 2;
|
||||||
sendingFrames.append(frame);
|
frame.data[1] = 0x10;
|
||||||
}
|
frame.data[2] = typ;
|
||||||
else
|
frame.data[3] = 0;frame.data[4] = 0;frame.data[5] = 0;
|
||||||
{
|
frame.data[6] = 0;frame.data[7] = 0;
|
||||||
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
|
sendOnBuses(frame, buses);
|
||||||
{
|
|
||||||
frame.bus = c;
|
|
||||||
sendingFrames.append(frame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waitTimer->start();
|
waitTimer->start();
|
||||||
@@ -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!
|
//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! ;(
|
//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;
|
QString result;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
int offset = ui->spinReplyOffset->value();
|
int offset = ui->spinReplyOffset->value();
|
||||||
CANFrame sentFrame;
|
CANFrame sentFrame;
|
||||||
bool gotReply = false;
|
bool gotReply = false;
|
||||||
|
|
||||||
if (numFrames > modelFrames->count()) return;
|
if (pFrames.length() <= 0) return;
|
||||||
|
|
||||||
int numSending = sendingFrames.length();
|
int numSending = sendingFrames.length();
|
||||||
if (numSending == 0) return;
|
if (numSending == 0) return;
|
||||||
if (currIdx >= numSending) return;
|
if (currIdx >= numSending) return;
|
||||||
sentFrame = sendingFrames[currIdx];
|
sentFrame = sendingFrames[currIdx];
|
||||||
|
|
||||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
foreach(const CANFrame& thisFrame, pFrames)
|
||||||
{
|
{
|
||||||
if (currIdx >= numSending) return;
|
if (currIdx >= numSending) return;
|
||||||
thisFrame = modelFrames->at(i);
|
|
||||||
id = thisFrame.ID;
|
id = thisFrame.ID;
|
||||||
|
|
||||||
if ((id == (uint32_t)(sentFrame.ID + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
|
if ((id == (uint32_t)(sentFrame.ID + offset)) || ui->cbAllowAdaptiveOffset->isChecked())
|
||||||
|
|||||||
+3
-1
@@ -2,6 +2,7 @@
|
|||||||
#define UDSSCANWINDOW_H
|
#define UDSSCANWINDOW_H
|
||||||
|
|
||||||
#include "can_structs.h"
|
#include "can_structs.h"
|
||||||
|
#include "connections/canconnection.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatedFrames(int numFrames);
|
void updatedFrames(int numFrames);
|
||||||
void rapidFrames(int numFrames);
|
void rapidFrames(const CANConnection* conn, const QVector<CANFrame>& pFrames);
|
||||||
void scanUDS();
|
void scanUDS();
|
||||||
void timeOut();
|
void timeOut();
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ private:
|
|||||||
bool currentlyRunning;
|
bool currentlyRunning;
|
||||||
|
|
||||||
void sendNextMsg();
|
void sendNextMsg();
|
||||||
|
void sendOnBuses(CANFrame &frame, int buses);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UDSSCANWINDOW_H
|
#endif // UDSSCANWINDOW_H
|
||||||
|
|||||||
+102
-32
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>742</width>
|
<width>742</width>
|
||||||
<height>527</height>
|
<height>628</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -65,41 +65,111 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Reply Offset:</string>
|
<widget class="QLabel" name="label_5">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Reply Offset:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinReplyOffset">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>-128</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbAllowAdaptiveOffset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Allow adaptive reply offset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="spinReplyOffset">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="minimum">
|
<item>
|
||||||
<number>-128</number>
|
<widget class="QLabel" name="label_6">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="maximum">
|
<string>Scan Types:</string>
|
||||||
<number>128</number>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="value">
|
</item>
|
||||||
<number>8</number>
|
<item>
|
||||||
</property>
|
<widget class="QCheckBox" name="ckTester">
|
||||||
</widget>
|
<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>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="cbAllowAdaptiveOffset">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Allow adaptive reply offset</string>
|
<widget class="QLabel" name="label">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Buses to scan</string>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QLabel" name="label">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Buses to scan</string>
|
<widget class="QComboBox" name="cbBuses"/>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
<widget class="QLabel" name="label_7">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QComboBox" name="cbBuses"/>
|
<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>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnScan">
|
<widget class="QPushButton" name="btnScan">
|
||||||
|
|||||||
Reference in New Issue
Block a user