fix(pcb): read board info and pads from the board KiCad holds - #207
fix(pcb): read board info and pads from the board KiCad holds#207pauliuszaleckas wants to merge 1 commit into
Conversation
The PCB-side entries are all fixed on this branch: Board readers parsed the file while board writers used IPC. Fixed for get_board_info and get_component_pads by the board-reader commit below, now up as mixelpixx#207. Records the wrong-board reads found on the way, the two things the live path deliberately does not do, and the readers left on the file — including why get_layer_list waits for mixelpixx#153. There was no way to resize or replace a board outline. Fixed by the delete_graphics commit below. Records the deliberate choices (no filter means no deletion, top-level graphics only, reference images excluded, IPC rejection fails closed) and the limitation it inherits: layer_enum_to_name names 15 layers, so an IPC-path filter on any other layer matches nothing while the file path matches it. The IPC socket path was not auto-detected. Fixed by the socket auto-detection commit below; mixelpixx#18 and mixelpixx#39 are the closed issues the friction produced. Records why a candidate counts only when something is listening, why detecting nothing leaves the address empty, and the limitation the fix keeps: detection runs once at startup, so a KiCad opened later is missed. The rest are the schematic side, found redrawing that same board from an empty file through the MCP tools. Only the junction entry is fixed, by the commit below. The tracker has been searched and each status line says what it found: the junction entry was filed as mixelpixx#201 while this file was being written, its move-and-prune half is mixelpixx#120, the sheet-size entry is most of the way covered by mixelpixx#175, and the remaining four are unreported. Each carries the commit that introduced it, blamed on the line and read against the surrounding diff where a reformat made git blame misleading — the ERC library-match entry points at 921fa92 and is really a50c96a. The junction, power-designator, netlist-summary and orphan-item entries date from the initial public release; all of them predate this branch. The junction entry was the cheapest to close: the dedupe it needed already existed in tree, added by 1866129 and 620da07, and had never reached the T loop in add_wire and batch_add_wire. Its status now records the third call site the report missed, connect_to_net, and why the string-path helper was not reused. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The PCB-side entries are all fixed on this branch: Board readers parsed the file while board writers used IPC. Fixed for get_board_info and get_component_pads by the board-reader commit below, now up as mixelpixx#207. Records the wrong-board reads found on the way, the two things the live path deliberately does not do, and the readers left on the file — including why get_layer_list waits for mixelpixx#153. There was no way to resize or replace a board outline. Fixed by the delete_graphics commit below. Records the deliberate choices (no filter means no deletion, top-level graphics only, reference images excluded, IPC rejection fails closed) and the limitation it inherits: layer_enum_to_name names 15 layers, so an IPC-path filter on any other layer matches nothing while the file path matches it. The IPC socket path was not auto-detected. Fixed by the socket auto-detection commit below; mixelpixx#18 and mixelpixx#39 are the closed issues the friction produced. Records why a candidate counts only when something is listening, why detecting nothing leaves the address empty, and the limitation the fix keeps: detection runs once at startup, so a KiCad opened later is missed. The rest are the schematic side, found redrawing that same board from an empty file through the MCP tools. The junction and power-designator entries are fixed, by the two commits below. The tracker has been searched and each status line says what it found: the junction entry was filed as mixelpixx#201 while this file was being written, its move-and-prune half is mixelpixx#120, the sheet-size entry is most of the way covered by mixelpixx#175, and the remaining four are unreported. Each carries the commit that introduced it, blamed on the line and read against the surrounding diff where a reformat made git blame misleading — the ERC library-match entry points at 921fa92 and is really a50c96a. The junction, power-designator, netlist-summary and orphan-item entries date from the initial public release; all of them predate this branch. The junction entry was the cheapest to close: the dedupe it needed already existed in tree, added by 1866129 and 620da07, and had never reached the T loop in add_wire and batch_add_wire. Its status now records the third call site the report missed, connect_to_net, and why the string-path helper was not reused. The power-designator entry went the same way: add_power_symbol numbered by counting, so a deletion re-issued a live #PWR reference. It now takes the lowest free number. Its status records why lowest-free rather than max+1, and that an instances-path reference left stale by mixelpixx#157 stays invisible to the scan. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Still held per your own stack order — you asked for this to land after the two This got more valuable than its draft status suggests. #215 landed Three things I would like before it lands:
For (2), the recipe I have been using: strip footprints from a copy of a demo No rush from my side; v0.4.0 is going out without it and that is fine. |
402710c to
b0632bf
Compare
|
Rebased onto (1) (2) The
(3) Splitting the Also folded in on rebase: Gate is green — fmt, clippy, doctests, workspace tests. The three |
b0632bf to
9f44f35
Compare
The writers in these toolsets act on the live board over IPC while get_board_info and get_component_pads parsed the file, so a session with unsaved edits got contradictory answers: get_component_list reported 25 components while get_board_info reported layer_count 0 and net_count 0 from the empty stub on disk, and pad positions were unreadable until the user pressed Ctrl+S. Both now try IPC first and fall back to the file, reporting which they used as "source" the way add_board_outline already does. get_pad_position carries the source through. Two deliberate non-behaviours. Paper size is still read from the file on both paths — KiCad's API exposes no page settings, and the tool description says so. A footprint KiCad does not have is an error rather than a file answer, because falling back would report a part the user deleted but has not saved. Every _in-less client method resolves its document as "the first open one", so with two boards open a read answered about the wrong one -- ensure_board_is_active only checks the requested board is open somewhere. The new readers address the document find_open_board matched, and get_board_extents was switched to do the same. Pads come out of the API in absolute board coordinates (see transform), so the live path applies none of the anchor/rotation math the file path needs. The copper layer count comes from BoardEnabledLayersResponse's own field rather than a tally of layer names ending in .Cu. The two agree on an ordinary stackup, which is the kind of agreement that stops holding on one nobody tried. KiCad answering with the footprint but no pads is refused whenever the saved file gives that part pads. A pad-less footprint is legal, so zero is not wrong by itself, but zero also reads as a plausible answer rather than a failure — and that is the shape an unread response would take. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
9f44f35 to
af5eb5a
Compare
The PCB-side entries are all fixed on this branch: Board readers parsed the file while board writers used IPC. Fixed for get_board_info and get_component_pads by the board-reader commit below, now up as mixelpixx#207. Records the wrong-board reads found on the way, the two things the live path deliberately does not do, and the readers left on the file — including why get_layer_list waits for mixelpixx#153. There was no way to resize or replace a board outline. Fixed by the delete_graphics commit below. Records the deliberate choices (no filter means no deletion, top-level graphics only, reference images excluded, IPC rejection fails closed) and the limitation it inherits: layer_enum_to_name names 15 layers, so an IPC-path filter on any other layer matches nothing while the file path matches it. The IPC socket path was not auto-detected. Fixed by the socket auto-detection commit below; mixelpixx#18 and mixelpixx#39 are the closed issues the friction produced. Records why a candidate counts only when something is listening, why detecting nothing leaves the address empty, and the limitation the fix keeps: detection runs once at startup, so a KiCad opened later is missed. The rest are the schematic side, found redrawing that same board from an empty file through the MCP tools. The junction, wire-delete and power-designator entries were fixed here and have merged upstream as mixelpixx#212, mixelpixx#214 and mixelpixx#213, so their entries are gone and the rest renumbered. Of the four left, the ERC library-match entry is fixed: upstream 94471f8 had already stopped the symbol writer emitting the "~" placeholder a day after the entry was written, and the create_symbol commit below adds the datasheet argument that was the other half. The tracker has been searched and each status line says what it found: the sheet-size entry is most of the way covered by the merged mixelpixx#175, mixelpixx#226 asks the opposite question about a different site, and the remaining entries are unreported. Each carries the commit that introduced it, blamed on the line and read against the surrounding diff where a reformat made git blame misleading — the ERC library-match entry points at 921fa92 and is really a50c96a. The netlist-summary and orphan-item entries date from the initial public release; both predate this branch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The PCB-side entries are all fixed on this branch: Board readers parsed the file while board writers used IPC. Fixed for get_board_info and get_component_pads by the board-reader commit below, now up as mixelpixx#207. Records the wrong-board reads found on the way, the two things the live path deliberately does not do, and the readers left on the file — including why get_layer_list waits for mixelpixx#153. There was no way to resize or replace a board outline. Fixed by the delete_graphics commit below. Records the deliberate choices (no filter means no deletion, top-level graphics only, reference images excluded, IPC rejection fails closed) and the limitation it inherits: layer_enum_to_name names 15 layers, so an IPC-path filter on any other layer matches nothing while the file path matches it. The IPC socket path was not auto-detected. Fixed by the socket auto-detection commit below; mixelpixx#18 and mixelpixx#39 are the closed issues the friction produced. Records why a candidate counts only when something is listening, why detecting nothing leaves the address empty, and the limitation the fix keeps: detection runs once at startup, so a KiCad opened later is missed. The rest are the schematic side, found redrawing that same board from an empty file through the MCP tools. The junction, wire-delete and power-designator entries were fixed here and have merged upstream as mixelpixx#212, mixelpixx#214 and mixelpixx#213, so their entries are gone and the rest renumbered. Of the four left, the ERC library-match entry is fixed: upstream 94471f8 had already stopped the symbol writer emitting the "~" placeholder a day after the entry was written, and the create_symbol commit below adds the datasheet argument that was the other half. The tracker has been searched and each status line says what it found: the sheet-size entry is most of the way covered by the merged mixelpixx#175, mixelpixx#226 asks the opposite question about a different site, and the remaining entries are unreported. Each carries the commit that introduced it, blamed on the line and read against the surrounding diff where a reformat made git blame misleading — the ERC library-match entry points at 921fa92 and is really a50c96a. The netlist-summary and orphan-item entries date from the initial public release; both predate this branch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The writers in these toolsets act on the live board over IPC while
get_board_infoandget_component_padsparsed the file, so a session with unsaved edits gave contradictoryanswers about the same board:
Pad positions were simply unreadable until the user pressed Ctrl+S —
place_componenthad put the footprint in KiCad, and nothing had written it to the file yet. Since #215
landed,
update_pcb_from_schematicstages footprints into the board KiCad holds, so"did the pads land where I expect?" is now a question the file cannot answer at all
until a save.
Both readers now try IPC first and fall back to the file, reporting which one answered
as
source, the wayadd_board_outlinealready does.get_pad_positioncarries thatsourcethrough.Where the numbers come from
copper_layer_countisBoardEnabledLayersResponse's own field, not a tally of layernames ending in
.Cu. The two agree on an ordinary stackup, which is exactly the kind ofagreement that stops holding on one nobody tried.
get_layers_indelegates to a newget_enabled_layers_inreturningIpcEnabledLayers { copper_layer_count, layers }; theexisting signatures are unchanged.
Pads come out of the API in absolute board coordinates (see
transform), so the livepath applies none of the anchor/rotation math the file path needs.
pad_atin the mockpins that down.
Three deliberate non-behaviours
settings; the tool description says so.
would report a part the user deleted but has not saved — the exact failure this PR
exists to remove, pointing the other way.
A pad-less footprint is legal — a logo, a mounting graphic — so zero is not wrong by
itself. But zero also reads as a plausible answer rather than a failure, and it is the
shape an unread response would take, so it stands only when the saved file does not
give that part pads.
Reading the board that was asked for
Every
_in-less client method resolves its document as "the first open one", whileensure_board_is_activeonly checks that the requested board is open somewhere. Withtwo boards open, a read could therefore answer about the other one. The new readers
address the document
find_open_boardmatched.get_board_extentsis switched to do thesame — four lines, independent of the rest of this PR, and easy to lift out if you would
rather take it separately.
Testing
cargo fmt --all -- --check,cargo clippy --workspace --locked -- -D warnings,cargo test --workspace --locked --docand the workspace test suite all pass. Threeupdate_symbols_from_librarytests fail on my machine both with and without this branch— pre-existing on
main, unrelated.New tests, each against a mock KiCad holding a board that differs from the file on disk:
derivation would have got wrong (27 layers, ids 3..26 all
*.Cu, so a name tally says24 where the response says 6), and an offline session still reads the file;
file, an empty live pad list is refused when the file has pads and accepted when it
does not, pads fall back to the file when KiCad is unreachable, and a pad position
carries its source;
absent from the live board reads as
None, and pad reads target the named board amongseveral open.
Not live-verified: which shape KiCad returns when it has the footprint but no pads for
us. There is no KiCad here to drive, and the guard above is written so that either shape
is safe — a misread response disagrees with the file and errors, a genuinely pad-less
part agrees with it and reads as zero.
🤖 Generated with Claude Code