Fixed sending to less blocks
This commit is contained in:
parent
defe492ec6
commit
8f7d4a203d
@ -188,7 +188,7 @@ hwapi::DownloadResult hwapi::sendNextAddress(int bNum) const {
|
|||||||
qDebug() << "addr-block" << bNum << "...";
|
qDebug() << "addr-block" << bNum << "...";
|
||||||
while (noAnswerCount <= 250) {
|
while (noAnswerCount <= 250) {
|
||||||
bl_sendAddress(bNum);
|
bl_sendAddress(bNum);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
DownloadResult const res = sendStatus(bl_wasSendingAddOK());
|
DownloadResult const res = sendStatus(bl_wasSendingAddOK());
|
||||||
if (res != DownloadResult::NOP) {
|
if (res != DownloadResult::NOP) {
|
||||||
if (res == DownloadResult::ERROR) {
|
if (res == DownloadResult::ERROR) {
|
||||||
@ -246,24 +246,24 @@ hwinf::DownloadResult hwapi::sendNextDataBlock(QByteArray const &binary,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hwinf::DownloadResult hwapi::dc_downloadBinary(QByteArray const &b) const {
|
hwinf::DownloadResult hwapi::dc_downloadBinary(QByteArray const &b) const {
|
||||||
|
|
||||||
int const nBlocks = (((b.size())%64)==0) ? (b.size()/64) : (b.size()/64)+1;
|
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();
|
qInfo() << "total number of bytes to send to dc" << b.size();
|
||||||
qInfo() << "total number of blocks to send to dc" << nBlocks;
|
qInfo() << "total number of blocks to send to dc" << nBlocks;
|
||||||
|
|
||||||
for (int blockNumber = 0; blockNumber < nBlocks; ++blockNumber) {
|
int bNum = 0;
|
||||||
DownloadResult res = sendNextAddress(blockNumber);
|
DownloadResult res = DownloadResult::OK;
|
||||||
if (res == DownloadResult::NOP) { // no address had to be
|
while (res != DownloadResult::ERROR && bNum < nBlocks) {
|
||||||
res = sendNextDataBlock(b, blockNumber); // sent, so send next block
|
if ((res = sendNextAddress(bNum)) != DownloadResult::ERROR) {
|
||||||
} // as data block
|
if ((res = sendNextDataBlock(b, bNum)) != DownloadResult::ERROR) {
|
||||||
if (res != DownloadResult::OK) {
|
bNum += 1;
|
||||||
return res;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (res != DownloadResult::ERROR) {
|
||||||
bl_sendLastBlock();
|
bl_sendLastBlock();
|
||||||
return DownloadResult::OK;
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::startBootloader() const {
|
bool hwapi::startBootloader() const {
|
||||||
@ -2960,7 +2960,6 @@ void hwapi::bl_sendLastBlock(void) const
|
|||||||
|
|
||||||
len=dcBL_writeLastPage(buf);
|
len=dcBL_writeLastPage(buf);
|
||||||
sendWRcmd_setSendBlock160(len, buf);
|
sendWRcmd_setSendBlock160(len, buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t hwapi::bl_wasSendingDataOK(void) const
|
uint8_t hwapi::bl_wasSendingDataOK(void) const
|
||||||
|
Loading…
Reference in New Issue
Block a user