Make sure the printer functions can be called without explicitly openeing the

serial device.
This commit is contained in:
Gerhard Hoffmann 2023-04-14 09:04:35 +02:00
parent e5a8cfd1cd
commit 3e3e1efe7d
3 changed files with 4802 additions and 4790 deletions

View File

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

View File

@ -310,12 +310,12 @@ public:
QVector<int> templateIdx,
QVector<QString> fnames,
QString br,
QString serial) const = 0;
QString serial = QString()) const = 0;
virtual bool dc_printTemplate(enum FileTypeJson type,
QVector<int> templateIdx,
QString br,
QString serial) const = 0;
QString serial = QString()) const = 0;
virtual void dc_autoRequest(bool on) const =0;
// 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 << "...";
if (!openSerial(baudrateMap.value(br), br, serial)) {
return false;
if (!serial.isNull()) {
if (!openSerial(baudrateMap.value(br), br, serial)) {
return false;
}
}
int nTry = 50;
@ -447,7 +449,9 @@ bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (--nTry <= 0) {
qCritical() << "sys not ready for sending";
closeSerial(serial);
if (!serial.isNull()) {
closeSerial(serial);
}
return false;
}
}
@ -471,7 +475,9 @@ bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
continue;
}
}
closeSerial(serial);
if (!serial.isNull()) {
closeSerial(serial);
}
return ret;
}
@ -496,8 +502,10 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
qDebug() << "printing: " << templateIdx << br << serial << "...";
if (!openSerial(baudrateMap.value(br), br, serial)) {
return false;
if (!serial.isNull()) {
if (!openSerial(baudrateMap.value(br), br, serial)) {
return false;
}
}
int nTry = 50;
@ -505,7 +513,9 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (--nTry <= 0) {
qCritical() << "sys not ready for sending";
closeSerial(serial);
if (!serial.isNull()) {
closeSerial(serial);
}
return false;
}
}
@ -520,7 +530,9 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
continue;
}
}
closeSerial(serial);
if (!serial.isNull()) {
closeSerial(serial);
}
return ret;
}