Activate updating device-controller-firmware.
This commit is contained in:
parent
06a9eba177
commit
d89520d58e
81
update.cpp
81
update.cpp
@ -28,7 +28,7 @@
|
||||
#define COLUMN_RESULT (3)
|
||||
|
||||
#define UPDATE_OPKG (1)
|
||||
#define UPDATE_DC (0)
|
||||
#define UPDATE_DC (1)
|
||||
#define UPDATE_PRINTER_TEMPLATES (0)
|
||||
#define UPDATE_CASH_TEMPLATE (0)
|
||||
#define UPDATE_CONF_TEMPLATE (0)
|
||||
@ -672,39 +672,74 @@ bool Update::doUpdate() {
|
||||
}
|
||||
QString const &request = lst[COLUMN_REQUEST];
|
||||
QString const &name = lst[COLUMN_NAME];
|
||||
|
||||
QTextStream out(&m_update_ctrl_file_copy);
|
||||
// QString const &datetime = lst[COLUMN_DATE_TIME];
|
||||
// QString const &result = lst[COLUMN_RESULT];
|
||||
qDebug() << "request=" << request << ", name=" << name;
|
||||
if (request.trimmed() == "DOWNLOAD") {
|
||||
if (!serialOpened) { // open serial code once
|
||||
if (!openSerial(baudrateMap.value(m_baudrate), m_baudrate, m_serialInterface)) {
|
||||
qCritical() << "CANNOT OPEN" << m_serialInterface << "(BAUDRATE="
|
||||
<< m_baudrate << ")";
|
||||
return false;
|
||||
if (!serialOpen) {
|
||||
if (!isSerialOpen()) { // open serial only if not already open
|
||||
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate), m_baudrate, m_serialInterface)) == false) {
|
||||
qCritical() << "CANNOT OPEN" << m_serialInterface << "(BAUDRATE="
|
||||
<< m_baudrate << ")";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
serialOpen = true;
|
||||
qCritical() << "SERIAL OPEN" << m_serialInterface << "(BAUDRATE=" << m_baudrate << ")";
|
||||
}
|
||||
|
||||
serialOpened = true;
|
||||
|
||||
QString fwVersion = m_hw->dc_getSWversion();
|
||||
QString const hwVersion = m_hw->dc_getHWversion();
|
||||
|
||||
if (name.contains("dc2c", Qt::CaseInsensitive) &&
|
||||
name.endsWith(".bin", Qt::CaseInsensitive)) {
|
||||
qDebug() << "sending sw/hw-requests...";
|
||||
for (int i=0; i < 3; ++i) { // send explicit reuests to get
|
||||
// current SW/HW-versions
|
||||
m_hw->request_DC2_SWversion();
|
||||
m_hw->request_DC2_HWversion();
|
||||
QThread::sleep(1);
|
||||
}
|
||||
QString const hwVersion = m_hw->dc_getHWversion().toLower();
|
||||
QString const fwVersion = m_hw->dc_getSWversion().toLower();
|
||||
qInfo() << "current dc-hardware-version" << hwVersion;
|
||||
qInfo() << "current dc-firmware-version" << fwVersion;
|
||||
|
||||
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||
QThread::sleep(3); // wait to be sure that there are no more
|
||||
// commands sent to dc-hardware
|
||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
}
|
||||
if (name.contains("dc2c", Qt::CaseInsensitive) &&
|
||||
name.endsWith(".bin", Qt::CaseInsensitive)) {
|
||||
qInfo() << "downloading" << name.trimmed() << "to DC";
|
||||
res = true;
|
||||
QFile fn(name);
|
||||
QFileInfo linkTarget(fn.symLinkTarget());
|
||||
if (!linkTarget.exists()) { // check for broken link
|
||||
res = false;
|
||||
} else {
|
||||
if (fwVersion.startsWith(linkTarget.completeBaseName())) {
|
||||
qCritical() << "current dc-firmware-version" << fwVersion
|
||||
<< "already installed";
|
||||
res = false;
|
||||
} else {
|
||||
res = true;
|
||||
|
||||
qCritical() << "downloading" << name.trimmed() << "->"
|
||||
<< linkTarget.completeBaseName() << "to DC";
|
||||
#if UPDATE_DC == 1
|
||||
if ((res = updateBinary(name.toStdString().c_str())) == true) {
|
||||
qInfo() << "downloaded binary" << name;
|
||||
}
|
||||
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||
QThread::sleep(1); // wait to be sure that there are no more
|
||||
// commands sent to dc-hardware
|
||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
|
||||
if ((res = updateBinary(name.toStdString().c_str())) == true) {
|
||||
qCritical() << "downloaded binary" << name;
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
qDebug() << "WAIT 10 SECS TO RECEIVE RESPONSES...";
|
||||
|
||||
QThread::sleep(10); // wait to be sure that responses
|
||||
// have been received
|
||||
|
||||
qCritical() << "updated dc-hardware-version" << m_hw->dc_getHWversion();
|
||||
qCritical() << "updated dc-firmware-version" << m_hw->dc_getSWversion();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else if (name.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
&& name.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
|
Loading…
Reference in New Issue
Block a user