Compare commits

..

No commits in common. "5599c561144326b237e6b0484cbd41a79aece7bd" and "100ada06f8a0f5ad1d9768a68539f29315819817" have entirely different histories.

3 changed files with 40 additions and 67 deletions

View File

@ -104,11 +104,10 @@ void DownloadThread::run() {
m_hw->dcDownloadRequestAck();
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "DownloadThread::run(): DOWNLOAD THREAD STARTED:";
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName();
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED:";
qCritical() << " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName();
#if 1
// load binary device controller file into memory
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
if (ba.size() > 0) {
@ -118,29 +117,15 @@ void DownloadThread::run() {
// fill last block of data to be sent with 0xFF
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
m_hw->dc_autoRequest(true); // turn auto-request setting on
m_hw->request_DC2_HWversion();
m_hw->request_DC2_SWversion();
QThread::sleep(1);
resetDeviceController();
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
QThread::sleep(1);
if (startBootloader()) {
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "DownloadThread::run(): STARTED BOOT-LOADER";
m_hw->dc_autoRequest(false);// turn auto-request setting off for
// download of binary dc
#if 0
int currentBlock = 0; // download of binary dc
DownloadResult res = DownloadResult::OK;
@ -175,26 +160,34 @@ void DownloadThread::run() {
// QThread::msleep(250);
}
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
#else
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
QThread::msleep(250);
}
#endif
m_hw->dc_autoRequest(true); // turn auto-request setting on again
}
stopBootloader(); // there is no harm in stopping the bootloader even
// if it was not started at all
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
} // if it was not started at all
#else
// load binary device controller file into memory
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);
// 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) {
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
QThread::msleep(250);
}
}
#endif
m_hw->dcDownloadSetRunning(false);
m_hw->dcDownloadSetFinished(true);
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "DOWNLOAD THREAD FINISHED";
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD FINISHED";
// the object deletes itself ! This is the last line in run().
// Never touch the object after this statement
@ -286,59 +279,46 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
}
bool DownloadThread::startBootloader() const {
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "starting bootloader...";
qDebug() << "starting bootloader...";
int nTry = 5;
while (--nTry >= 0) {
m_hw->bl_startBL();
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << "bl_startBL() ..." << nTry;
QThread::msleep(1000);
m_hw->bl_checkBL();
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << "bl_checkBL() ..." << nTry;
QThread::msleep(1000);
if (m_hw->bl_isUp()) {
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << "bootloader... isUP" << nTry;
qInfo() << "starting bootloader...OK";
QThread::msleep(1000);
return true;
} else {
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "bootloader not up (" << nTry << ")";
qCritical() << "bootloader not up (" << nTry << ")";
}
}
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "starting bootloader FAILED";
qCritical() << "starting bootloader...FAILED";
return false;
}
bool DownloadThread::stopBootloader() const {
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "stopping bootloader...";
qDebug() << "stopping bootloader...";
int nTry = 5;
while (--nTry >= 0) {
m_hw->bl_stopBL();
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "bl_stopBL() ...";
QThread::msleep(500);
m_hw->bl_checkBL();
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << "bl_checkBL() ..." << nTry;
if (!m_hw->bl_isUp()) {
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "stopping bootloader OK";
qInfo() << "stopping bootloader...OK";
return true;
}
}
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "stopping bootloader FAILED";
qCritical() << "stopping bootloader...FAILED";
return false;
}
bool DownloadThread::resetDeviceController() const {
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "resetting device controller...";
qDebug() << "resetting device controller...";
m_hw->bl_rebootDC();
// wait maximally 3 seconds, before starting bootloader
QThread::sleep(1);
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "resetting device controller...OK";
qInfo() << "resetting device controller...OK";
return true;
}

View File

@ -23,8 +23,7 @@ ReportingThread::~ReportingThread() {
void ReportingThread::run() {
qCritical()
<< QDateTime::currentDateTime().time().toString(Qt::ISODate)
<< "START REPORT THREAD"
<< QDateTime::currentDateTime() << "START REPORT THREAD"
<< "(PART OF APPLICATION" << QCoreApplication::applicationName() << ")";
static QString report("");
@ -33,9 +32,9 @@ void ReportingThread::run() {
while (!m_hw->dcDownloadGetRunning()) {
if (--cnt > 0) {
report = QString("%1 waiting for download to start %2")
.arg(QDateTime::currentDateTime().time().toString(Qt::ISODate))
.arg(QDateTime::currentDateTime().toString(Qt::ISODate))
.arg(cnt);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") STATUS" << report;
qCritical() << __LINE__ << "STATUS" << report;
emit m_hw->hwapi_reportDCDownloadStatus(report);
QThread::sleep(1);
} else break;

View File

@ -64,8 +64,7 @@ bool indat_isMdbOn()
void gpi_storeHWver(QString text)
{
QString hwVersion((char const *)SharedMem::read()->indat_HWversion);
if (hwVersion != text) {
if (qstrlen(SharedMem::read()->indat_HWversion) == 0) {
char const *p = text.toUtf8().constData();
if (qstrlen(p) > 0) {
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
@ -73,8 +72,6 @@ void gpi_storeHWver(QString text)
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
}
}
qCritical() << "HW TEXT" << epi_loadHWver();
}
QString epi_loadHWver(void)
@ -84,8 +81,7 @@ QString epi_loadHWver(void)
void gpi_storeSWver(QString text)
{
QString swVersion((char const *)SharedMem::read()->indat_SWversion);
if (swVersion != text) {
if (qstrlen(SharedMem::read()->indat_SWversion) == 0) {
char const *p = text.toUtf8().constData();
if (qstrlen(p) > 0) {
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
@ -93,8 +89,6 @@ void gpi_storeSWver(QString text)
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
}
}
qCritical() << "SW TEXT" << epi_loadSWver();
}
QString epi_loadSWver(void)