Skip to content

Command mode: read the config at startup, show it in the header, edit it with n - #10

Merged
shuckc merged 4 commits into
mainfrom
cmd-mode
Nov 9, 2026
Merged

shuckc merged 4 commits into
mainfrom
cmd-mode

Conversation

@shuckc

@shuckc shuckc commented Nov 9, 2026

Copy link
Copy Markdown
Member

Reads the machine's command set and NC Code preferences at connect, shows the command set in the header, and adds an n dialog to change them.

What the machine config is

The 6-byte GET 0x3106 / SET 0x3107 struct carries the command set and, from VPanel's "NC Code setting" page (FUN_00404ff0 / FUN_00405040), three NC Code preferences. Each byte is the MFC radio index of a VPanel control:

Byte Meaning Values
1 command set RML-1 (0), NC Code (1), Auto (2)
2 decimal-point method Conventional (0), Calculator [All] (1), [F] (2), [IJKRXYZA] (3)
3 tool-diameter offset type Type A (0), Type B (1)
4 optional block Enabled (0), Disabled (1)

Bytes 0 and 5 are never edited by VPanel and are round-tripped. VPanel writes only when something changed, and enables the NC Code page only for the NC Code and automatic command sets.

Changes

  • machine: MachineConfig decodes the struct. It is read at connect and logged in full at startup (Machine config: command set …, tool-dia offset paths …, decimal point …, optional block … [00 01 00 00 00 05]). write_config() changes any of the fields with one validated read-modify-write, waits for the ack and reads back to verify. set_command_set() now delegates to it, and the unused MDX40A.CMDSET_* class attributes are gone (the constants are module-level).
  • tui: the header shows RML-1 mode, NC mode or Auto-mode. n opens a Command Mode dialog (command set plus Tool-dia offset paths Type A/B, decimal point, optional block): ↑↓ navigate, ↵ apply, Space select, Esc close. The NC Code preferences are locked unless the command set is NC Code or automatic, as in VPanel, and n is refused while a job is loaded. Changes are applied with a single write.
  • The Z-probe dialog now uses the cached command set instead of reading it each time it opens, and also warns that VPanel hides User in NC Code mode.
  • docs: a "Machine config struct" section in usb-protocol.md, notes in sending-nc-code.md, and the n key in the README.

Test plan

  • pytest -q: 206 passed, 1 skipped
  • tests/test_machine_config.py (exact bytes written, only the edited bytes change, no write when unchanged, validation, failed read-back, the startup banner) and tests/test_cmd_mode.py (dialog flow, locked preferences, one write per apply, no write on Esc)
  • ruff check on the test files touched
  • Reading and writing these values was tested on a real MDX-40A (by the author)

🤖 Generated with Claude Code

shuckc and others added 4 commits November 9, 2026 10:55
… one config write

The 6-byte GET 0x3106 / SET 0x3107 struct holds the command set (byte 1) and, from
the VPanel "NC Code setting" page (FUN_00404ff0 / FUN_00405040), the decimal-point
method (byte 2), tool-diameter offset type (byte 3) and optional block (byte 4);
bytes 0 and 5 are only round-tripped. MachineConfig decodes it, write_config()
changes any of the fields with one read-modify-write (validated, acked and read
back), and the config is cached at connect. set_command_set() now delegates to it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ialog

The header shows "RML-1 mode", "NC mode" or "Auto-mode" from the config read at
connect. n opens a dialog for the command set plus the three NC Code preferences
(tool-diameter offset type, decimal-point method, optional block): arrows move,
Space selects, Enter applies everything changed with one config write, Esc cancels.
The NC Code preferences are locked unless the command set is NC Code or automatic,
as in VPanel, and n is refused while a job is loaded.

The Z-probe dialog now uses the cached command set instead of reading it on open, and
also warns that VPanel hides User in NC Code mode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t the whole config at startup

The dialog group is "Tool-dia offset paths" with options "Type A" and "Type B", and the
option column moves right to fit it. The startup banner prints every decoded field of the
6-byte machine config plus the raw bytes, e.g.
  Machine config: command set NC Code, tool-dia offset paths Type A, decimal point
  Conventional Method, optional block Enabled [00 01 00 00 00 05]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@shuckc
shuckc merged commit ed6105c into main Nov 9, 2026
1 check passed
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