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