Squashed 'DCPlugin/' changes from e5a8cfd..3e3e1ef

3e3e1ef Make sure the printer functions can be called without explicitly openeing the serial device.

git-subtree-dir: DCPlugin
git-subtree-split: 3e3e1efe7d77c71f0101f35c8b38419e877f5636
This commit is contained in:
Gerhard Hoffmann 2023-04-14 09:06:56 +02:00
parent a9e69cd0c4
commit ff5e3f15a4
3 changed files with 4802 additions and 4790 deletions

View File

@ -148,12 +148,12 @@ public:
QVector<int> templateIdx, QVector<int> templateIdx,
QVector<QString> fnames, QVector<QString> fnames,
QString br, QString br,
QString serial) const override; QString serial = QString()) const override;
bool dc_printTemplate(enum FileTypeJson type, bool dc_printTemplate(enum FileTypeJson type,
QVector<int> templateIdx, QVector<int> templateIdx,
QString br, QString br,
QString serial) const override; QString serial = QString()) const override;
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Level 1, control device-controller (functions of µC) // Level 1, control device-controller (functions of µC)
// check serial connection to deviceController // check serial connection to deviceController

View File

@ -310,12 +310,12 @@ public:
QVector<int> templateIdx, QVector<int> templateIdx,
QVector<QString> fnames, QVector<QString> fnames,
QString br, QString br,
QString serial) const = 0; QString serial = QString()) const = 0;
virtual bool dc_printTemplate(enum FileTypeJson type, virtual bool dc_printTemplate(enum FileTypeJson type,
QVector<int> templateIdx, QVector<int> templateIdx,
QString br, QString br,
QString serial) const = 0; QString serial = QString()) const = 0;
virtual void dc_autoRequest(bool on) const =0; virtual void dc_autoRequest(bool on) const =0;
// on = true: select that all READ-Requests are sent automatically // on = true: select that all READ-Requests are sent automatically

View File

@ -438,8 +438,10 @@ bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
qDebug() << "updating: " << fnames << br << serial << "..."; qDebug() << "updating: " << fnames << br << serial << "...";
if (!openSerial(baudrateMap.value(br), br, serial)) { if (!serial.isNull()) {
return false; if (!openSerial(baudrateMap.value(br), br, serial)) {
return false;
}
} }
int nTry = 50; int nTry = 50;
@ -447,7 +449,9 @@ bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (--nTry <= 0) { if (--nTry <= 0) {
qCritical() << "sys not ready for sending"; qCritical() << "sys not ready for sending";
closeSerial(serial); if (!serial.isNull()) {
closeSerial(serial);
}
return false; return false;
} }
} }
@ -471,7 +475,9 @@ bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
continue; continue;
} }
} }
closeSerial(serial); if (!serial.isNull()) {
closeSerial(serial);
}
return ret; return ret;
} }
@ -496,8 +502,10 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
qDebug() << "printing: " << templateIdx << br << serial << "..."; qDebug() << "printing: " << templateIdx << br << serial << "...";
if (!openSerial(baudrateMap.value(br), br, serial)) { if (!serial.isNull()) {
return false; if (!openSerial(baudrateMap.value(br), br, serial)) {
return false;
}
} }
int nTry = 50; int nTry = 50;
@ -505,7 +513,9 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (--nTry <= 0) { if (--nTry <= 0) {
qCritical() << "sys not ready for sending"; qCritical() << "sys not ready for sending";
closeSerial(serial); if (!serial.isNull()) {
closeSerial(serial);
}
return false; return false;
} }
} }
@ -520,7 +530,9 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
continue; continue;
} }
} }
closeSerial(serial); if (!serial.isNull()) {
closeSerial(serial);
}
return ret; return ret;
} }