BlueGit

timfa posprint

Files

posprint / docs / FEASIBILITY.md

FEASIBILITY.md

FEASIBILITY.md 7.3 KiB Download Raw

Feasibility and complexity assessment

Executive summary

QuestionAnswer
Is it feasible?Yes — all required capabilities exist in mature libraries or documented protocols
Overall complexityMedium–high for a complete v1; medium if Bluetooth is deferred
Biggest riskCross-platform raw printer I/O (USB class, serial, Bluetooth SPP)
Recommended MVP scopeUSB-serial printers first; add USB-printer-class and Bluetooth in v1.1

A focused MVP is realistic for one developer in roughly 6–10 weeks. A polished v1 with broad printer compatibility is closer to 3–4 months.

---

Requirements breakdown

1. Cross-platform desktop app (Windows + Linux)

AspectFeasibilityComplexity
Single codebase, native binariesHighLow–medium
Packaged installers (.msi/.exe, .deb/AppImage)HighMedium

Modern cross-platform desktop frameworks (Tauri, egui, Avalonia, Qt) all support Windows and Linux. Packaging is routine but needs CI and per-OS testing.

2. Markdown-like document syntax + live preview

AspectFeasibilityComplexity
Custom lightweight DSLHighMedium
Live preview paneHighMedium
Width modes (auto-scale / fixed mm)HighLow–medium

The DSL does not need full CommonMark — a small, POS-oriented grammar keeps the parser simple. Preview renders to a monospace layout matching printer dot width (e.g. 384 dots @ 58 mm, 576 dots @ 80 mm). Matching exact printer fonts is approximate in preview; exact fidelity is only guaranteed at print time.

3. Save / load .pos files

AspectFeasibilityComplexity
JSON or TOML envelope + body textHighLow

Trivial with serde (Rust) or equivalent. Version field supports forward-compatible evolution.

4. Parameter tokens (${Name})

AspectFeasibilityComplexity
Parse and collect unique namesHighLow
Print-time modal with last-used valuesHighLow
Deduplicate same name across documentHighLow
Use in text, barcodes, QR, imagesHighLow–medium

Straightforward string substitution after validation. Image parameters might reference file paths or base64 — define clearly in DSL spec.

5. Barcodes, QR codes, images

AspectFeasibilityComplexity
Generate ESC/POS barcode commandsHighLow
Generate ESC/POS QR commandsHighLow
Rasterize images to printer widthHighMedium

The escpos Rust crate (and similar libraries in other languages) already implements barcodes, QR, and raster graphics. Preview can use the same generation path and render bitmaps in the UI.

6. Direct USB / Bluetooth printing (raw bytes, no spooler)

AspectFeasibilityComplexity
USB serial (CDC-ACM, CH340, FTDI)HighMedium
USB printer class (bulk OUT)MediumHigh
Bluetooth Classic SPPMediumHigh
Enumerate devices in UIMediumMedium
Printer-specific quirksOngoingHigh

This is the primary technical risk.

How POS printers actually connect

Most consumer thermal printers expose one of:

1. Virtual COM port (USB-serial) — very common; appears as COM3 (Windows) or /dev/ttyUSB0 / /dev/ttyACM0 (Linux). Raw ESC/POS bytes are written to the serial port. Easiest path.

2. USB printer class (interface 7) — bulk transfers to endpoint; needs libusb/nusb on Linux and either WinUSB/Zadig or Windows usbprint.sys on Windows. The escpos crate’s usbprint feature uses the Windows kernel driver without replacing it.

3. Bluetooth Classic SPP — serial profile; paired device appears as a COM port (Windows) or /dev/rfcomm* (Linux). Requires platform Bluetooth APIs for discovery; connection is then serial I/O.

4. Network (TCP 9100) — common in production but out of scope unless added later.

“No drivers” in practice means no Windows print spooler / CUPS job — the app opens the device directly and writes bytes. USB-serial devices often need only the generic CDC driver already present. USB-printer-class devices on Windows may still use usbprint.sys, which is a kernel driver but not a vendor-specific print driver.

Compatibility reality

  • MVP: Target Epson-compatible ESC/POS over USB-serial. Covers a large share of cheap 58/80 mm printers.
  • v1: Add USB printer class via nusb / usbprint.
  • v1.1: Add Bluetooth SPP discovery and pairing UX.

Expect per-printer testing; some devices need init sequences, code pages, or cut commands that differ slightly.

---

Complexity by subsystem

                    Effort (relative)
Editor UI           ████████░░  Medium
Preview renderer    ███████░░░  Medium
DSL parser          ██████░░░░  Medium
File I/O            ██░░░░░░░░  Low
Parameters          ███░░░░░░░  Low
Barcode/QR/image    █████░░░░░  Low–medium
Printer discovery   ███████░░░  Medium
Raw print I/O       █████████░  High
Integration/polish  ██████░░░░  Medium

