When sending dc-data, fill the last block with 0xFF to stream-line the source code.
This commit is contained in:
parent
7d6b433373
commit
fa04e32266
23
update.cpp
23
update.cpp
@ -277,29 +277,32 @@ Update::DownloadResult Update::sendNextDataBlock(QByteArray const &binary,
|
||||
Update::DownloadResult Update::dc_downloadBinary(QByteArray const &b) const {
|
||||
int const nBlocks = (((b.size())%64)==0) ? (b.size()/64) : (b.size()/64)+1;
|
||||
|
||||
qInfo() << "total number of bytes to send to dc" << b.size();
|
||||
// fill lst block of data to be sent with 0xFF
|
||||
QByteArray ba = b.leftJustified(nBlocks*64, (char)(0xFF));
|
||||
|
||||
qInfo() << "total number of bytes to send to dc" << ba.size();
|
||||
qInfo() << "total number of blocks to send to dc" << nBlocks;
|
||||
|
||||
int bNum = 0;
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
while (res != DownloadResult::ERROR && bNum < nBlocks) {
|
||||
if ((res = sendNextAddress(bNum)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(b, bNum)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, bNum)) != DownloadResult::ERROR) {
|
||||
bNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
qInfo() << "nBlocks" << nBlocks;
|
||||
//if (res != DownloadResult::ERROR) {
|
||||
// always send last block, even when there are no data !!!
|
||||
int const rest = b.size() % 64;
|
||||
int const offset = b.size() - rest;
|
||||
char const *startAddress = b.constData() + offset;
|
||||
int const rest = ba.size() % 64;
|
||||
int const offset = ba.size() - rest;
|
||||
char const *startAddress = ba.constData() + offset;
|
||||
|
||||
uint8_t local[66];
|
||||
memset(local, 0x00, sizeof(local));
|
||||
if (rest > 0) {
|
||||
// SHOULD NEVER HAPPEN !!!
|
||||
uint8_t local[66];
|
||||
memset(local, 0xFF, sizeof(local));
|
||||
memcpy(local, startAddress, rest);
|
||||
qCritical() << "ERROR SEND REMAINING" << rest << "BYTES";
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
}
|
||||
|
||||
m_hw->bl_sendLastBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user