Add text boxes to Fuzzing window to make it easy to set the bytes

directly and to show feedback while fuzzing is running.
This commit is contained in:
Collin Kidder
2020-02-15 21:25:32 -05:00
parent e4a3854af4
commit 909710fcfa
9 changed files with 207 additions and 13 deletions
+45
View File
@@ -26,6 +26,15 @@ FuzzingWindow::FuzzingWindow(const QVector<CANFrame> *frames, QWidget *parent) :
connect(ui->listID, &QListWidget::itemChanged, this, &FuzzingWindow::idListChanged);
connect(ui->spinBytes, SIGNAL(valueChanged(int)), this, SLOT(changedNumDataBytes(int)));
connect(ui->bitfield, SIGNAL(gridClicked(int,int)), this, SLOT(bitfieldClicked(int,int)));
connect(ui->txtByte0, &QLineEdit::returnPressed, this, [=](){changedDataByteText(0, ui->txtByte0->text());});
connect(ui->txtByte1, &QLineEdit::returnPressed, this, [=](){changedDataByteText(1, ui->txtByte1->text());});
connect(ui->txtByte2, &QLineEdit::returnPressed, this, [=](){changedDataByteText(2, ui->txtByte2->text());});
connect(ui->txtByte3, &QLineEdit::returnPressed, this, [=](){changedDataByteText(3, ui->txtByte3->text());});
connect(ui->txtByte4, &QLineEdit::returnPressed, this, [=](){changedDataByteText(4, ui->txtByte4->text());});
connect(ui->txtByte5, &QLineEdit::returnPressed, this, [=](){changedDataByteText(5, ui->txtByte5->text());});
connect(ui->txtByte6, &QLineEdit::returnPressed, this, [=](){changedDataByteText(6, ui->txtByte6->text());});
connect(ui->txtByte7, &QLineEdit::returnPressed, this, [=](){changedDataByteText(7, ui->txtByte7->text());});
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
@@ -110,9 +119,32 @@ void FuzzingWindow::changePlaybackSpeed(int newSpeed)
fuzzTimer->setInterval(newSpeed);
}
void FuzzingWindow::changedDataByteText(int which, QString valu)
{
int startBit = which * 8;
int byt = valu.toInt(nullptr, 16);
for (int i = 0; i < 8; i++)
{
bitGrid[startBit + i] = (byt & (1 << i)) ? 2 : 0;
}
redrawGrid();
}
void FuzzingWindow::changedNumDataBytes(int newVal)
{
qDebug() << "new num bytes: " << newVal;
ui->txtByte0->setEnabled((newVal > 0) ? true : false);
ui->txtByte1->setEnabled((newVal > 1) ? true : false);
ui->txtByte2->setEnabled((newVal > 2) ? true : false);
ui->txtByte3->setEnabled((newVal > 3) ? true : false);
ui->txtByte4->setEnabled((newVal > 4) ? true : false);
ui->txtByte5->setEnabled((newVal > 5) ? true : false);
ui->txtByte6->setEnabled((newVal > 6) ? true : false);
ui->txtByte7->setEnabled((newVal > 7) ? true : false);
int byt;
for (int i = 0; i < 64; i++)
{
@@ -132,8 +164,21 @@ void FuzzingWindow::changedNumDataBytes(int newVal)
void FuzzingWindow::timerTriggered()
{
static uint64_t lastByteUpdate = 0;
CANFrame thisFrame;
sendingBuffer.clear();
//Every 250ms update the text fields to show our progress and what's going on.
if (QDateTime::currentMSecsSinceEpoch() - lastByteUpdate > 250)
{
ui->txtByte0->setText(QString::number(currentBytes[0], 16));
ui->txtByte1->setText(QString::number(currentBytes[1], 16));
ui->txtByte2->setText(QString::number(currentBytes[2], 16));
ui->txtByte3->setText(QString::number(currentBytes[3], 16));
ui->txtByte4->setText(QString::number(currentBytes[4], 16));
ui->txtByte5->setText(QString::number(currentBytes[5], 16));
ui->txtByte6->setText(QString::number(currentBytes[6], 16));
ui->txtByte7->setText(QString::number(currentBytes[7], 16));
}
int buses = ui->cbBuses->currentIndex();
for (int count = 0; count < ui->spinBurst->value(); count++)
{