Skip to content

v0.3.17

Choose a tag to compare

@ovidiubistrian ovidiubistrian released this 24 Apr 12:58
· 3 commits to main since this release
feat(datecs): FP-55/FP-700 dialect probe + switcher + unit tests

Today's field log had open_fiscal NAK even after the password fix — the
frame is syntactically perfect (LEN=14, CMD=0x0030, SUM-BCC correct,
TAB separators) but the DP-25 still rejects it. The remaining likely
cause is a dialect mismatch: this specific unit may speak FP-700
(nibble+0x30, XOR BCC, 1-byte CMD) rather than the modern FP-55
(nibble+0x20, SUM BCC, 4-byte CMD) we default to.

Changes:

1. bridge/probe.py (new) — exercises cmd=0x4A (STATUS) in both
   dialects against the configured COM port and reports which (if any)
   the printer ACKs. STATUS is safe — read-only, prints nothing.

2. main.py: new `--probe-printer` CLI. Runs the probe, prints a human-
   readable report, exits 0 when either dialect responds, 2 otherwise.

3. gui.py: new "🔧 Test comunicare" button wired to the same probe +
   Protocol dialect dropdown (fp55 / fp700) in the Setări dialog, so
   switching does not need a new build.

4. config.py: new `protocol_variant: "fp55"` field, persisted via
   config.json.

5. ws_client.py: when the user set fp700 locally, all four wire knobs
   (protocol/encoding_offset/bcc_algo/cmd_width) are force-set via
   _FP700_PARAMS and then kept local-wins so the server's fp55 push
   doesn't clobber them.

6. datecs_fp.py: log line on each send now includes the active dialect
   + offset + bcc + cmd_width so it's obvious from the log what wire
   protocol is actually going on the port.

7. tests/test_datecs_fp.py (new, 13 tests passing): pins
   _encode_4nibbles, _calc_bcc (SUM/XOR), _build_frame end-to-end for
   both FP-55 and FP-700, SEQ increment + wrap, and that open_fiscal
   uses TAB (never comma). Includes the exact BCC the real NAK'd
   frame had (20 21 2d 2c for "1\t0000\t1") as a regression guard.

How the user applies this:

   a. Install v0.3.17.
   b. In GUI click "🔧 Test comunicare" — pops a dialog with which
      dialect the printer speaks.
   c. If fp700 recommended → Setări → Protocol dialect → fp700 →
      Save. Test print.
   d. CLI equivalent: `360booking-bridge.exe --probe-printer`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>