Aopen serial port only when necessary, i.e. when downloading device controller
or json-files.
This commit is contained in:
parent
c7acc2a99b
commit
528b74549a
54
update.cpp
54
update.cpp
@ -605,22 +605,7 @@ bool Update::doUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!openSerial(baudrateMap.value(m_baudrate), m_baudrate, m_serialInterface)) {
|
||||
qCritical() << "CANNOT OPEN" << m_serialInterface << "(BAUDRATE="
|
||||
<< m_baudrate << ")";
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fwVersion = m_hw->dc_getSWversion();
|
||||
QString const hwVersion = m_hw->dc_getHWversion();
|
||||
|
||||
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";
|
||||
bool serialOpened = false;
|
||||
|
||||
QStringList linesToWorkOn = getLinesToWorkOn();
|
||||
if (linesToWorkOn.size() == 0) {
|
||||
@ -651,6 +636,26 @@ bool Update::doUpdate() {
|
||||
// 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;
|
||||
}
|
||||
|
||||
serialOpened = true;
|
||||
|
||||
QString fwVersion = m_hw->dc_getSWversion();
|
||||
QString const hwVersion = m_hw->dc_getHWversion();
|
||||
|
||||
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";
|
||||
@ -750,14 +755,19 @@ bool Update::doUpdate() {
|
||||
20, 20, QDateTime::currentDateTime().toString(Qt::ISODate).toStdString().c_str(),
|
||||
10, 10, (res == true) ? "SUCCESS" : "ERROR");
|
||||
m_update_ctrl_file_copy.write(buf);
|
||||
|
||||
qInfo() << "write" << buf << "into file" << m_update_ctrl_file_copy;
|
||||
|
||||
} // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
|
||||
|
||||
closeSerial();
|
||||
m_hw->dc_autoRequest(true);
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
|
||||
qInfo() << "current dc-hardware-version" << m_hw->dc_getHWversion();
|
||||
qInfo() << "current dc-firmware-version" << m_hw->dc_getSWversion();
|
||||
if (serialOpened) {
|
||||
m_hw->dc_autoRequest(true);
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
qInfo() << "current dc-hardware-version" << m_hw->dc_getHWversion();
|
||||
qInfo() << "current dc-firmware-version" << m_hw->dc_getSWversion();
|
||||
closeSerial();
|
||||
serialOpened = false;
|
||||
}
|
||||
|
||||
return finishUpdate(linesToWorkOn.size() > 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user