Upped version number, implemented an incomplete but working version of
the fuzzing window.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 149
|
||||
#define VERSION 150
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
|
||||
+188
-2
@@ -1,17 +1,203 @@
|
||||
#include "fuzzingwindow.h"
|
||||
#include "ui_fuzzingwindow.h"
|
||||
#include "utility.h"
|
||||
#include <QDebug>
|
||||
|
||||
FuzzingWindow::FuzzingWindow(const QVector<CANFrame> *frames, SerialWorker *worker, QWidget *parent) :
|
||||
FuzzingWindow::FuzzingWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::FuzzingWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
modelFrames = frames;
|
||||
serialWorker = worker;
|
||||
|
||||
fuzzTimer = new QTimer();
|
||||
|
||||
connect(ui->btnStartStop, &QPushButton::clicked, this, &FuzzingWindow::toggleFuzzing);
|
||||
connect(ui->btnAllFilters, &QPushButton::clicked, this, &FuzzingWindow::setAllFilters);
|
||||
connect(ui->btnNoFilters, &QPushButton::clicked, this, &FuzzingWindow::clearAllFilters);
|
||||
connect(fuzzTimer, &QTimer::timeout, this, &FuzzingWindow::timerTriggered);
|
||||
connect(ui->spinTiming, SIGNAL(valueChanged(int)), this, SLOT(changePlaybackSpeed(int)));
|
||||
connect(ui->listID, &QListWidget::itemChanged, this, &FuzzingWindow::idListChanged);
|
||||
|
||||
refreshIDList();
|
||||
|
||||
currentlyFuzzing = false;
|
||||
}
|
||||
|
||||
FuzzingWindow::~FuzzingWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FuzzingWindow::changePlaybackSpeed(int newSpeed)
|
||||
{
|
||||
fuzzTimer->setInterval(newSpeed);
|
||||
}
|
||||
|
||||
void FuzzingWindow::timerTriggered()
|
||||
{
|
||||
CANFrame thisFrame;
|
||||
sendingBuffer.clear();
|
||||
for (int count = 0; count < ui->spinBurst->value(); count++)
|
||||
{
|
||||
thisFrame.ID = currentID;
|
||||
for (int i = 0; i < 8; i++) thisFrame.data[i] = currentBytes[i];
|
||||
if (currentID > 0x7FF) thisFrame.extended = true;
|
||||
else thisFrame.extended = false;
|
||||
thisFrame.bus = 0; //hard coded for now. TODO: do not hard code
|
||||
thisFrame.len = 8;
|
||||
sendingBuffer.append(thisFrame);
|
||||
calcNextID();
|
||||
calcNextBitPattern();
|
||||
numSentFrames++;
|
||||
}
|
||||
emit sendFrameBatch(&sendingBuffer);
|
||||
ui->lblNumFrames->setText("# of sent frames: " + QString::number(numSentFrames));
|
||||
}
|
||||
|
||||
void FuzzingWindow::clearAllFilters()
|
||||
{
|
||||
for (int i = 0; i < ui->listID->count(); i++)
|
||||
{
|
||||
ui->listID->item(i)->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
void FuzzingWindow::setAllFilters()
|
||||
{
|
||||
for (int i = 0; i < ui->listID->count(); i++)
|
||||
{
|
||||
ui->listID->item(i)->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
void FuzzingWindow::calcNextID()
|
||||
{
|
||||
if (seqIDScan)
|
||||
{
|
||||
currentID++;
|
||||
if (rangeIDSelect)
|
||||
{
|
||||
if (currentID > endID) currentID = startID;
|
||||
}
|
||||
else //IDs by filter. So, select the first filter
|
||||
{
|
||||
if (currentID > selectedIDs.length()) currentID = 0;
|
||||
}
|
||||
}
|
||||
else //random IDs
|
||||
{
|
||||
if (rangeIDSelect)
|
||||
{
|
||||
int range = endID - startID;
|
||||
currentID = startID + qrand() % range;
|
||||
}
|
||||
else //IDs by filter so pick a random selected ID from the filter list
|
||||
{
|
||||
currentID = qrand() % selectedIDs.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FuzzingWindow::calcNextBitPattern()
|
||||
{
|
||||
//simple, quick random data for now
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
currentBytes[i] = qrand() % 256;
|
||||
}
|
||||
}
|
||||
|
||||
void FuzzingWindow::toggleFuzzing()
|
||||
{
|
||||
if (currentlyFuzzing) //stop it then
|
||||
{
|
||||
ui->btnStartStop->setText("Start Fuzzing");
|
||||
currentlyFuzzing = false;
|
||||
fuzzTimer->stop();
|
||||
}
|
||||
else //start it then
|
||||
{
|
||||
ui->btnStartStop->setText("Stop Fuzzing");
|
||||
currentlyFuzzing = true;
|
||||
|
||||
startID = Utility::ParseStringToNum(ui->txtStartID->text());
|
||||
endID = Utility::ParseStringToNum(ui->txtEndID->text());
|
||||
|
||||
seqIDScan = ui->rbSequentialID->isChecked();
|
||||
rangeIDSelect = ui->rbRangeIDSel->isChecked();
|
||||
seqBitSelect = ui->rbSequentialBits->isChecked();
|
||||
|
||||
numSentFrames = 0;
|
||||
|
||||
if (seqIDScan)
|
||||
{
|
||||
if (rangeIDSelect)
|
||||
{
|
||||
currentID = startID;
|
||||
}
|
||||
else //IDs by filter. So, select the first filter
|
||||
{
|
||||
currentID = 0;
|
||||
}
|
||||
}
|
||||
else //random IDs
|
||||
{
|
||||
if (rangeIDSelect)
|
||||
{
|
||||
int range = endID - startID;
|
||||
currentID = startID + qrand() % range;
|
||||
}
|
||||
else //IDs by filter so pick a random selected ID from the filter list
|
||||
{
|
||||
currentID = qrand() % selectedIDs.length();
|
||||
}
|
||||
}
|
||||
|
||||
calcNextBitPattern();
|
||||
|
||||
fuzzTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void FuzzingWindow::refreshIDList()
|
||||
{
|
||||
ui->listID->clear();
|
||||
|
||||
int id;
|
||||
for (int i = 0; i < modelFrames->count(); i++)
|
||||
{
|
||||
id = modelFrames->at(i).ID;
|
||||
if (!foundIDs.contains(id))
|
||||
{
|
||||
foundIDs.append(id);
|
||||
selectedIDs.append(id);
|
||||
QListWidgetItem *thisItem = new QListWidgetItem();
|
||||
thisItem->setText(Utility::formatNumber(id));
|
||||
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
||||
thisItem->setCheckState(Qt::Checked);
|
||||
ui->listID->addItem(thisItem);
|
||||
}
|
||||
}
|
||||
//default is to sort in ascending order
|
||||
ui->listID->sortItems();
|
||||
}
|
||||
|
||||
void FuzzingWindow::idListChanged(QListWidgetItem *item)
|
||||
{
|
||||
int id = Utility::ParseStringToNum(item->text());
|
||||
if (item->checkState() == Qt::Checked)
|
||||
{
|
||||
if (!selectedIDs.contains(id))
|
||||
{
|
||||
qDebug() << "adding " << id << " to list of selected IDs";
|
||||
selectedIDs.append(id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "removing " << id << " from the list of selected ids";
|
||||
selectedIDs.removeOne(id);
|
||||
}
|
||||
}
|
||||
|
||||
+28
-3
@@ -2,8 +2,9 @@
|
||||
#define FUZZINGWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QListWidget>
|
||||
#include <QTimer>
|
||||
#include "can_structs.h"
|
||||
#include "serialworker.h"
|
||||
|
||||
namespace Ui {
|
||||
class FuzzingWindow;
|
||||
@@ -14,14 +15,38 @@ class FuzzingWindow : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FuzzingWindow(const QVector<CANFrame> *frames, SerialWorker *worker, QWidget *parent = 0);
|
||||
explicit FuzzingWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
|
||||
~FuzzingWindow();
|
||||
|
||||
signals:
|
||||
void sendCANFrame(const CANFrame *, int);
|
||||
void sendFrameBatch(const QList<CANFrame> *);
|
||||
|
||||
private slots:
|
||||
void changePlaybackSpeed(int newSpeed);
|
||||
void timerTriggered();
|
||||
void clearAllFilters();
|
||||
void setAllFilters();
|
||||
void toggleFuzzing();
|
||||
void idListChanged(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
Ui::FuzzingWindow *ui;
|
||||
const QVector<CANFrame> *modelFrames;
|
||||
QTimer *fuzzTimer;
|
||||
SerialWorker *serialWorker;
|
||||
QList<int> foundIDs;
|
||||
QList<int> selectedIDs;
|
||||
QList<CANFrame> sendingBuffer;
|
||||
int startID, endID, currentID;
|
||||
bool seqIDScan, rangeIDSelect, seqBitSelect;
|
||||
bool currentlyFuzzing;
|
||||
uint8_t currentBytes[8];
|
||||
uint8_t bitGrid[64];
|
||||
int numSentFrames;
|
||||
|
||||
void refreshIDList();
|
||||
void calcNextID();
|
||||
void calcNextBitPattern();
|
||||
};
|
||||
|
||||
#endif // FUZZINGWINDOW_H
|
||||
|
||||
+65
-15
@@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Fuzzing Window</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,3,6">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,3,6,0,0">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
@@ -21,12 +21,19 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Interframe Timing</string>
|
||||
<string>Interframe Timing (ms)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox"/>
|
||||
<widget class="QSpinBox" name="spinTiming">
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -40,7 +47,17 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_2"/>
|
||||
<widget class="QSpinBox" name="spinBurst">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -53,19 +70,25 @@
|
||||
<property name="title">
|
||||
<string>ID Scanning</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<widget class="QRadioButton" name="rbSequentialID">
|
||||
<property name="text">
|
||||
<string>Seqential</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<widget class="QRadioButton" name="rbRandomID">
|
||||
<property name="text">
|
||||
<string>Random</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -78,14 +101,17 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_3">
|
||||
<widget class="QRadioButton" name="rbRangeIDSel">
|
||||
<property name="text">
|
||||
<string>Range of IDs</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_4">
|
||||
<widget class="QRadioButton" name="rbFilterIDSel">
|
||||
<property name="text">
|
||||
<string>Filter List</string>
|
||||
</property>
|
||||
@@ -101,17 +127,20 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_5">
|
||||
<widget class="QRadioButton" name="rbSequentialBits">
|
||||
<property name="text">
|
||||
<string>Sequential</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_6">
|
||||
<widget class="QRadioButton" name="rbRandomBits">
|
||||
<property name="text">
|
||||
<string>Random</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -137,7 +166,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
<widget class="QLineEdit" name="txtStartID"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -151,7 +180,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
<widget class="QLineEdit" name="txtEndID"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -161,19 +190,19 @@
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
<widget class="QListWidget" name="listID"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="btnAllFilters">
|
||||
<property name="text">
|
||||
<string>All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="btnNoFilters">
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
@@ -195,6 +224,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnStartStop">
|
||||
<property name="text">
|
||||
<string>Start Fuzzing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblNumFrames">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string># of sent frames:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
+3
-1
@@ -923,7 +923,9 @@ void MainWindow::showFuzzingWindow()
|
||||
{
|
||||
if (!fuzzingWindow)
|
||||
{
|
||||
fuzzingWindow = new FuzzingWindow(model->getListReference(), worker);
|
||||
fuzzingWindow = new FuzzingWindow(model->getListReference());
|
||||
connect(fuzzingWindow, SIGNAL(sendCANFrame(const CANFrame*,int)), worker, SLOT(sendFrame(const CANFrame*,int)));
|
||||
connect(fuzzingWindow, SIGNAL(sendFrameBatch(const QList<CANFrame>*)), worker, SLOT(sendFrameBatch(const QList<CANFrame>*)));
|
||||
}
|
||||
fuzzingWindow->show();
|
||||
}
|
||||
|
||||
+3
-1
@@ -193,8 +193,10 @@ void SerialWorker::sendFrame(const CANFrame *frame, int bus = 0)
|
||||
//Don't get carried away here. The GVRET firmware only has finite
|
||||
//buffers and besides, the other end will get buried in traffic.
|
||||
void SerialWorker::sendFrameBatch(const QList<CANFrame> *frames)
|
||||
{
|
||||
{
|
||||
sendBulkMutex.lock();
|
||||
for (int i = 0; i < frames->length(); i++) sendFrame(&frames->at(i), frames->at(i).bus);
|
||||
sendBulkMutex.unlock();
|
||||
}
|
||||
|
||||
void SerialWorker::updateBaudRates(int Speed1, int Speed2)
|
||||
|
||||
@@ -76,6 +76,7 @@ private:
|
||||
CANFrameModel *canModel;
|
||||
QTimer *ticker;
|
||||
QTime *elapsedTime;
|
||||
QMutex sendBulkMutex;
|
||||
int framesPerSec;
|
||||
int gotFrames;
|
||||
int targetID;
|
||||
|
||||
Reference in New Issue
Block a user