---

Effort estimate (one experienced developer)

PhaseScopeDuration
0 — DesignSpecs, DSL, file format1 week
1 — CoreParser, ESC/POS builder, preview, .pos I/O2–3 weeks
2 — UIEditor, preview split, settings, parameters dialog2 weeks
3 — Print MVPUSB-serial enumeration + print1–2 weeks
4 — HardeningUSB class, BT, edge cases, packaging2–4 weeks

MVP (serial USB only): ~6–8 weeks Full v1 (USB + BT, packaged): ~10–14 weeks

Add 30–50% if the developer is new to Rust or ESC/POS.

---

Risks and mitigations

RiskImpactMitigation
Printer hardware diversityPrints garbled or not at allESC/POS subset doc; test matrix; user-selectable code page
Linux permissions (dialout)Cannot open serial portDocument group membership; clear error UI
Windows USB accessAdmin / driver conflictsPrefer serial-first; use usbprint where applicable
Bluetooth pairing UXUsers cannot find printerDefer BT; link to OS pairing instructions
Preview ≠ printUser confusionLabel preview as approximate; same backend for print
Image size on narrow paperSlow print or clippedAuto-scale to page width; warn in UI

---

Out of scope (v1)

  • Network printers (TCP 9100)
  • Non-ESC/POS protocols (Star Line, ZPL)
  • Multi-column layout engines
  • Collaborative editing / cloud sync
  • macOS (feasible later with same stack)

---

Recommendation

Proceed. Start with a serial-USB MVP on Rust + Tauri 2, prove the DSL and preview loop, then expand transport layers. Defer Bluetooth until USB paths are stable.

See LANGUAGE-CHOICE.md for stack details and ARCHITECTURE.md for module layout.

