diff --git a/README.md b/README.md index e9c3203..4f2ec4c 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,12 @@ and their exported `source_port` flags. It does not read or require sibling Use tscircuit 0.0.2745 or newer, which exports these attributes as `is_output`, `is_input`, `is_using_internal_pullup`, and `is_configured_for_i2c_sda` / `is_configured_for_i2c_scl`. Capability flags such as `isGpio` alone do not select a pin function. Connected -pins with missing or unsupported functions produce an error identifying the -MCU name/part number, physical pin numbers/labels and required TSX attributes, -without generated record IDs or a converter stack trace. Missing MCU port +pins with missing or unsupported functions produce an error. Missing-direction +errors contain one short line per pin with the component name, physical pin +number, label and problem, for example +`- U1 pin 4 (DIO11): GPIO direction is missing`. The CLI adds its standard failure +prefix; these diagnostics omit manufacturer part numbers, TSX setup instructions, +generated record IDs and converter stack traces. Missing MCU port records or traces referencing absent source ports also fail before a new SysConfig file is written; no behavior is inferred from signal names. If more than one supported MCU is present, select one with `--component U1` diff --git a/npm/README.md b/npm/README.md index c8e98c6..6089467 100644 --- a/npm/README.md +++ b/npm/README.md @@ -58,9 +58,12 @@ ti check-sysconfig ./board.circuit.tsx Use tscircuit 0.0.2745 or newer for TSX export. For supported CC2340 circuits, GPIO/I2C choices come from existing MCU `pinAttributes` exported to Circuit JSON. No separate request JSON is required -or read implicitly. Missing connected-pin functions fail with physical pin and -signal labels and the required TSX attributes, without generated record IDs -or a converter stack trace. Missing MCU port records +or read implicitly. Missing connected-pin functions fail. Missing-direction +errors contain one short line per pin with the component name, physical pin +number, label and problem, for example +`- U1 pin 4 (DIO11): GPIO direction is missing`. The CLI adds its standard failure +prefix; these diagnostics omit manufacturer part numbers, TSX setup instructions, +generated record IDs and converter stack traces. Missing MCU port records or connected source-port records also fail before a new `.syscfg` is written. Use `--component U1` when selecting between multiple MCUs. Connected 32768 Hz two-terminal crystals on MCU pins 14/15 select the external diff --git a/package.json b/package.json index 2fc22d0..2a599ee 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@types/bun": "^1.4.0", "@types/react": "^19.2.17", "bun-match-svg": "^0.0.17", - "circuit-json-to-sysconfig": "github:tscircuit/circuit-json-to-sysconfig#3da9ac4b464a84eac13615dc684da7105065c685", + "circuit-json-to-sysconfig": "github:tscircuit/circuit-json-to-sysconfig#05add591d6d678cc7457c985b08096690d1e3949", "circuit-to-svg": "0.0.410", "tscircuit": "0.0.2745", "typescript": "^5.0.0" diff --git a/scripts/test-npm-package.mjs b/scripts/test-npm-package.mjs index 26a7fc9..932a0e0 100644 --- a/scripts/test-npm-package.mjs +++ b/scripts/test-npm-package.mjs @@ -157,6 +157,7 @@ async function testCli({ command, cwd }) { name: "ENABLE", pin_number: 4, is_output: true, + is_bidirectional: true, }, ]), ); @@ -202,6 +203,7 @@ async function testCli({ command, cwd }) { name: "ENABLE", pin_number: 4, is_output: true, + is_bidirectional: true, }, { type: "source_trace", diff --git a/tests/cli/sysconfig-errors-snapshot.test.ts b/tests/cli/sysconfig-errors-snapshot.test.ts index 0b85437..3155f64 100644 --- a/tests/cli/sysconfig-errors-snapshot.test.ts +++ b/tests/cli/sysconfig-errors-snapshot.test.ts @@ -68,6 +68,7 @@ test("Circuit JSON error output names unresolved pins without IDs or a stack", ( name: "DIO11", pin_number: 4, is_gpio: true, + is_bidirectional: true, }, { type: "source_port", @@ -76,6 +77,7 @@ test("Circuit JSON error output names unresolved pins without IDs or a stack", ( name: "DIO13", pin_number: 6, is_gpio: true, + is_bidirectional: true, }, { type: "source_trace", @@ -91,11 +93,8 @@ test("Circuit JSON error output names unresolved pins without IDs or a stack", ( expect(result).toEqual({ status: 1, stdout: "", sysconfigWritten: false }); expect(stderr).toMatchInlineSnapshot(` "Failed to generate SysConfig: SysConfig conversion failed: - Unresolved CC2340 pin configuration for U1 (CC2340R52E0RGER): - - U1 pin 4 (DIO11): no GPIO direction or supported peripheral selected - - U1 pin 6 (DIO13): no GPIO direction or supported peripheral selected - Update U1's TSX pinAttributes with the intended function for each listed pin: set exactly one of isInput: true or isOutput: true for GPIO, or activeCapability: "i2c_sda" / "i2c_scl" for I2C. - Datasheet capabilities such as isGpio describe what a pin supports; they do not select how this board uses it. + - U1 pin 4 (DIO11): GPIO direction is missing + - U1 pin 6 (DIO13): GPIO direction is missing " `); }); @@ -108,8 +107,8 @@ test("TSX error output explains board choices without a request file or stack", @@ -120,11 +119,8 @@ test("TSX error output explains board choices without a request file or stack", expect(result).toEqual({ status: 1, stdout: "", sysconfigWritten: false }); expect(stderr).toMatchInlineSnapshot(` "Failed to generate SysConfig: SysConfig conversion failed: - Unresolved CC2340 pin configuration for U1 (CC2340R52E0RGER): - - U1 pin 4 (DIO11): no GPIO direction or supported peripheral selected - - U1 pin 6 (DIO13): no GPIO direction or supported peripheral selected - Update U1's TSX pinAttributes with the intended function for each listed pin: set exactly one of isInput: true or isOutput: true for GPIO, or activeCapability: "i2c_sda" / "i2c_scl" for I2C. - Datasheet capabilities such as isGpio describe what a pin supports; they do not select how this board uses it. + - U1 pin 4 (DIO11): GPIO direction is missing + - U1 pin 6 (DIO13): GPIO direction is missing " `); }); diff --git a/tests/cli/sysconfig-from-circuit.test.mjs b/tests/cli/sysconfig-from-circuit.test.mjs index 7f73a92..72e25bd 100644 --- a/tests/cli/sysconfig-from-circuit.test.mjs +++ b/tests/cli/sysconfig-from-circuit.test.mjs @@ -102,14 +102,15 @@ test("connected pins with missing roles fail without a request-file suggestion", }); writeFileSync(join(f.cwd, "board.circuit.json"), JSON.stringify(incomplete)); assert.equal(await f.run(["generate-sysconfig", "board.circuit.json"]), 1); - assert.match(f.stderr.join("\n"), /U1.*CC2340R52E0RGER/); - assert.match(f.stderr.join("\n"), /pin 4[\s\S]*pinAttributes/); + assert.match( + f.stderr.join("\n"), + /- U1 pin 4 \(ENABLE\): GPIO direction is missing/, + ); assert.doesNotMatch( f.stderr.join("\n"), /request file is missing|source_component_id|source_port_id|\bat \S+|throw new Error|convert\.mjs:\d/, ); assert.doesNotMatch(f.stderr.join("\n"), /\(mcu,|\(output,/); - assert.match(f.stderr.join("\n"), /isInput: true or isOutput: true/); assert.equal(existsSync(join(f.cwd, "board.syscfg")), false); }); @@ -183,8 +184,8 @@ test("TSX pinAttributes export selected GPIO roles without a request file", asyn );`, @@ -200,6 +201,11 @@ test("TSX pinAttributes export selected GPIO roles without a request file", asyn const exported = JSON.parse( readFileSync(join(f.cwd, "dist/board/circuit.json"), "utf8"), ); + assert.ok( + exported + .filter((port) => port.type === "source_port") + .every((port) => port.is_bidirectional === true), + ); assert.equal( exported.find( (port) => port.type === "source_port" && port.pin_number === 4, @@ -231,10 +237,8 @@ test("a TSX pin failure prints actionable labels without the converter stack", a ); assert.equal(await f.run(["generate-sysconfig", "board.circuit.tsx"]), 1); const message = f.stderr.join("\n"); - assert.match(message, /U1 \(CC2340R52E0RGER\)/); - assert.match(message, /U1 pin 4 \(DIO11\)/); - assert.match(message, /U1 pin 6 \(DIO13\)/); - assert.match(message, /Update U1's TSX pinAttributes/); + assert.match(message, /- U1 pin 4 \(DIO11\): GPIO direction is missing/); + assert.match(message, /- U1 pin 6 \(DIO13\): GPIO direction is missing/); assert.doesNotMatch( message, /source_component_\d|source_port_\d|\bat \S+|throw new Error/, diff --git a/tests/cli/sysconfig.test.mjs b/tests/cli/sysconfig.test.mjs index fc525f7..3ebc514 100644 --- a/tests/cli/sysconfig.test.mjs +++ b/tests/cli/sysconfig.test.mjs @@ -321,8 +321,10 @@ test("missing pin functions are reported without requiring a firmware request fi assert.equal(await f.run(["generate-sysconfig", "index.circuit.tsx"]), 1); assert.ok(existsSync(join(f.cwd, "dist/index/circuit.json"))); const message = f.stderr.join("\n"); - assert.match(message, /Unresolved CC2340 pin configuration/); - assert.match(message, /pinAttributes/); + assert.match( + message, + /- U1_MCU pin 9 \(DISP_PWR_N\): GPIO direction is missing/, + ); assert.doesNotMatch( message, /source_component_\d|source_port_\d|throw new Error|\bat \S+/,