From f8b9d375768fd5c3b607f4e2f07423309bda0220 Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Wed, 24 Dec 2025 01:33:08 +0300 Subject: [PATCH 1/5] Fix printing waiting for LBP1120 LBP1120 does not set PAPER_DELIVERY right after sending video data, which makes printing impossible: the printer is released before it manage to print anything. --- libcapt/Protocol/ExtendedStatus.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcapt/Protocol/ExtendedStatus.hpp b/libcapt/Protocol/ExtendedStatus.hpp index 8f5cd77..6779afc 100644 --- a/libcapt/Protocol/ExtendedStatus.hpp +++ b/libcapt/Protocol/ExtendedStatus.hpp @@ -23,7 +23,8 @@ namespace Capt::Protocol { } constexpr bool IsPrinting() const noexcept { - return (this->Aux & AuxStatus::PAPER_DELIVERY) != 0 || (this->Aux & AuxStatus::SAFE_TIMER) != 0; + return (this->Aux & AuxStatus::PAPER_DELIVERY) != 0 || (this->Aux & AuxStatus::SAFE_TIMER) != 0 + || !this->Printed; } constexpr bool Ready() const noexcept { From 20d2e60f6a5033163d2cea9920b49f68f1399bec Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Thu, 25 Dec 2025 20:36:21 +0300 Subject: [PATCH 2/5] Apply Printed check only while the printer is Online --- libcapt/Protocol/ExtendedStatus.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcapt/Protocol/ExtendedStatus.hpp b/libcapt/Protocol/ExtendedStatus.hpp index 6779afc..2a2f4ed 100644 --- a/libcapt/Protocol/ExtendedStatus.hpp +++ b/libcapt/Protocol/ExtendedStatus.hpp @@ -24,7 +24,7 @@ namespace Capt::Protocol { constexpr bool IsPrinting() const noexcept { return (this->Aux & AuxStatus::PAPER_DELIVERY) != 0 || (this->Aux & AuxStatus::SAFE_TIMER) != 0 - || !this->Printed; + || (this->Printed == 0 && this->Online()); } constexpr bool Ready() const noexcept { From 0425c50d2f90b97096d5fe2a15b5e295b95a8e30 Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Thu, 25 Dec 2025 22:23:54 +0300 Subject: [PATCH 3/5] Add expectedPage number to IsPrinting, to wait for exact (last) page --- libcapt/BasicCaptPrinter.hpp | 6 ++++++ libcapt/Protocol/ExtendedStatus.hpp | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libcapt/BasicCaptPrinter.hpp b/libcapt/BasicCaptPrinter.hpp index af59bd8..2f66a75 100644 --- a/libcapt/BasicCaptPrinter.hpp +++ b/libcapt/BasicCaptPrinter.hpp @@ -164,6 +164,12 @@ namespace Capt { return this->WaitStatus({}, func, delay).value(); } + inline virtual std::optional WaitPrintEnd(StopTokenType stopToken, unsigned expectedPage) { + return this->WaitStatus(stopToken, [expectedPage](const Protocol::ExtendedStatus& ex) { + return !ex.IsPrinting(expectedPage); + }, std::chrono::seconds(1)); + } + // nullopt if stop requested inline virtual std::optional WaitPrintEnd(StopTokenType stopToken) { return this->WaitStatus(stopToken, [](const Protocol::ExtendedStatus& ex) { diff --git a/libcapt/Protocol/ExtendedStatus.hpp b/libcapt/Protocol/ExtendedStatus.hpp index 2a2f4ed..6aad6e2 100644 --- a/libcapt/Protocol/ExtendedStatus.hpp +++ b/libcapt/Protocol/ExtendedStatus.hpp @@ -22,9 +22,13 @@ namespace Capt::Protocol { return (this->PaperAvailableBits & (0x80 >> (slot & 0x1f))) != 0; } - constexpr bool IsPrinting() const noexcept { + constexpr bool IsPrinting(unsigned expectedPage) const noexcept { return (this->Aux & AuxStatus::PAPER_DELIVERY) != 0 || (this->Aux & AuxStatus::SAFE_TIMER) != 0 - || (this->Printed == 0 && this->Online()); + || (this->Online() && expectedPage ? this->Printed != expectedPage : this->Printed == 0); + } + + constexpr bool IsPrinting() const noexcept { + return this->IsPrinting(0); } constexpr bool Ready() const noexcept { From 26232e5760a367030303aa199d3f9c8640935e0c Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Thu, 25 Dec 2025 23:21:45 +0300 Subject: [PATCH 4/5] Revert "Add expectedPage number to IsPrinting, to wait for exact (last) page" This reverts commit 0425c50d2f90b97096d5fe2a15b5e295b95a8e30. --- libcapt/BasicCaptPrinter.hpp | 6 ------ libcapt/Protocol/ExtendedStatus.hpp | 8 ++------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/libcapt/BasicCaptPrinter.hpp b/libcapt/BasicCaptPrinter.hpp index 2f66a75..af59bd8 100644 --- a/libcapt/BasicCaptPrinter.hpp +++ b/libcapt/BasicCaptPrinter.hpp @@ -164,12 +164,6 @@ namespace Capt { return this->WaitStatus({}, func, delay).value(); } - inline virtual std::optional WaitPrintEnd(StopTokenType stopToken, unsigned expectedPage) { - return this->WaitStatus(stopToken, [expectedPage](const Protocol::ExtendedStatus& ex) { - return !ex.IsPrinting(expectedPage); - }, std::chrono::seconds(1)); - } - // nullopt if stop requested inline virtual std::optional WaitPrintEnd(StopTokenType stopToken) { return this->WaitStatus(stopToken, [](const Protocol::ExtendedStatus& ex) { diff --git a/libcapt/Protocol/ExtendedStatus.hpp b/libcapt/Protocol/ExtendedStatus.hpp index 6aad6e2..2a2f4ed 100644 --- a/libcapt/Protocol/ExtendedStatus.hpp +++ b/libcapt/Protocol/ExtendedStatus.hpp @@ -22,13 +22,9 @@ namespace Capt::Protocol { return (this->PaperAvailableBits & (0x80 >> (slot & 0x1f))) != 0; } - constexpr bool IsPrinting(unsigned expectedPage) const noexcept { - return (this->Aux & AuxStatus::PAPER_DELIVERY) != 0 || (this->Aux & AuxStatus::SAFE_TIMER) != 0 - || (this->Online() && expectedPage ? this->Printed != expectedPage : this->Printed == 0); - } - constexpr bool IsPrinting() const noexcept { - return this->IsPrinting(0); + return (this->Aux & AuxStatus::PAPER_DELIVERY) != 0 || (this->Aux & AuxStatus::SAFE_TIMER) != 0 + || (this->Printed == 0 && this->Online()); } constexpr bool Ready() const noexcept { From 5653f6e7bfe0f2c701d841b1bc1ea34fd71ce250 Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Thu, 25 Dec 2025 23:22:29 +0300 Subject: [PATCH 5/5] Check this->Start != this->Printing --- libcapt/Protocol/ExtendedStatus.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcapt/Protocol/ExtendedStatus.hpp b/libcapt/Protocol/ExtendedStatus.hpp index 2a2f4ed..3f284d6 100644 --- a/libcapt/Protocol/ExtendedStatus.hpp +++ b/libcapt/Protocol/ExtendedStatus.hpp @@ -24,7 +24,7 @@ namespace Capt::Protocol { constexpr bool IsPrinting() const noexcept { return (this->Aux & AuxStatus::PAPER_DELIVERY) != 0 || (this->Aux & AuxStatus::SAFE_TIMER) != 0 - || (this->Printed == 0 && this->Online()); + || (this->Online() && this->Start != this->Printing); } constexpr bool Ready() const noexcept {