Skip to content

Commit 7962d14

Browse files
committed
Show read buffer on UI without skipped bad blocks
1 parent 4e2d653 commit 7962d14

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

qt/main_window.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void MainWindow::slotProgConnectCompleted(int status)
219219
disconnect(prog, SIGNAL(connectCompleted(int)), this,
220220
SLOT(slotProgConnectCompleted(int)));
221221

222-
if (status)
222+
if (status < 0)
223223
return;
224224

225225
qInfo() << "Connected to programmer";
@@ -253,7 +253,7 @@ void MainWindow::slotProgReadDeviceIdCompleted(int status)
253253
disconnect(prog, SIGNAL(readChipIdCompleted(int)), this,
254254
SLOT(slotProgReadDeviceIdCompleted(int)));
255255

256-
if (status)
256+
if (status < 0)
257257
return;
258258

259259
idStr = tr("0x%1 0x%2 0x%3 0x%4 0x%5")
@@ -325,7 +325,7 @@ void MainWindow::slotProgErase()
325325
prog->eraseChip(START_ADDRESS, eraseSize);
326326
}
327327

328-
void MainWindow::slotProgReadCompleted(int status)
328+
void MainWindow::slotProgReadCompleted(int readBytes)
329329
{
330330
disconnect(prog, SIGNAL(readChipProgress(unsigned int)), this,
331331
SLOT(slotProgReadProgress(unsigned int)));
@@ -334,15 +334,21 @@ void MainWindow::slotProgReadCompleted(int status)
334334

335335
setProgress(100);
336336

337-
if (status)
337+
if (readBytes < 0)
338338
{
339339
buffer.clear();
340340
return;
341341
}
342342

343+
if (readBytes > buffer.size())
344+
{
345+
qCritical() << "Read operation returned more than requested: " <<
346+
readBytes << ">" << buffer.size();
347+
return;
348+
}
349+
343350
qInfo() << "Data has been successfully read";
344-
bufferTableModel.setBuffer(buffer.data(),
345-
static_cast<uint32_t>(buffer.size()));
351+
bufferTableModel.setBuffer(buffer.data(), readBytes);
346352
}
347353

348354
void MainWindow::slotProgReadProgress(unsigned int progress)
@@ -555,7 +561,7 @@ void MainWindow::slotProgDetectChipReadChipIdCompleted(int status)
555561
disconnect(prog, SIGNAL(readChipIdCompleted(int)), this,
556562
SLOT(slotProgDetectChipReadChipIdCompleted(int)));
557563

558-
if (status)
564+
if (status < 0)
559565
return;
560566

561567
idStr = tr("0x%1 0x%2 0x%3 0x%4 0x%5")
@@ -593,7 +599,7 @@ void MainWindow::slotProgDetectChipConfCompleted(int status)
593599
disconnect(prog, SIGNAL(confChipCompleted(int)), this,
594600
SLOT(slotProgDetectChipConfCompleted(int)));
595601

596-
if (status)
602+
if (status < 0)
597603
return;
598604

599605
QTimer::singleShot(50, this, &MainWindow::detectChipReadChipIdDelayed);

qt/main_window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MainWindow : public QMainWindow
4949
private slots:
5050
void slotProgConnectCompleted(int status);
5151
void slotProgReadDeviceIdCompleted(int status);
52-
void slotProgReadCompleted(int status);
52+
void slotProgReadCompleted(int readBytes);
5353
void slotProgReadProgress(unsigned int progress);
5454
void slotProgWriteCompleted(int status);
5555
void slotProgWriteProgress(unsigned int progress);

qt/reader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void Reader::readCb(int size)
242242
}
243243
}
244244
else
245-
emit result(0);
245+
emit result(readOffset);
246246
}
247247

248248
int Reader::read(char *pbuf, uint32_t len)

0 commit comments

Comments
 (0)