Skip to content

Add Bidi ribbon monitoring for HiTi P52x printers - #34

Open
mikebean233 wants to merge 1 commit into
masterfrom
feature/bidi-ribbon-monitor
Open

Add Bidi ribbon monitoring for HiTi P52x printers#34
mikebean233 wants to merge 1 commit into
masterfrom
feature/bidi-ribbon-monitor

Conversation

@mikebean233

Copy link
Copy Markdown
Owner

Summary

  • Adds RibbonMonitor class that queries the HiTi P52x printer for real remaining ribbon count via the Windows Bidi interface (IBidiSpl COM), replacing the manually-decremented counter
  • Falls back gracefully to the existing manual RemainingPrints tracking when the Bidi driver extension is not installed or the printer doesn't support it
  • Adds a low-ribbon early warning (default: 10 prints remaining) that triggers a print error before the ribbon is completely exhausted
  • Auto-fills the remaining print count in the out-of-paper error dialog by querying the printer after a ribbon swap

How it works

The RibbonMonitor uses the standard Windows BidiSpl.BidiSpl COM object to send a \Printer.Consumables.Ribbon:Remaining query to the printer driver. This requires the P52xBidiLM.dll wrapper language monitor to be installed alongside the stock HiTi driver (see the P52xL_Driver_v1.6.41.67/bidi/ directory for the driver patch).

When Bidi is unavailable (different printer, driver not patched, printer offline), all queries return null and the existing manual counter behavior is preserved — no functionality is lost.

Changes

File Change
Printing/RibbonMonitor.cs New — Bidi client for ribbon status queries
Printing/PrintManager.cs Sync remaining count from printer after each print and during error checks; expose RibbonMonitor property; add low-ribbon warning
Printing/Printing.csproj Add RibbonMonitor.cs to compilation
MainApplication/PrinterErrorDialog.xaml.cs Accept optional RibbonMonitor param; auto-fill count after ribbon swap
MainApplication/MainWindow.xaml.cs Pass RibbonMonitor to error dialog

Test plan

  • Verify the app builds and runs with no printer connected (Bidi unavailable path)
  • Verify manual RemainingPrints counter still decrements when Bidi returns null
  • With patched HiTi driver installed, verify RibbonMonitor.GetRemainingPrints() returns the real count
  • Verify low-ribbon warning triggers when <= 10 prints remain
  • Verify the error dialog auto-populates the count after a ribbon swap
  • Verify out-of-paper detection still works when ribbon is fully exhausted

🤖 Generated with Claude Code

Query the printer for real remaining ribbon count via the Windows Bidi
interface instead of relying solely on a manually-decremented counter.
Falls back to the existing manual tracking when Bidi is unavailable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant