Compare commits
9 Commits
bdef3ff652
...
3fc8562a2b
Author | SHA1 | Date | |
---|---|---|---|
3fc8562a2b | |||
544bab4332 | |||
35f7d56c2a | |||
a63e7018a4 | |||
b05325e5f4 | |||
5cfc346317 | |||
15151a9df4 | |||
b7449ff4a2 | |||
04055e9607 |
@ -33,6 +33,8 @@ QMAKE_CXXFLAGS += -C
|
||||
QMAKE_CXXFLAGS += -O2 -O
|
||||
QMAKE_CXXFLAGS += -g
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
# QMAKE_CXXFLAGS += -fsanitize=address
|
||||
# QMAKE_CXXFLAGS += -fno-omit-frame-pointer
|
||||
|
||||
QMAKE_LFLAGS += -Wl,-e,main
|
||||
|
||||
|
@ -104,11 +104,26 @@ void DownloadThread::run() {
|
||||
|
||||
m_hw->dcDownloadRequestAck();
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): DOWNLOAD THREAD STARTED:";
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName();
|
||||
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
|
||||
#if 1
|
||||
QFile fn(m_hw->dcDownloadFileName());
|
||||
|
||||
if (!fn.exists()) {
|
||||
// output via CONSOLE() etc
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName() << "DOES NOT EXIST";;
|
||||
} else {
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): DC-CONTROLLER SW-VERSION BEFORE"
|
||||
<< m_hw->dc_getSWversion();
|
||||
|
||||
// load binary device controller file into memory
|
||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
||||
if (ba.size() > 0) {
|
||||
@ -118,9 +133,9 @@ 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)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||
@ -129,32 +144,42 @@ void DownloadThread::run() {
|
||||
m_hw->request_DC2_SWversion();
|
||||
QThread::sleep(1);
|
||||
|
||||
// m_hw->dc_autoRequest(false); // turn auto-request setting on
|
||||
|
||||
resetDeviceController();
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
|
||||
QThread::sleep(1);
|
||||
|
||||
if (startBootloader()) {
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STARTED BOOT-LOADER";
|
||||
|
||||
m_hw->dc_autoRequest(false);// turn auto-request setting off for
|
||||
// download of binary dc
|
||||
#if 0
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF FIRMWARE BLOCKS" << totalBlocks;
|
||||
|
||||
int currentBlock = 0; // download of binary dc
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
qCritical() << "64-byte block " << currentBlock;
|
||||
|
||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): currentBlockNumber ..." << currentBlock;
|
||||
|
||||
currentBlock += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< QString("DownloadThread::run(): last 64-byte block %1").arg(currentBlock);
|
||||
|
||||
int const rest = ba.size() % 64;
|
||||
int const offset = ba.size() - rest;
|
||||
@ -175,26 +200,87 @@ void DownloadThread::run() {
|
||||
// QThread::msleep(250);
|
||||
}
|
||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
#else
|
||||
|
||||
stopBootloader(); // stop bootloader several times: if it
|
||||
QThread::sleep(1); // is not stopped, then the PSA has to be
|
||||
}
|
||||
// restarted manually (!!!)
|
||||
stopBootloader();
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
|
||||
|
||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||
// if it was not started at all
|
||||
|
||||
m_hw->dc_autoRequest(true);
|
||||
}
|
||||
|
||||
#else // test
|
||||
// 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));
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "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::ISODateWithMs)
|
||||
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
|
||||
QThread::sleep(1);
|
||||
|
||||
if (startBootloader()) {
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STARTED BOOT-LOADER";
|
||||
|
||||
m_hw->dc_autoRequest(false);// turn auto-request setting off for
|
||||
// download of binary dc
|
||||
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)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
|
||||
}
|
||||
#endif
|
||||
|
||||
m_hw->dcDownloadSetRunning(false);
|
||||
m_hw->dcDownloadSetFinished(true);
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
<< "DOWNLOAD THREAD FINISHED";
|
||||
QDateTime const end = QDateTime::currentDateTime();
|
||||
quint64 secs = start.secsTo(end);
|
||||
QString runtime;
|
||||
if (secs % 60) {
|
||||
runtime = QString("%1min %2s").arg(secs / 60).arg(secs % 60);
|
||||
} else {
|
||||
runtime = QString("%1min").arg((secs / 60) + 1);
|
||||
}
|
||||
|
||||
qCritical() << end.time().toString(Qt::ISODateWithMs)
|
||||
<< QString("DOWNLOAD THREAD FINISHED (RUNTIME %1)")
|
||||
.arg(runtime);
|
||||
|
||||
// the object deletes itself ! This is the last line in run().
|
||||
// Never touch the object after this statement
|
||||
@ -218,7 +304,6 @@ DownloadThread::sendNextAddress(int bNum) const {
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||
// qDebug() << "addr-block" << bNum << "...";
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
QThread::msleep(100);
|
||||
@ -257,9 +342,6 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
memcpy(local, binary.constData() + bAddr, 64);
|
||||
local[64] = local[65] = 0x00;
|
||||
|
||||
// QByteArray b((const char *)(&local[0]), 64);
|
||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
||||
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
QThread::msleep(10);
|
||||
@ -272,9 +354,7 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
}
|
||||
} else {
|
||||
// qInfo() << "data for block" << bNum << "OK";
|
||||
|
||||
// TODO: hier ins shared mem schreiben
|
||||
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
@ -286,64 +366,65 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
}
|
||||
|
||||
bool DownloadThread::startBootloader() const {
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "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);
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_startBL() ..." << nTry;
|
||||
QThread::msleep(500);
|
||||
m_hw->bl_checkBL();
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << "bl_checkBL() ..." << nTry;
|
||||
QThread::msleep(1000);
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
|
||||
QThread::msleep(500);
|
||||
if (m_hw->bl_isUp()) {
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << "bootloader... isUP" << nTry;
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bootloader... isUP" << nTry;
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "bootloader not up (" << nTry << ")";
|
||||
}
|
||||
}
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "starting bootloader FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DownloadThread::stopBootloader() const {
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "stopping bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "bl_stopBL() ...";
|
||||
QThread::msleep(500);
|
||||
m_hw->bl_checkBL();
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << "bl_checkBL() ..." << nTry;
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
|
||||
if (!m_hw->bl_isUp()) {
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "stopping bootloader OK";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "stopping bootloader FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DownloadThread::resetDeviceController() const {
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "resetting device controller...";
|
||||
m_hw->bl_rebootDC();
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
QThread::sleep(1);
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "resetting device controller...OK";
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
|
||||
qDebug() << "loading dc binary" << filename << "...";
|
||||
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||
<< "loading dc binary" << filename << "...";
|
||||
|
||||
QFile file(filename); // closed in destructor call
|
||||
if (!file.exists()) {
|
||||
|
@ -2640,12 +2640,23 @@ void hwapi::bl_openBinary(void) const
|
||||
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
|
||||
{
|
||||
// send 64 byte from bin file
|
||||
uint8_t LL=length, sendBuf[80], sendLen;
|
||||
// gh, 09/02/2024: extend sendBuf. Buffer sometimes too small, sendLen=81
|
||||
uint8_t LL=length, sendBuf[80+32], sendLen;
|
||||
if (LL>64) LL=64;
|
||||
|
||||
tslib_strclr(sendBuf,0,80);
|
||||
memset(sendBuf, 0, sizeof(sendBuf));
|
||||
sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame
|
||||
|
||||
// qCritical() << "(" __func__ << ":" << __LINE__ << ") sendLen=" << sendLen
|
||||
// << ":" << QByteArray((const char *)sendBuf, sendLen);
|
||||
|
||||
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
|
||||
|
||||
// if (sendLen > 80) {
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << QByteArray((const char *)&sendBuf[80], 32).toHex(':');
|
||||
// }
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
ReportingThread::ReportingThread(hwapi *hw)
|
||||
: m_hw(hw)
|
||||
@ -99,14 +100,27 @@ void ReportingThread::run() {
|
||||
|
||||
#endif
|
||||
|
||||
uint16_t const totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
uint16_t totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
cnt = 10;
|
||||
while(--cnt > 0 && totalBlocks == 0) {
|
||||
totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 TOTAL BLOCKS=%2 (%3)")
|
||||
.arg(__LINE__).arg(totalBlocks).arg(cnt);
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 TOTAL BLOCKS=%2").arg(__LINE__).arg(totalBlocks);
|
||||
|
||||
if (totalBlocks) {
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
uint16_t currentBlockNumber = 0;
|
||||
uint16_t prevBlockNumber = ~0;
|
||||
uint64_t estimatedMinutesLeftMax = ~0ULL;
|
||||
uint64_t estimatedSecondsLeftMax = ~0ULL;
|
||||
uint64_t estimatedMinutesLeftPrev = 0;
|
||||
uint64_t estimatedSecondsLeftPrev = 0;
|
||||
|
||||
while (m_hw->dcDownloadGetRunning()) {
|
||||
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
||||
@ -114,13 +128,21 @@ void ReportingThread::run() {
|
||||
double durationSecs = start.secsTo(QDateTime::currentDateTime());
|
||||
|
||||
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationSecs / currentBlockNumber) : durationSecs;
|
||||
long estimatedSecondsLeft = lround((timeAveragePerBlock * (totalBlocks - currentBlockNumber)));
|
||||
long estimatedMinutesLeft =
|
||||
uint64_t estimatedSecondsLeft = lround((timeAveragePerBlock * (totalBlocks - currentBlockNumber)));
|
||||
uint64_t estimatedMinutesLeft =
|
||||
((estimatedSecondsLeft % 60) == 0) ?
|
||||
(estimatedSecondsLeft / 60) :
|
||||
((estimatedSecondsLeft + 60) / 60);
|
||||
|
||||
estimatedSecondsLeft = (estimatedSecondsLeft % 60);
|
||||
|
||||
if ((estimatedMinutesLeft <= estimatedMinutesLeftMax)
|
||||
|| (estimatedSecondsLeft <= estimatedSecondsLeftMax)) {
|
||||
estimatedMinutesLeftMax = estimatedMinutesLeft;
|
||||
estimatedSecondsLeftMax = estimatedSecondsLeft;
|
||||
estimatedMinutesLeftPrev = estimatedMinutesLeft;
|
||||
estimatedSecondsLeftPrev = estimatedSecondsLeft;
|
||||
|
||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
|
||||
.arg(totalBlocks)
|
||||
@ -129,10 +151,26 @@ void ReportingThread::run() {
|
||||
.arg(estimatedMinutesLeft)
|
||||
.arg(estimatedSecondsLeft, 2);
|
||||
|
||||
qCritical() << m_hw << "RT report" << report;
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
<< QString("line=%1: RT report").arg(__LINE__) << report;
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
|
||||
} else {
|
||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
|
||||
.arg(totalBlocks)
|
||||
.arg(currentBlockNumber)
|
||||
.arg(percent, 0, 'f', 2)
|
||||
.arg(estimatedMinutesLeftPrev)
|
||||
.arg(estimatedSecondsLeftPrev, 2);
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||
<< QString("line=%1: RT report").arg(__LINE__) << report;
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
}
|
||||
|
||||
prevBlockNumber = currentBlockNumber;
|
||||
}
|
||||
QThread::msleep(100);
|
||||
@ -150,7 +188,7 @@ void ReportingThread::run() {
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
|
||||
|
||||
cnt = 10;
|
||||
|
@ -684,6 +684,7 @@ bool T_runProc::bl_isUp(void)
|
||||
|
||||
for (nn=0; nn<160; nn++) receivedData[nn]=0;
|
||||
LL=epi_getRawRecLength();
|
||||
|
||||
if (LL>0)
|
||||
{
|
||||
epi_getRawReceivedData(receivedData);
|
||||
@ -696,15 +697,26 @@ bool T_runProc::bl_isUp(void)
|
||||
//epi_clrRawReceivedString();
|
||||
return true;
|
||||
}
|
||||
// response to "start BL"
|
||||
if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 &&
|
||||
receivedData[3]==223 && receivedData[4] ==131 )
|
||||
{
|
||||
qDebug() << "hwapi_bl_isUp: got BL response to start";
|
||||
//epi_clrRawReceivedString();
|
||||
|
||||
// response to "start BL" { 2, 101, 48, 223, 131, 3}
|
||||
static uint8_t const cmp[6] = {0x02, 0x65, 0x30, 0xdf, 0x83, 0x03};
|
||||
|
||||
if (LL >= 6 && LL <= 13) {
|
||||
// (1) "02:63:34:35:62:33:03:02:65:30:df:83:03"
|
||||
// (2) "02:65:30:df:83:03"
|
||||
|
||||
// qCritical() << "(" << __func__ << ":" << __LINE__
|
||||
// << ") CHECK" << QByteArray((char const*)receivedData, LL).toHex(':');
|
||||
|
||||
for (int i=0; i <= LL-6; ++i) {
|
||||
if (memcmp(cmp, &receivedData[i], 6) == 0) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__
|
||||
<< ") BL RESPONSE to bl_start(): BOOTLOADER IS UP";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "datei.h"
|
||||
|
||||
#include <QTextCodec>
|
||||
|
||||
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||
|
||||
@ -64,40 +66,64 @@ bool indat_isMdbOn()
|
||||
|
||||
void gpi_storeHWver(QString text)
|
||||
{
|
||||
QString hwVersion((char const *)SharedMem::read()->indat_HWversion);
|
||||
if (hwVersion != text) {
|
||||
char const *p = text.toUtf8().constData();
|
||||
if (qstrlen(p) > 0) {
|
||||
QString prev(QByteArray(SharedMem::read()->indat_HWversion, versionBufferLen-1));
|
||||
prev = prev.trimmed();
|
||||
|
||||
QString const textTruncated = text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||
|
||||
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||
&& textTruncated != prev) {
|
||||
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||
if (!string.isEmpty()) {
|
||||
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
|
||||
memcpy(SharedMem::write()->indat_HWversion, p,
|
||||
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
|
||||
char *p = (char *)SharedMem::write()->indat_HWversion;
|
||||
char *q = (char *)string.constData();
|
||||
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||
if (q[j]) {
|
||||
*p++ = q[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << "Changed" << hwVersion << "to" << epi_loadHWver();
|
||||
}
|
||||
}
|
||||
|
||||
QString epi_loadHWver(void)
|
||||
{
|
||||
return QString((char const*)SharedMem::read()->indat_HWversion);
|
||||
QString text(SharedMem::read()->indat_HWversion);
|
||||
return text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||
}
|
||||
|
||||
void gpi_storeSWver(QString text)
|
||||
{
|
||||
QString swVersion((char const *)SharedMem::read()->indat_SWversion);
|
||||
if (swVersion != text) {
|
||||
char const *p = text.toUtf8().constData();
|
||||
if (qstrlen(p) > 0) {
|
||||
QString prev(QByteArray(SharedMem::read()->indat_SWversion, 12));
|
||||
prev = prev.trimmed();
|
||||
|
||||
QString const textTruncated = text.mid(0, qMin(12, text.size())).trimmed();
|
||||
|
||||
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||
&& textTruncated != prev) {
|
||||
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||
if (!string.isEmpty()) {
|
||||
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
|
||||
memcpy(SharedMem::write()->indat_SWversion, p,
|
||||
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
|
||||
char *p = (char *)SharedMem::write()->indat_SWversion;
|
||||
char *q = (char *)string.constData();
|
||||
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||
if (q[j]) {
|
||||
*p++ = q[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << "Changed" << swVersion << "to" << epi_loadSWver();
|
||||
}
|
||||
}
|
||||
|
||||
QString epi_loadSWver(void)
|
||||
{
|
||||
return QString((char const*)SharedMem::read()->indat_SWversion);
|
||||
QString text(SharedMem::read()->indat_SWversion);
|
||||
return text.mid(0, qMin(12, text.size())).trimmed();
|
||||
}
|
||||
|
||||
void gpi_storeDCstate(QString text)
|
||||
@ -2177,8 +2203,8 @@ void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData)
|
||||
SharedMem::write()->Sdata_LengthRawData=lrd;
|
||||
for (nn=0; nn<lrd; nn++)
|
||||
SharedMem::write()->Sdata_rawData[nn]=receivedData[nn];
|
||||
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
||||
|
||||
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
||||
}
|
||||
|
||||
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
|
||||
|
Loading…
x
Reference in New Issue
Block a user