Skip to content

Fix P15 clone print failures (empty labels / power-off crash)#13

Merged
tomLadder merged 2 commits intomainfrom
fix/p15-clone-packet-size-and-flow-control
Apr 7, 2026
Merged

Fix P15 clone print failures (empty labels / power-off crash)#13
tomLadder merged 2 commits intomainfrom
fix/p15-clone-packet-size-and-flow-control

Conversation

@tomLadder
Copy link
Copy Markdown
Owner

Summary

  • Cap packet size at profile value when MTU exceeds it. The P15 profile sets packetSize: 95 but an MTU notification of 220 was overriding it to 217. Clones with smaller application-level buffers either crash (Pristar P15 powers off) or silently truncate each write, losing ~56% of image data and producing blank labels. The official Marklife app forces device-specific sizes on every tick, ignoring MTU for P15/P12 devices.
  • Preserve hasRealCredits across print jobs. FlowController.reset() was clearing this flag before each job, causing starvation recovery to bypass credit-based flow control for the first few packets — even when the printer actively sends credits via CX.
  • Increase starvation recovery timeout from 30ms to 1000ms to match the official app's behavior.
  • Wire up 30ms inter-packet delay for P15 and P12 profiles, matching the official app's dataPacketDelay.

Context

Reported by a user with a Pristar P15 (clone of Marklife P15). Device discovers and connects fine, but at 100% print progress the printer powers off and the frontend shows a timeout. Debug log showed mtu=220 packet=217 overriding the profile's 95-byte packet size.

Pristar P15 (and likely other clones) powers off when printing because:

1. MTU notification (220) overrides the profile's packet size from 95 to 217,
   overwhelming the printer's application buffer. The official Marklife app
   forces device-specific sizes on every tick, ignoring MTU for P15 devices.

2. FlowController.reset() cleared hasRealCredits before each print job,
   causing starvation recovery to bypass credit-based flow control for the
   first few packets — even when the printer actively sends credits via CX.

3. Starvation recovery timeout was 30ms vs the official app's 1000ms,
   blasting packets far too aggressively when credits aren't flowing.

Changes:
- Cap MTU-derived packet size at profile's explicit packetSize
- Preserve hasRealCredits across reset (connection property, not per-job)
- Increase starvation timeout from 30ms to 1000ms to match official app
The decompiled app uses a configurable dataPacketDelay (30ms for P15
and most devices) between BLE writes. Our packetDelayMs option existed
in the type but was never wired into the send loop.
@tomLadder tomLadder merged commit 7aa6c45 into main Apr 7, 2026
2 checks passed
@tomLadder tomLadder deleted the fix/p15-clone-packet-size-and-flow-control branch April 7, 2026 21:37
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