Added some debug output.

Send only one DC_print-template.
Tested again downloading dc-firmware and printer-templates.
This commit is contained in:
Gerhard Hoffmann 2023-05-18 14:26:23 +02:00
parent 8d325c20eb
commit 18e4811d57

View File

@ -25,6 +25,9 @@ static void updateBinary(std::unique_ptr<hwinf> hw, // update d2dc*.bin
char const *baudrate, char const *baudrate,
char const *serialInterface) { char const *serialInterface) {
for (int i=0; i < 1;++i) { for (int i=0; i < 1;++i) {
qDebug() << "file to send to DC ..." << fileToSendToDC;
qDebug() << "baudrate ............." << baudrate;
qDebug() << "serial interface ....." << serialInterface;
hw->dc_updateDC(fileToSendToDC, baudrate, serialInterface); hw->dc_updateDC(fileToSendToDC, baudrate, serialInterface);
std::this_thread::sleep_for(std::chrono::milliseconds(3000)); std::this_thread::sleep_for(std::chrono::milliseconds(3000));
} }
@ -35,13 +38,14 @@ static void updatePrinterConf(std::unique_ptr<hwinf> hw, // update printer-file
QVector<int> nrOfTemplate, QVector<int> nrOfTemplate,
QVector<QString> fileToSendToDC, QVector<QString> fileToSendToDC,
QString br, QString serial) { QString br, QString serial) {
for (int i=0; i < 1;++i) { // for (int i = 0; i < 1; ++i) {
//hw->dc_updatePrinterTemplate(hwapi::FileTypeJson::PRINTER, if (nrOfTemplate.size() == 1 && fileToSendToDC.size() == 1) {
// nrOfTemplate, fileToSendToDC, hw->dc_updatePrinterTemplate(hwapi::FileTypeJson::PRINTER,
// br, serial); nrOfTemplate, fileToSendToDC,
br, serial);
hw->dc_printTemplate(hwapi::FileTypeJson::PRINTER, // hw->dc_printTemplate(hwapi::FileTypeJson::PRINTER,
nrOfTemplate, br, serial); // nrOfTemplate, br, serial);
} }
QCoreApplication::quit(); QCoreApplication::quit();
} }
@ -56,7 +60,7 @@ int main(int argc, char *argv[]) {
//setDebugLevel(QtMsgType::QtDebugMsg); //setDebugLevel(QtMsgType::QtDebugMsg);
} }
if (argc > 2) { if (argc != 2) {
qCritical() << "Usage: " << argv[0] << "<file to send to dc>"; qCritical() << "Usage: " << argv[0] << "<file to send to dc>";
return -1; return -1;
} }
@ -72,17 +76,29 @@ int main(int argc, char *argv[]) {
ret = a.exec(); ret = a.exec();
t.join(); t.join();
} else { } else {
QVector<QString> fnames{"DC2C_print01.json", if (fname.startsWith("DC2C_print") && fname.endsWith(".json")) {
"DC2C_print02.json", qDebug() << "downloading" << fname << "to dc...";
"DC2C_print03.json"};
QVector<int> templateIdx{1,2,3}; QVector<QString> fnames;
//if (fname.startsWith("DC2C_print") && fname.endsWith(".json")) { QVector<int> templateIdx;
//int const nrOfTemplate = fname.midRef(10, 2).toInt();
std::thread t(updatePrinterConf, std::move(hw), templateIdx, fnames, int const nrOfTemplate = fname.midRef(10, 2).toInt();
"115200", SERIAL_PORT); if (nrOfTemplate <= 0 && nrOfTemplate > 32) {
ret = a.exec(); qCritical() << "wrong template number" << nrOfTemplate;
t.join(); return -1;
//} }
fnames.append(fname);
templateIdx.append(nrOfTemplate);
std::thread t(updatePrinterConf, std::move(hw),
templateIdx,
fnames,
"115200", SERIAL_PORT);
ret = a.exec();
t.join();
}
} }
return ret; return ret;