From 83bcdcb47eff68e04eb30a4a45aafa7b3b2191f1 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Tue, 13 May 2025 13:44:12 +0200 Subject: [PATCH] Print: improve printing receipt: - call prn_cut() 200ms after prn_switchPower(true) - make an "emergency cut" on error - improve log output on error --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 308dcec..6b63edf 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -806,7 +806,7 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingStri this->printResultCheckCounter = 0; - QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt())); + QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingReceipt())); //QTimer::singleShot(2000, this, [this](){ hw->prn_cut(3); } ); } @@ -827,7 +827,7 @@ void ATBDeviceControllerPlugin::onPrinterWaitForPrintingReceipt() "", ""); hw->prn_switchPower(true); - hw->prn_cut(3); + QTimer::singleShot(200, this, [this](){ hw->prn_cut(3); } ); break; case 2: // printing finished, Error qCritical() << "DC Error: wait for printing receipt"; @@ -837,15 +837,21 @@ void ATBDeviceControllerPlugin::onPrinterWaitForPrintingReceipt() emit this->printReceiptFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, this->errorCode, this->errorDescription); + hw->prn_switchPower(true); + QTimer::singleShot(200, this, [this](){ hw->prn_cut(3); } ); break; default: - qCritical() << "DC Error: wait for printing receipt"; + qCritical() << "DC Error: wait for printing receipt: printerResult = " << printerResult; this->errorCode = "PRINTER"; // TODO: get more detailed error code from low level API - this->errorDescription = "Printer error"; // TODO: get more detailed error description from low level API + this->errorDescription = "Printer error(" + QString(printerResult) + ")"; emit this->printReceiptFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, this->errorCode, this->errorDescription); + // do an emergency cut + hw->prn_switchPower(true); + QTimer::singleShot(200, this, [this](){ hw->prn_cut(3); } ); + break; }