Preliminaries for new UDS modes, added code to ensure lower and upper

bounds are respected on UDS window.
This commit is contained in:
Collin Kidder
2017-05-21 17:28:20 -04:00
parent 341df5df2d
commit 72589c7760
3 changed files with 98 additions and 16 deletions
+50 -8
View File
@@ -26,12 +26,19 @@ UDSScanWindow::UDSScanWindow(const QVector<CANFrame> *frames, QWidget *parent) :
connect(waitTimer, &QTimer::timeout, this, &UDSScanWindow::timeOut);
connect(ui->btnSaveResults, &QPushButton::clicked, this, &UDSScanWindow::saveResults);
connect(ui->ckWildcard, &QCheckBox::toggled, this, &UDSScanWindow::wildcardToggled);
connect(ui->ckReadByAddr, &QCheckBox::toggled, this, &UDSScanWindow::readByToggled);
connect(ui->ckReadByID, &QCheckBox::toggled, this, &UDSScanWindow::readByToggled);
connect(ui->cbAllowAdaptiveOffset, &QCheckBox::toggled, this, &UDSScanWindow::adaptiveToggled);
connect(ui->spinNumBytes, SIGNAL(valueChanged(int)), this, SLOT(numBytesChanged()));
connect(ui->spinLowerService, SIGNAL(valueChanged(int)), this, SLOT(checkServiceRange()));
connect(ui->spinUpperService, SIGNAL(valueChanged(int)), this, SLOT(checkServiceRange()));
connect(ui->spinLowerSubfunc, SIGNAL(valueChanged(int)), this, SLOT(checkSubFuncRange()));
connect(ui->spinUpperSubfunc, SIGNAL(valueChanged(int)), this, SLOT(checkSubFuncRange()));
connect(ui->spinStartID, SIGNAL(valueChanged(int)), this, SLOT(checkIDRange()));
connect(ui->spinEndID, SIGNAL(valueChanged(int)), this, SLOT(checkIDRange()));
int numBuses = CANConManager::getInstance()->getNumBuses();
for (int n = 0; n < numBuses; n++) ui->cbBuses->addItem(QString::number(n));
ui->cbBuses->addItem(tr("All"));
}
UDSScanWindow::~UDSScanWindow()
@@ -57,10 +64,14 @@ void UDSScanWindow::wildcardToggled()
ui->ckSecurity->setEnabled(state);
ui->ckSession->setEnabled(state);
ui->ckTester->setEnabled(state);
ui->ckReadByAddr->setEnabled(state);
ui->ckReadByID->setEnabled(state);
ui->ckReset->setChecked(false);
ui->ckSecurity->setChecked(false);
ui->ckSession->setChecked(false);
ui->ckTester->setChecked(false);
ui->ckReadByAddr->setChecked(false);
ui->ckReadByID->setChecked(false);
ui->spinLowerService->setEnabled(!state);
ui->spinLowerSubfunc->setEnabled(!state);
@@ -69,12 +80,43 @@ void UDSScanWindow::wildcardToggled()
ui->spinUpperSubfunc->setEnabled(!state);
}
void UDSScanWindow::readByToggled()
{
bool state = false;
if (ui->ckReadByAddr->isChecked() || ui->ckReadByID->isChecked()) state = true;
else state = false;
ui->spinLowerService->setEnabled(false);
ui->spinLowerSubfunc->setEnabled(state);
ui->spinNumBytes->setEnabled(state);
ui->spinUpperService->setEnabled(false);
ui->spinUpperSubfunc->setEnabled(state);
}
void UDSScanWindow::numBytesChanged()
{
uint64_t upperBound = (1 << (8 * ui->spinNumBytes->value())) - 1;
ui->spinUpperSubfunc->setMaximum(upperBound);
}
void UDSScanWindow::checkIDRange()
{
ui->spinStartID->setMaximum(ui->spinEndID->value());
ui->spinEndID->setMinimum(ui->spinStartID->value());
}
void UDSScanWindow::checkServiceRange()
{
ui->spinLowerService->setMaximum(ui->spinUpperService->value());
ui->spinUpperService->setMinimum(ui->spinLowerService->value());
}
void UDSScanWindow::checkSubFuncRange()
{
ui->spinLowerSubfunc->setMaximum(ui->spinUpperSubfunc->value());
ui->spinUpperSubfunc->setMinimum(ui->spinLowerSubfunc->value());
}
void UDSScanWindow::saveResults()
{
QString filename;
@@ -123,19 +165,19 @@ void UDSScanWindow::dumpNode(QTreeWidgetItem* item, QFile *file, int indent)
void UDSScanWindow::sendOnBuses(UDS_MESSAGE test, int buses)
{
int busList = buses;
if (busList < ui->cbBuses->count() - 1)
{
//if (busList < ui->cbBuses->count() - 1)
//{
test.bus = buses;
sendingFrames.append(test);
}
else
//}
/*else
{
for (int c = 0; c < ui->cbBuses->count() - 1; c++)
{
test.bus = c;
sendingFrames.append(test);
}
}
}*/
}
void UDSScanWindow::scanUDS()
@@ -160,8 +202,8 @@ void UDSScanWindow::scanUDS()
UDS_MESSAGE test;
int typ, id;
int startID, endID;
startID = Utility::ParseStringToNum(ui->txtStartID->text());
endID = Utility::ParseStringToNum(ui->txtEndID->text());
startID = ui->spinStartID->value();
endID = ui->spinEndID->value();
if (endID < startID) {
int temp = startID;
startID = endID;
+4
View File
@@ -29,7 +29,11 @@ private slots:
void timeOut();
void adaptiveToggled();
void wildcardToggled();
void readByToggled();
void numBytesChanged();
void checkIDRange();
void checkServiceRange();
void checkSubFuncRange();
private:
Ui::UDSScanWindow *ui;
+44 -8
View File
@@ -52,9 +52,18 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtStartID">
<property name="text">
<string>0x7E0</string>
<widget class="QSpinBox" name="spinStartID">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>536870911</number>
</property>
<property name="value">
<number>2016</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
@@ -70,9 +79,18 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtEndID">
<property name="text">
<string>0x7E7</string>
<widget class="QSpinBox" name="spinEndID">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>536870911</number>
</property>
<property name="value">
<number>2024</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
@@ -123,7 +141,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Buses to scan</string>
<string>Bus to scan</string>
</property>
</widget>
</item>
@@ -174,7 +192,7 @@
<item>
<widget class="QCheckBox" name="ckSession">
<property name="text">
<string>Session Control</string>
<string>Session Ctrl</string>
</property>
</widget>
</item>
@@ -192,6 +210,24 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="ckReadByID">
<property name="text">
<string>Read By ID</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ckReadByAddr">
<property name="text">
<string>Read By Addr</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ckWildcard">
<property name="text">