BlueGit

timfa posprint

Files

posprint / docs / FEASIBILITY.md

FEASIBILITY.md

FEASIBILITY.md 7.1 KiB Download Raw

Feasibility and complexity assessment

> Status: MVP (v0.1.0) implemented — Rust + egui, USB-serial printing, 20 unit tests. This document retains the original feasibility analysis; see ARCHITECTURE.md for what is built today.

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 (done); USB-printer-class and Bluetooth later

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

ESC/POS barcode, QR, and raster image commands are implemented in src/escpos.rs (in-tree). Preview uses text placeholders for barcodes/QR/images.

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; not implemented. Would need nusb or Windows usbprint.sys.

3. Bluetooth Classic SPP — not implemented; deferred.

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 (done): Epson-compatible ESC/POS over USB-serial at 9600 baud.
  • Future: USB printer class, Bluetooth SPP.

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 (current release)

  • Bluetooth printing
  • USB printer class (non-serial)
  • 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

MVP delivered. Next increments: USB printer class, baud settings, persisted parameters, hardware test matrix. Bluetooth only if explicitly needed.

See LANGUAGE-CHOICE.md and ARCHITECTURE.md.

Source
1# Feasibility and complexity assessment
2
3> **Status:** MVP (v0.1.0) **implemented** — Rust + egui, USB-serial printing, 20 unit tests. This document retains the original feasibility analysis; see [ARCHITECTURE.md](ARCHITECTURE.md) for what is built today.
4
5## Executive summary
6
7| Question | Answer |
8|----------|--------|
9| Is it feasible? | **Yes** — all required capabilities exist in mature libraries or documented protocols |
10| Overall complexity | **Medium–high** for a complete v1; **medium** if Bluetooth is deferred |
11| Biggest risk | Cross-platform raw printer I/O (USB class, serial, Bluetooth SPP) |
12| Recommended MVP scope | USB-serial printers first (**done**); USB-printer-class and Bluetooth later |
13
14A 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**.
15
16---
17
18## Requirements breakdown
19
20### 1. Cross-platform desktop app (Windows + Linux)
21
22| Aspect | Feasibility | Complexity |
23|--------|-------------|------------|
24| Single codebase, native binaries | High | Low–medium |
25| Packaged installers (.msi/.exe, .deb/AppImage) | High | Medium |
26
27Modern cross-platform desktop frameworks (Tauri, egui, Avalonia, Qt) all support Windows and Linux. Packaging is routine but needs CI and per-OS testing.
28
29### 2. Markdown-like document syntax + live preview
30
31| Aspect | Feasibility | Complexity |
32|--------|-------------|------------|
33| Custom lightweight DSL | High | Medium |
34| Live preview pane | High | Medium |
35| Width modes (auto-scale / fixed mm) | High | Low–medium |
36
37The 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.
38
39### 3. Save / load `.pos` files
40
41| Aspect | Feasibility | Complexity |
42|--------|-------------|------------|
43| JSON or TOML envelope + body text | High | Low |
44
45Trivial with serde (Rust) or equivalent. Version field supports forward-compatible evolution.
46
47### 4. Parameter tokens (`${Name}`)
48
49| Aspect | Feasibility | Complexity |
50|--------|-------------|------------|
51| Parse and collect unique names | High | Low |
52| Print-time modal with last-used values | High | Low |
53| Deduplicate same name across document | High | Low |
54| Use in text, barcodes, QR, images | High | Low–medium |
55
56Straightforward string substitution after validation. Image parameters might reference file paths or base64 — define clearly in DSL spec.
57
58### 5. Barcodes, QR codes, images
59
60| Aspect | Feasibility | Complexity |
61|--------|-------------|------------|
62| Generate ESC/POS barcode commands | High | Low |
63| Generate ESC/POS QR commands | High | Low |
64| Rasterize images to printer width | High | Medium |
65
66ESC/POS barcode, QR, and raster image commands are implemented in `src/escpos.rs` (in-tree). Preview uses text placeholders for barcodes/QR/images.
67
68### 6. Direct USB / Bluetooth printing (raw bytes, no spooler)
69
70| Aspect | Feasibility | Complexity |
71|--------|-------------|------------|
72| USB serial (CDC-ACM, CH340, FTDI) | **High** | Medium |
73| USB printer class (bulk OUT) | Medium | **High** |
74| Bluetooth Classic SPP | Medium | **High** |
75| Enumerate devices in UI | Medium | Medium |
76| Printer-specific quirks | Ongoing | **High** |
77
78This is the **primary technical risk**.
79
80#### How POS printers actually connect
81
82Most consumer thermal printers expose one of:
83
841. **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.**
85
862. **USB printer class (interface 7)** — bulk transfers; **not implemented**. Would need `nusb` or Windows `usbprint.sys`.
87
883. **Bluetooth Classic SPP** — **not implemented**; deferred.
89
904. **Network (TCP 9100)** — common in production but **out of scope** unless added later.
91
92“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.
93
94#### Compatibility reality
95
96- **MVP (done):** Epson-compatible ESC/POS over USB-serial at 9600 baud.
97- **Future:** USB printer class, Bluetooth SPP.
98
99Expect **per-printer testing**; some devices need init sequences, code pages, or cut commands that differ slightly.
100
101---
102
103## Complexity by subsystem
104
105```
106 Effort (relative)
107Editor UI ████████░░ Medium
108Preview renderer ███████░░░ Medium
109DSL parser ██████░░░░ Medium
110File I/O ██░░░░░░░░ Low
111Parameters ███░░░░░░░ Low
112Barcode/QR/image █████░░░░░ Low–medium
113Printer discovery ███████░░░ Medium
114Raw print I/O █████████░ High
115Integration/polish ██████░░░░ Medium
116```
117
118---
119
120## Effort estimate (one experienced developer)
121
122| Phase | Scope | Duration |
123|-------|-------|----------|
124| **0 — Design** | Specs, DSL, file format | 1 week |
125| **1 — Core** | Parser, ESC/POS builder, preview, `.pos` I/O | 2–3 weeks |
126| **2 — UI** | Editor, preview split, settings, parameters dialog | 2 weeks |
127| **3 — Print MVP** | USB-serial enumeration + print | 1–2 weeks |
128| **4 — Hardening** | USB class, BT, edge cases, packaging | 2–4 weeks |
129
130**MVP (serial USB only):** ~6–8 weeks
131**Full v1 (USB + BT, packaged):** ~10–14 weeks
132
133Add 30–50% if the developer is new to Rust or ESC/POS.
134
135---
136
137## Risks and mitigations
138
139| Risk | Impact | Mitigation |
140|------|--------|------------|
141| Printer hardware diversity | Prints garbled or not at all | ESC/POS subset doc; test matrix; user-selectable code page |
142| Linux permissions (`dialout`) | Cannot open serial port | Document group membership; clear error UI |
143| Windows USB access | Admin / driver conflicts | Prefer serial-first; use `usbprint` where applicable |
144| Bluetooth pairing UX | Users cannot find printer | Defer BT; link to OS pairing instructions |
145| Preview ≠ print | User confusion | Label preview as approximate; same backend for print |
146| Image size on narrow paper | Slow print or clipped | Auto-scale to page width; warn in UI |
147
148---
149
150## Out of scope (current release)
151
152- Bluetooth printing
153- USB printer class (non-serial)
154- Network printers (TCP 9100)
155- Non-ESC/POS protocols (Star Line, ZPL)
156- Multi-column layout engines
157- Collaborative editing / cloud sync
158- macOS (feasible later with same stack)
159
160---
161
162## Recommendation
163
164**MVP delivered.** Next increments: USB printer class, baud settings, persisted parameters, hardware test matrix. Bluetooth only if explicitly needed.
165
166See [LANGUAGE-CHOICE.md](LANGUAGE-CHOICE.md) and [ARCHITECTURE.md](ARCHITECTURE.md).