Skip to content

Conversation

@belono
Copy link
Contributor

@belono belono commented Oct 2, 2025

Description

This starts a PR series to improve and extend the availability of the _read() method to some connectors where it is currently not implemented.

The objectives of this series are:

  • Improve the way we validate the printer's response after a real time status query to reduce false positives. This will also allow for the addition of new status queries (Offline cause, ink status, etc.).
  • Implement the _read() method in the following connectors:
    • File()
    • Dummy()
  • Extend testing of the related methods.

Part 1: Improve on/offline masks consistency and its usage by the Cups connector:

This will close #611 by:

  • Add a RT_MASK_OFFLINE constant and change the value of RT_MASK_ONLINE to a value that is more consistent with the ESC/POS real-time status response format for both constants (a validator/checker is planned for a follow up PR). The new values are also consistent with the rest of RT_MASK_* constants.
  • Make use of the on/offline mask values as the return values of the _read() method in the CupsPrinter() connector to improve readability.
  • Adapt the related methods and tests to the new values.

Part 2: #711

Part 3: #712

Part 4: #714

Tested with

TM-U210 Parallel port printer

@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.41%. Comparing base (11d46fd) to head (3a6d645).

Files with missing lines Patch % Lines
src/escpos/escpos.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #709      +/-   ##
==========================================
+ Coverage   81.39%   81.41%   +0.02%     
==========================================
  Files          21       21              
  Lines        1693     1695       +2     
  Branches      267      267              
==========================================
+ Hits         1378     1380       +2     
+ Misses        235      234       -1     
- Partials       80       81       +1     
Flag Coverage Δ
unittests 81.35% <83.33%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/escpos/constants.py 100.00% <100.00%> (ø)
src/escpos/printer/cups.py 90.42% <100.00%> (+1.17%) ⬆️
src/escpos/escpos.py 75.40% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@belono belono changed the title Improve on/offline masks consistency and its usage by the Cups connector Improve and extend the _read() method availability for its users and related methods. Part 1: Cupsprinter and on/offline. Oct 3, 2025
@belono belono marked this pull request as ready for review October 3, 2025 19:20
@belono belono requested a review from patkan October 3, 2025 19:21
@belono
Copy link
Contributor Author

belono commented Oct 9, 2025

Hey there @patkan .

I know you've been short on time lately, but if you could take a look at these 4 requests and merge them, it would help me write the tests. 🙏

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce IntEnum or similar for printer states

1 participant