Source
1# Feasibility and complexity assessment
2
3## Executive summary
4
5| Question | Answer |
6|----------|--------|
7| Is it feasible? | **Yes** — all required capabilities exist in mature libraries or documented protocols |
8| Overall complexity | **Medium–high** for a complete v1; **medium** if Bluetooth is deferred |
9| Biggest risk | Cross-platform raw printer I/O (USB class, serial, Bluetooth SPP) |
10| Recommended MVP scope | USB-serial printers first; add USB-printer-class and Bluetooth in v1.1 |
11
12A focused MVP is realistic for one developer in roughly **6–10 weeks**. A polished v1 with broad printer compatibility is closer to **3–4 months**.
13
14---
15
16## Requirements breakdown
17
18### 1. Cross-platform desktop app (Windows + Linux)
19
20| Aspect | Feasibility | Complexity |
21|--------|-------------|------------|
22| Single codebase, native binaries | High | Low–medium |
23| Packaged installers (.msi/.exe, .deb/AppImage) | High | Medium |
24
25Modern cross-platform desktop frameworks (Tauri, egui, Avalonia, Qt) all support Windows and Linux. Packaging is routine but needs CI and per-OS testing.
26
27### 2. Markdown-like document syntax + live preview
28
29| Aspect | Feasibility | Complexity |
30|--------|-------------|------------|
31| Custom lightweight DSL | High | Medium |
32| Live preview pane | High | Medium |
33| Width modes (auto-scale / fixed mm) | High | Low–medium |
34
35The DSL does not need full CommonMark — a small, POS-oriented grammar keeps the parser simple. Preview renders to a monospace layout matching printer dot width (e.g. 384 dots @ 58 mm, 576 dots @ 80 mm). Matching exact printer fonts is approximate in preview; exact fidelity is only guaranteed at print time.
36
37### 3. Save / load `.pos` files
38
39| Aspect | Feasibility | Complexity |
40|--------|-------------|------------|
41| JSON or TOML envelope + body text | High | Low |
42
43Trivial with serde (Rust) or equivalent. Version field supports forward-compatible evolution.
44
45### 4. Parameter tokens (`${Name}`)
46
47| Aspect | Feasibility | Complexity |
48|--------|-------------|------------|
49| Parse and collect unique names | High | Low |
50| Print-time modal with last-used values | High | Low |
51| Deduplicate same name across document | High | Low |
52| Use in text, barcodes, QR, images | High | Low–medium |
53
54Straightforward string substitution after validation. Image parameters might reference file paths or base64 — define clearly in DSL spec.
55
56### 5. Barcodes, QR codes, images
57
58| Aspect | Feasibility | Complexity |
59|--------|-------------|------------|
60| Generate ESC/POS barcode commands | High | Low |
61| Generate ESC/POS QR commands | High | Low |
62| Rasterize images to printer width | High | Medium |
63
64The [`escpos`](https://crates.io/crates/escpos) Rust crate (and similar libraries in other languages) already implements barcodes, QR, and raster graphics. Preview can use the same generation path and render bitmaps in the UI.
65
66### 6. Direct USB / Bluetooth printing (raw bytes, no spooler)
67
68| Aspect | Feasibility | Complexity |
69|--------|-------------|------------|
70| USB serial (CDC-ACM, CH340, FTDI) | **High** | Medium |
71| USB printer class (bulk OUT) | Medium | **High** |
72| Bluetooth Classic SPP | Medium | **High** |
73| Enumerate devices in UI | Medium | Medium |
74| Printer-specific quirks | Ongoing | **High** |
75
76This is the **primary technical risk**.
77
78#### How POS printers actually connect
79
80Most consumer thermal printers expose one of:
81
821. **Virtual COM port (USB-serial)** — very common; appears as `COM3` (Windows) or `/dev/ttyUSB0` / `/dev/ttyACM0` (Linux). Raw ESC/POS bytes are written to the serial port. **Easiest path.**
83
842. **USB printer class (interface 7)** — bulk transfers to endpoint; needs `libusb`/`nusb` on Linux and either WinUSB/Zadig or Windows `usbprint.sys` on Windows. The `escpos` crate’s `usbprint` feature uses the Windows kernel driver without replacing it.
85
863. **Bluetooth Classic SPP** — serial profile; paired device appears as a COM port (Windows) or `/dev/rfcomm*` (Linux). Requires platform Bluetooth APIs for discovery; connection is then serial I/O.
87
884. **Network (TCP 9100)** — common in production but **out of scope** unless added later.
89
90“No drivers” in practice means **no Windows print spooler / CUPS job** — the app opens the device directly and writes bytes. USB-serial devices often need only the generic CDC driver already present. USB-printer-class devices on Windows may still use `usbprint.sys`, which is a kernel driver but not a vendor-specific print driver.
91
92#### Compatibility reality
93
94- **MVP:** Target Epson-compatible ESC/POS over USB-serial. Covers a large share of cheap 58/80 mm printers.
95- **v1:** Add USB printer class via `nusb` / `usbprint`.
96- **v1.1:** Add Bluetooth SPP discovery and pairing UX.
97
98Expect **per-printer testing**; some devices need init sequences, code pages, or cut commands that differ slightly.
99
100---
101
102## Complexity by subsystem
103
104```
105 Effort (relative)
106Editor UI ████████░░ Medium
107Preview renderer ███████░░░ Medium
108DSL parser ██████░░░░ Medium
109File I/O ██░░░░░░░░ Low
110Parameters ███░░░░░░░ Low
111Barcode/QR/image █████░░░░░ Low–medium
112Printer discovery ███████░░░ Medium
113Raw print I/O █████████░ High
114Integration/polish ██████░░░░ Medium
115```
116
117---
118
119## Effort estimate (one experienced developer)
120
121| Phase | Scope | Duration |
122|-------|-------|----------|
123| **0 — Design** | Specs, DSL, file format | 1 week |
124| **1 — Core** | Parser, ESC/POS builder, preview, `.pos` I/O | 2–3 weeks |
125| **2 — UI** | Editor, preview split, settings, parameters dialog | 2 weeks |
126| **3 — Print MVP** | USB-serial enumeration + print | 1–2 weeks |
127| **4 — Hardening** | USB class, BT, edge cases, packaging | 2–4 weeks |
128
129**MVP (serial USB only):** ~6–8 weeks
130**Full v1 (USB + BT, packaged):** ~10–14 weeks
131
132Add 30–50% if the developer is new to Rust or ESC/POS.
133
134---
135
136## Risks and mitigations
137
138| Risk | Impact | Mitigation |
139|------|--------|------------|
140| Printer hardware diversity | Prints garbled or not at all | ESC/POS subset doc; test matrix; user-selectable code page |
141| Linux permissions (`dialout`) | Cannot open serial port | Document group membership; clear error UI |
142| Windows USB access | Admin / driver conflicts | Prefer serial-first; use `usbprint` where applicable |
143| Bluetooth pairing UX | Users cannot find printer | Defer BT; link to OS pairing instructions |
144| Preview ≠ print | User confusion | Label preview as approximate; same backend for print |
145| Image size on narrow paper | Slow print or clipped | Auto-scale to page width; warn in UI |
146
147---
148
149## Out of scope (v1)
150
151- Network printers (TCP 9100)
152- Non-ESC/POS protocols (Star Line, ZPL)
153- Multi-column layout engines
154- Collaborative editing / cloud sync
155- macOS (feasible later with same stack)
156
157---
158
159## Recommendation
160
161**Proceed.** Start with a **serial-USB MVP** on **Rust + Tauri 2**, prove the DSL and preview loop, then expand transport layers. Defer Bluetooth until USB paths are stable.
162
163See [LANGUAGE-CHOICE.md](LANGUAGE-CHOICE.md) for stack details and [ARCHITECTURE.md](ARCHITECTURE.md) for module layout.