forked from GerhardHoffmann/DCLibraries
Do real download, not just some simulation.
This commit is contained in:
parent
6005fddc66
commit
0839254f06
@ -104,8 +104,10 @@ void DownloadThread::run() {
|
|||||||
|
|
||||||
m_hw->dcDownloadRequestAck();
|
m_hw->dcDownloadRequestAck();
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED";
|
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED:";
|
||||||
|
qCritical() << " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName();
|
||||||
|
|
||||||
|
#if 1
|
||||||
// load binary device controller file into memory
|
// load binary device controller file into memory
|
||||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
||||||
if (ba.size() > 0) {
|
if (ba.size() > 0) {
|
||||||
@ -115,13 +117,17 @@ void DownloadThread::run() {
|
|||||||
// fill last block of data to be sent with 0xFF
|
// fill last block of data to be sent with 0xFF
|
||||||
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||||
|
|
||||||
resetDeviceController();
|
|
||||||
if (startBootloader()) {
|
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||||
|
|
||||||
int currentBlock = 0;
|
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||||
|
|
||||||
|
resetDeviceController();
|
||||||
|
QThread::sleep(1);
|
||||||
|
if (startBootloader()) {
|
||||||
|
m_hw->dc_autoRequest(false);// turn auto-request setting off for
|
||||||
|
#if 0
|
||||||
|
int currentBlock = 0; // download of binary dc
|
||||||
DownloadResult res = DownloadResult::OK;
|
DownloadResult res = DownloadResult::OK;
|
||||||
qCritical() << "64-byte block " << currentBlock;
|
qCritical() << "64-byte block " << currentBlock;
|
||||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||||
@ -149,20 +155,32 @@ void DownloadThread::run() {
|
|||||||
} else {
|
} else {
|
||||||
m_hw->bl_sendLastBlock();
|
m_hw->bl_sendLastBlock();
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
|
|
||||||
|
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
|
||||||
|
// QThread::msleep(250);
|
||||||
}
|
}
|
||||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||||
|
#endif
|
||||||
|
m_hw->dc_autoRequest(true); // turn auto-request setting on again
|
||||||
}
|
}
|
||||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||||
} // if it was not started at all
|
} // if it was not started at all
|
||||||
|
|
||||||
#if 0
|
#else
|
||||||
// test code:
|
// load binary device controller file into memory
|
||||||
uint16_t const totalBlocks = 100;
|
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
||||||
|
if (ba.size() > 0) {
|
||||||
|
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
|
||||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
||||||
|
|
||||||
|
// fill last block of data to be sent with 0xFF
|
||||||
|
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||||
|
|
||||||
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
QThread::msleep(100);
|
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
|
||||||
|
QThread::msleep(250);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -265,11 +283,12 @@ bool DownloadThread::startBootloader() const {
|
|||||||
int nTry = 5;
|
int nTry = 5;
|
||||||
while (--nTry >= 0) {
|
while (--nTry >= 0) {
|
||||||
m_hw->bl_startBL();
|
m_hw->bl_startBL();
|
||||||
QThread::msleep(5000);
|
QThread::msleep(1000);
|
||||||
m_hw->bl_checkBL();
|
m_hw->bl_checkBL();
|
||||||
|
QThread::msleep(1000);
|
||||||
if (m_hw->bl_isUp()) {
|
if (m_hw->bl_isUp()) {
|
||||||
qInfo() << "starting bootloader...OK";
|
qInfo() << "starting bootloader...OK";
|
||||||
QThread::msleep(5000);
|
QThread::msleep(1000);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "bootloader not up (" << nTry << ")";
|
qCritical() << "bootloader not up (" << nTry << ")";
|
||||||
|
Loading…
Reference in New Issue
Block a user