fix: handle non-numeric pin labels and (rotate N) modifier in DSN parser - #527
Open
singularitycurse26-svg wants to merge 1 commit into
Open
singularitycurse26-svg wants to merge 1 commit into
singularitycurse26-svg wants to merge 1 commit into
Conversation
Three root-cause fixes for Smoothie Board DSN conversion: 1. getPinNum: Skip (rotate N) List modifier to find actual pin number - Pins like (pin padstack (rotate 90) A 2000 0) had 'rotate' read as the pin number instead of 'A' 2. processPin: Start coordinate parsing after the pin number, accounting for the (rotate N) modifier that shifts the pin number position - Without this fix, coordinates were read from the wrong index 3. convert-dsn-pcb-components: Don't force Number() on non-numeric pin labels (A, C, +, -, GND1, etc.) — use undefined for pin_number instead of NaN, keeping the label in the name field 4. convert-padstacks-to-smtpads: Use pin.pin_number directly in IDs instead of Number(pin.pin_number) - 1 which produced NaN-1 Before: 456 NaN pin_numbers on Smoothie Board After: 0 NaN pin_numbers Closes tscircuit#54 /claim tscircuit#54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three root-cause bugs that prevented Smoothie Board DSN from converting to Circuit JSON correctly.
Root Causes
1.
getPinNum—(rotate N)modifier misread as pin numberPins like
(pin padstack (rotate 90) A 2000 0)had"rotate"read as the pin number instead of"A". The function now detects(rotate ...)List modifiers and skips to the next node.2.
processPin— Coordinate parsing started at wrong indexWhen a
(rotate N)modifier was present, coordinates started at index 4, not 3. The old code read the pin label as a coordinate, causing parse failures.3.
convert-dsn-pcb-components—Number()coercion produced NaNNon-numeric pin labels (
A,C,+,-,GND1, etc.) were forced throughNumber(), producingNaNforsource_port.pin_number. Now usesundefinedfor non-numeric labels, keeping the label in thenamefield.4.
convert-padstacks-to-smtpads—Number(pin.pin_number) - 1produced NaNSMT pad IDs used
Number(pin.pin_number) - 1which producedNaN - 1 = NaNfor non-numeric pins. Now usespin.pin_numberdirectly in the ID string.Before/After
Tests
tests/repros/smoothie-pin-labels.test.ts— Tests non-numeric pin labels,(rotate 90)modifier parsing, and NaN-free output on Smoothie Board reproCloses #54
/claim #54