dsh-stm32 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +567 -516
- package/README_EN.md +544 -510
- package/client/client.js +7033 -682
- package/docs/reading-guide.md +921 -859
- package/lib/client.js +7033 -682
- package/lib/commands/register.js +2 -0
- package/lib/data/firmware-packages.js +35 -0
- package/lib/data/firmware-pins.js +7 -0
- package/lib/data/install-guides.js +110 -0
- package/lib/data/ioc-presets.js +118 -0
- package/lib/engine/artifacts.js +123 -0
- package/lib/engine/breakpoint-hits.js +73 -0
- package/lib/engine/build.js +161 -5
- package/lib/engine/channel-tap.js +227 -0
- package/lib/engine/channels.js +48 -0
- package/lib/engine/clocks.js +192 -0
- package/lib/engine/datasheet/auto.js +74 -0
- package/lib/engine/datasheet/digest.js +74 -0
- package/lib/engine/datasheet/lcsc.js +60 -0
- package/lib/engine/datasheet/pinout.js +119 -0
- package/lib/engine/datasheet/price.js +152 -0
- package/lib/engine/datasheet/search.js +147 -0
- package/lib/engine/datasheet/store.js +371 -0
- package/lib/engine/debug-session.js +48 -2
- package/lib/engine/ecad/autobuild.js +156 -0
- package/lib/engine/ecad/bom.js +238 -0
- package/lib/engine/ecad/brief.js +205 -0
- package/lib/engine/ecad/checks.js +239 -0
- package/lib/engine/ecad/design.js +177 -0
- package/lib/engine/ecad/dfm.js +314 -0
- package/lib/engine/ecad/easyeda.js +454 -0
- package/lib/engine/ecad/fabrication.js +104 -0
- package/lib/engine/ecad/gen/footprint.js +159 -0
- package/lib/engine/ecad/gen/symbol.js +103 -0
- package/lib/engine/ecad/import.js +372 -0
- package/lib/engine/ecad/jlcpcb.js +141 -0
- package/lib/engine/ecad/libs.js +316 -0
- package/lib/engine/ecad/models3d.js +89 -0
- package/lib/engine/ecad/netgate.js +286 -0
- package/lib/engine/ecad/normalize.js +182 -0
- package/lib/engine/ecad/package.js +126 -0
- package/lib/engine/ecad/padmerge.js +128 -0
- package/lib/engine/ecad/padprecheck.js +123 -0
- package/lib/engine/ecad/part-import.js +257 -0
- package/lib/engine/ecad/pcb/apply.js +53 -0
- package/lib/engine/ecad/pcb/emc-deep.js +396 -0
- package/lib/engine/ecad/pcb/emc.js +275 -0
- package/lib/engine/ecad/pcb/geometry.js +63 -0
- package/lib/engine/ecad/pcb/gerber.js +499 -0
- package/lib/engine/ecad/pcb/hand-sync.js +242 -0
- package/lib/engine/ecad/pcb/impedance.js +119 -0
- package/lib/engine/ecad/pcb/ipc-open.js +78 -0
- package/lib/engine/ecad/pcb/ipc-script.js +276 -0
- package/lib/engine/ecad/pcb/ipc.js +129 -0
- package/lib/engine/ecad/pcb/krt.js +182 -0
- package/lib/engine/ecad/pcb/links.js +393 -0
- package/lib/engine/ecad/pcb/mech.js +201 -0
- package/lib/engine/ecad/pcb/model-fix.js +178 -0
- package/lib/engine/ecad/pcb/netlist.js +146 -0
- package/lib/engine/ecad/pcb/pcb-svg.js +199 -0
- package/lib/engine/ecad/pcb/placement.js +140 -0
- package/lib/engine/ecad/pcb/power.js +203 -0
- package/lib/engine/ecad/pcb/render3d.js +208 -0
- package/lib/engine/ecad/pcb/route.js +167 -0
- package/lib/engine/ecad/pcb/router.js +469 -0
- package/lib/engine/ecad/pcb/rules.js +122 -0
- package/lib/engine/ecad/pcb/scene.js +513 -0
- package/lib/engine/ecad/pcb/stackup.js +154 -0
- package/lib/engine/ecad/pcb/swap.js +222 -0
- package/lib/engine/ecad/pcb/tracks.js +70 -0
- package/lib/engine/ecad/runtime.js +227 -0
- package/lib/engine/ecad/toolchain.js +146 -0
- package/lib/engine/ecad/tsci.js +362 -0
- package/lib/engine/ecad/zip.js +98 -0
- package/lib/engine/event-bus.js +158 -0
- package/lib/engine/event-log.js +335 -0
- package/lib/engine/fault-hints.js +146 -0
- package/lib/engine/generate-script.js +4 -1
- package/lib/engine/generate.js +145 -5
- package/lib/engine/interrupts.js +247 -0
- package/lib/engine/ioc-diff.js +369 -0
- package/lib/engine/ioc-plan.js +12 -2
- package/lib/engine/ioc-sync.js +58 -0
- package/lib/engine/mcu-info.js +134 -0
- package/lib/engine/msys2-install.js +31 -6
- package/lib/engine/panel-actions.js +103 -0
- package/lib/engine/pdf/curve.js +321 -0
- package/lib/engine/pdf/png.js +83 -0
- package/lib/engine/pdf/reader.js +336 -0
- package/lib/engine/pdf/schematic.js +93 -0
- package/lib/engine/pdf/tables.js +249 -0
- package/lib/engine/pdf/toolchain.js +50 -0
- package/lib/engine/pinout.js +140 -0
- package/lib/engine/probe-info.js +95 -0
- package/lib/engine/probe.js +45 -0
- package/lib/engine/progress.js +99 -0
- package/lib/engine/project-conf.js +254 -0
- package/lib/engine/project-layout.js +198 -0
- package/lib/engine/project-repair.js +205 -0
- package/lib/engine/schematic/checks.js +153 -0
- package/lib/engine/schematic/draw.js +390 -0
- package/lib/engine/schematic/edit.js +229 -0
- package/lib/engine/schematic/kicad-sch.js +225 -0
- package/lib/engine/schematic/model.js +442 -0
- package/lib/engine/schematic/nets.js +219 -0
- package/lib/engine/schematic/pcb.js +144 -0
- package/lib/engine/schematic/review.js +134 -0
- package/lib/engine/schematic/sexpr.js +134 -0
- package/lib/engine/schematic/to-ioc.js +197 -0
- package/lib/engine/schematic/transform.js +25 -0
- package/lib/engine/session-context.js +106 -0
- package/lib/engine/source-slice.js +59 -0
- package/lib/engine/tool-events.js +119 -0
- package/lib/engine/toolchain-gate.js +8 -0
- package/lib/engine/watch-admin.js +101 -0
- package/lib/engine/watch-record.js +39 -0
- package/lib/engine/watch-recorder.js +116 -0
- package/lib/engine/web-api.js +1123 -4
- package/lib/engine/web-routes.js +18 -1
- package/lib/engine/workspace-memo.js +41 -0
- package/lib/index.js +118 -24
- package/lib/skill/stm32-workflow.js +1 -1
- package/lib/tools/build.js +10 -2
- package/lib/tools/code-patch.js +2 -2
- package/lib/tools/datasheet.js +447 -0
- package/lib/tools/debug-session.js +9 -4
- package/lib/tools/debug.js +2 -2
- package/lib/tools/doctor.js +2 -2
- package/lib/tools/ecad.js +903 -0
- package/lib/tools/flash.js +2 -2
- package/lib/tools/gen.js +166 -0
- package/lib/tools/generate.js +7 -5
- package/lib/tools/import-circuit.js +146 -0
- package/lib/tools/ioc-apply.js +11 -2
- package/lib/tools/ioc-inspect.js +2 -2
- package/lib/tools/ioc-plan.js +2 -2
- package/lib/tools/ioc-verify.js +2 -2
- package/lib/tools/layout.js +92 -0
- package/lib/tools/mcu-info.js +163 -0
- package/lib/tools/part-import.js +182 -0
- package/lib/tools/pcb.js +2316 -0
- package/lib/tools/pdf.js +423 -0
- package/lib/tools/project-create.js +28 -0
- package/lib/tools/project-dir.js +25 -1
- package/lib/tools/regs.js +2 -2
- package/lib/tools/route-plan.js +2 -2
- package/lib/tools/rtt.js +10 -2
- package/lib/tools/sch-draw.js +433 -0
- package/lib/tools/sch-edit.js +145 -0
- package/lib/tools/schematic.js +817 -0
- package/lib/tools/serial.js +22 -0
- package/lib/tools/watch.js +24 -2
- package/package.json +1 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stm32_board_info:把 .ioc 里的事实写成 <工程>/dsh/mcu.json,给别的插件读(S184)。
|
|
3
|
+
* 默认只回事实不落盘;write: true 才写,写完顺手报一次是否与当前 .ioc 同步。
|
|
4
|
+
*/
|
|
5
|
+
import { collectMcuInfo, mcuInfoFreshness, mcuInfoPath, readMcuInfo, writeMcuInfo } from "../engine/mcu-info.js";
|
|
6
|
+
import { resolveProjectDir } from "./project-dir.js";
|
|
7
|
+
export const BOARD_INFO_TOOL = "stm32_board_info";
|
|
8
|
+
const infoOutput = {
|
|
9
|
+
type: "object",
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
properties: {
|
|
12
|
+
ok: { type: "boolean" },
|
|
13
|
+
error: { type: "string" },
|
|
14
|
+
file: { type: "string" },
|
|
15
|
+
written: { type: "boolean" },
|
|
16
|
+
schema: { type: "string" },
|
|
17
|
+
generatedAt: { type: "string" },
|
|
18
|
+
mcu: {
|
|
19
|
+
type: "object",
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
properties: {
|
|
22
|
+
cpn: { type: "string" },
|
|
23
|
+
name: { type: "string" },
|
|
24
|
+
family: { type: "string" },
|
|
25
|
+
package: { type: "string" },
|
|
26
|
+
},
|
|
27
|
+
required: ["cpn", "name", "family", "package"],
|
|
28
|
+
},
|
|
29
|
+
clock: {
|
|
30
|
+
type: "object",
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
properties: {
|
|
33
|
+
sysclkHz: { type: "number" },
|
|
34
|
+
ahbHz: { type: "number" },
|
|
35
|
+
apb1Hz: { type: "number" },
|
|
36
|
+
apb2Hz: { type: "number" },
|
|
37
|
+
},
|
|
38
|
+
required: ["sysclkHz", "ahbHz", "apb1Hz", "apb2Hz"],
|
|
39
|
+
},
|
|
40
|
+
debugPins: { type: "array", items: { type: "string" } },
|
|
41
|
+
nvicCount: { type: "number" },
|
|
42
|
+
peripheralCount: { type: "number" },
|
|
43
|
+
pinCount: { type: "number" },
|
|
44
|
+
pins: {
|
|
45
|
+
type: "array",
|
|
46
|
+
items: {
|
|
47
|
+
type: "object",
|
|
48
|
+
additionalProperties: false,
|
|
49
|
+
properties: {
|
|
50
|
+
pin: { type: "string" },
|
|
51
|
+
signal: { type: "string" },
|
|
52
|
+
label: { type: "string" },
|
|
53
|
+
mode: { type: "string" },
|
|
54
|
+
},
|
|
55
|
+
required: ["pin", "signal", "label", "mode"],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
stale: { type: "boolean" },
|
|
59
|
+
staleReason: { type: "string" },
|
|
60
|
+
notes: { type: "array", items: { type: "string" } },
|
|
61
|
+
},
|
|
62
|
+
required: ["ok", "error", "file", "written", "schema", "generatedAt", "mcu", "clock", "debugPins", "nvicCount", "peripheralCount", "pinCount", "pins", "stale", "staleReason", "notes"],
|
|
63
|
+
};
|
|
64
|
+
export function registerMcuInfoTools(ctx) {
|
|
65
|
+
const tool = {
|
|
66
|
+
name: BOARD_INFO_TOOL,
|
|
67
|
+
description: "MCU 事实文件:把 .ioc 里的事实(型号、封装、时钟、调试口、引脚、外设、中断数)写成 <工程>/dsh/mcu.json,给别的插件或脚本读;默认只回事实,`write: true` 才落盘。文件带 .ioc 的 sha256 指纹,改过 .ioc 后要重新生成。",
|
|
68
|
+
parameters: {
|
|
69
|
+
type: "object",
|
|
70
|
+
additionalProperties: false,
|
|
71
|
+
properties: {
|
|
72
|
+
projectDir: { type: "string", description: "工程根目录;缺省为当前调试会话的工程。" },
|
|
73
|
+
write: { type: "boolean", description: "true 才写进 <工程>/dsh/mcu.json;默认只回事实。" },
|
|
74
|
+
file: { type: "string", description: "覆盖输出路径(相对工程根);缺省 dsh/mcu.json。" },
|
|
75
|
+
},
|
|
76
|
+
required: [],
|
|
77
|
+
},
|
|
78
|
+
output: {
|
|
79
|
+
schema: infoOutput,
|
|
80
|
+
render: (_args, value) => {
|
|
81
|
+
const result = value;
|
|
82
|
+
if (!result.ok)
|
|
83
|
+
return [{ type: "text", text: "读不到 MCU 事实:" + result.error }];
|
|
84
|
+
const mhz = (hz) => (hz > 0 ? String(hz / 1_000_000) + " MHz" : "—");
|
|
85
|
+
const lines = [
|
|
86
|
+
(result.written ? "已写入:" : "预览(未写盘):") + result.file,
|
|
87
|
+
result.mcu.cpn + "(" + result.mcu.package + " · " + result.mcu.family + ")· PIN " + String(result.pinCount) + " · 外设 " + String(result.peripheralCount) + " · 中断 " + String(result.nvicCount),
|
|
88
|
+
"时钟 SYSCLK " + mhz(result.clock.sysclkHz) + " / APB1 " + mhz(result.clock.apb1Hz) + " / APB2 " + mhz(result.clock.apb2Hz),
|
|
89
|
+
"调试口:" + (result.debugPins.length > 0 ? result.debugPins.join(" ") : "没有启用"),
|
|
90
|
+
];
|
|
91
|
+
if (result.stale)
|
|
92
|
+
lines.push("⚠ " + result.staleReason);
|
|
93
|
+
for (const note of result.notes)
|
|
94
|
+
lines.push("说明:" + note);
|
|
95
|
+
return [{ type: "text", text: lines.join("\n") }];
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
timeoutMs: 30_000,
|
|
99
|
+
isConcurrencySafe: () => true,
|
|
100
|
+
execute: async (args, exec) => {
|
|
101
|
+
const empty = {
|
|
102
|
+
ok: false,
|
|
103
|
+
error: "",
|
|
104
|
+
file: "",
|
|
105
|
+
written: false,
|
|
106
|
+
schema: "",
|
|
107
|
+
generatedAt: "",
|
|
108
|
+
mcu: { cpn: "", name: "", family: "", package: "" },
|
|
109
|
+
clock: { sysclkHz: 0, ahbHz: 0, apb1Hz: 0, apb2Hz: 0 },
|
|
110
|
+
debugPins: [],
|
|
111
|
+
nvicCount: 0,
|
|
112
|
+
peripheralCount: 0,
|
|
113
|
+
pinCount: 0,
|
|
114
|
+
pins: [],
|
|
115
|
+
stale: false,
|
|
116
|
+
staleReason: "",
|
|
117
|
+
notes: [],
|
|
118
|
+
};
|
|
119
|
+
const resolved = await resolveProjectDir(ctx, args.projectDir, exec);
|
|
120
|
+
if (resolved.projectDir === "")
|
|
121
|
+
return { ...empty, error: "projectDir 不能为空:从工具栏「工程」下拉里选一个,或先打开调试会话" };
|
|
122
|
+
const collected = collectMcuInfo(resolved.projectDir);
|
|
123
|
+
if (!collected.ok || collected.info === null)
|
|
124
|
+
return { ...empty, error: collected.error };
|
|
125
|
+
const info = collected.info;
|
|
126
|
+
const target = args.file === undefined || args.file.trim() === "" ? mcuInfoPath(resolved.projectDir) : (args.file.trim().match(/^[A-Za-z]:/u) ? args.file.trim() : joinPath(resolved.projectDir, args.file.trim()));
|
|
127
|
+
const shouldWrite = args.write === true;
|
|
128
|
+
const written = shouldWrite ? writeMcuInfo(target, info) : { ok: true, error: "" };
|
|
129
|
+
if (!written.ok)
|
|
130
|
+
return { ...empty, error: written.error, file: target };
|
|
131
|
+
const freshness = readMcuInfo(target);
|
|
132
|
+
const stale = freshness.ok && freshness.info !== null ? mcuInfoFreshness(freshness.info, resolved.projectDir) : { stale: false, reason: "" };
|
|
133
|
+
return {
|
|
134
|
+
ok: true,
|
|
135
|
+
error: "",
|
|
136
|
+
file: target,
|
|
137
|
+
written: shouldWrite,
|
|
138
|
+
schema: info.schema,
|
|
139
|
+
generatedAt: info.generatedAt,
|
|
140
|
+
mcu: { ...info.mcu },
|
|
141
|
+
clock: {
|
|
142
|
+
sysclkHz: info.clock.sysclkHz ?? 0,
|
|
143
|
+
ahbHz: info.clock.ahbHz ?? 0,
|
|
144
|
+
apb1Hz: info.clock.apb1Hz ?? 0,
|
|
145
|
+
apb2Hz: info.clock.apb2Hz ?? 0,
|
|
146
|
+
},
|
|
147
|
+
debugPins: [...info.debug.pins],
|
|
148
|
+
nvicCount: info.nvicCount,
|
|
149
|
+
peripheralCount: info.peripherals.length,
|
|
150
|
+
pinCount: info.pins.length,
|
|
151
|
+
pins: info.pins.map((pin) => ({ pin: pin.pin, signal: pin.signal, label: pin.label, mode: pin.mode })),
|
|
152
|
+
stale: stale.stale,
|
|
153
|
+
staleReason: stale.reason,
|
|
154
|
+
notes: [...info.notes],
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
ctx.tools.register(tool);
|
|
159
|
+
}
|
|
160
|
+
function joinPath(base, rel) {
|
|
161
|
+
const normalized = rel.replace(/\\/gu, "/");
|
|
162
|
+
return base.replace(/[\\/]+$/u, "") + "/" + normalized;
|
|
163
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S173:器件导入工具。
|
|
3
|
+
*
|
|
4
|
+
* stm32_part_import footprint=Package_SO:SOIC-8_3.9x4.9mm_P1.27mm code=C25137 write=true
|
|
5
|
+
*
|
|
6
|
+
* 把 KiCad 官方库里的封装收进工程自己的库,按焊盘生成符号骨架,并登记两张库表。
|
|
7
|
+
* 立创编号只用来查型号/品牌/手册;查不到不阻断,但会在 notes 里说清楚。
|
|
8
|
+
*/
|
|
9
|
+
import { importPart } from "../engine/ecad/part-import.js";
|
|
10
|
+
import { locateEcadToolchain } from "../engine/ecad/toolchain.js";
|
|
11
|
+
import { resolveProjectDir } from "./project-dir.js";
|
|
12
|
+
export const PART_IMPORT_TOOL = "stm32_part_import";
|
|
13
|
+
export function registerPartImportTools(ctx) {
|
|
14
|
+
ctx.tools.register({
|
|
15
|
+
name: PART_IMPORT_TOOL,
|
|
16
|
+
description: "把封装导入工程:优先从 KiCad 官方库复制 .kicad_mod;库里没有但给了立创编号时,从立创页面取封装图形转成 .kicad_mod(source=lcsc 可强制走这条路)。按焊盘生成符号骨架到 hardware/libs/symbols,并登记 fp-lib-table/sym-lib-table。默认只做预先检查,write=true 才写文件。",
|
|
17
|
+
parameters: {
|
|
18
|
+
type: "object",
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
properties: {
|
|
21
|
+
projectDir: { type: "string", description: "工程根目录;缺省为当前调试会话的工程。" },
|
|
22
|
+
footprint: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "源封装,Lib:Name 形式(如 Package_SO:SOIC-8_3.9x4.9mm_P1.27mm);只给 Name 时在库里按名字找。",
|
|
25
|
+
},
|
|
26
|
+
code: { type: "string", description: "立创编号(如 C25137):用来查型号/品牌/手册,也是库里没有封装时的回退来源。" },
|
|
27
|
+
source: {
|
|
28
|
+
type: "string",
|
|
29
|
+
enum: ["auto", "kicad", "lcsc"],
|
|
30
|
+
description: "封装从哪来:auto(默认,先库后立创)/ kicad(只查官方库)/ lcsc(只从立创页面转)。",
|
|
31
|
+
},
|
|
32
|
+
library: { type: "string", description: "收进工程后的库名,默认沿用源库名。" },
|
|
33
|
+
name: { type: "string", description: "收进工程后的封装名与符号名,默认沿用源封装名。" },
|
|
34
|
+
write: { type: "boolean", description: "true 才真的写文件与登记库表;默认只回计划。" },
|
|
35
|
+
},
|
|
36
|
+
required: ["footprint"],
|
|
37
|
+
},
|
|
38
|
+
output: {
|
|
39
|
+
schema: {
|
|
40
|
+
type: "object",
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
properties: {
|
|
43
|
+
ok: { type: "boolean" },
|
|
44
|
+
error: { type: "string" },
|
|
45
|
+
code: { type: "string" },
|
|
46
|
+
mpn: { type: "string" },
|
|
47
|
+
brand: { type: "string" },
|
|
48
|
+
datasheet: { type: "string" },
|
|
49
|
+
library: { type: "string" },
|
|
50
|
+
footprintName: { type: "string" },
|
|
51
|
+
source: { type: "string" },
|
|
52
|
+
footprintFile: { type: "string" },
|
|
53
|
+
symbolFile: { type: "string" },
|
|
54
|
+
modelFile: { type: "string" },
|
|
55
|
+
modelBytes: { type: "number" },
|
|
56
|
+
padCount: { type: "number" },
|
|
57
|
+
pads: { type: "array", items: { type: "string" } },
|
|
58
|
+
written: { type: "array", items: { type: "string" } },
|
|
59
|
+
notes: { type: "array", items: { type: "string" } },
|
|
60
|
+
},
|
|
61
|
+
required: [
|
|
62
|
+
"ok",
|
|
63
|
+
"error",
|
|
64
|
+
"code",
|
|
65
|
+
"mpn",
|
|
66
|
+
"brand",
|
|
67
|
+
"datasheet",
|
|
68
|
+
"library",
|
|
69
|
+
"footprintName",
|
|
70
|
+
"source",
|
|
71
|
+
"footprintFile",
|
|
72
|
+
"symbolFile",
|
|
73
|
+
"modelFile",
|
|
74
|
+
"modelBytes",
|
|
75
|
+
"padCount",
|
|
76
|
+
"pads",
|
|
77
|
+
"written",
|
|
78
|
+
"notes",
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
render: (_args, value) => {
|
|
82
|
+
const result = value;
|
|
83
|
+
if (!result.ok)
|
|
84
|
+
return [{ type: "text", text: "导入失败:" + result.error }];
|
|
85
|
+
const head = (result.code !== "" ? result.code + " " : "") +
|
|
86
|
+
(result.mpn !== "" ? result.mpn + " " : "") +
|
|
87
|
+
(result.brand !== "" ? "(" + result.brand + ")" : "") +
|
|
88
|
+
"· 封装 " + result.library + ":" + result.footprintName + " · 焊盘 " + String(result.padCount) + " 个";
|
|
89
|
+
const lines = [head.trim()];
|
|
90
|
+
if (result.source.startsWith("easyeda:"))
|
|
91
|
+
lines.push("封装来源:立创页面 " + result.source.slice("easyeda:".length));
|
|
92
|
+
if (result.datasheet !== "")
|
|
93
|
+
lines.push("手册:" + result.datasheet);
|
|
94
|
+
lines.push(result.written.length > 0 ? "已写:" : "将写(还没有落盘):");
|
|
95
|
+
lines.push(" 封装:" + result.footprintFile);
|
|
96
|
+
lines.push(" 符号:" + result.symbolFile);
|
|
97
|
+
lines.push(result.modelFile !== ""
|
|
98
|
+
? " 3D 模型:" + result.modelFile + "(" + result.modelBytes.toLocaleString("en-US") + " B)"
|
|
99
|
+
: " 3D 模型:没有(封装不引用,或 KiCad 里缺这个文件)");
|
|
100
|
+
for (const file of result.written.slice(2))
|
|
101
|
+
lines.push(" 库表:" + file);
|
|
102
|
+
for (const note of result.notes)
|
|
103
|
+
lines.push("· " + note);
|
|
104
|
+
return [{ type: "text", text: lines.join("\n") }];
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
timeoutMs: 60_000,
|
|
108
|
+
isConcurrencySafe: () => true,
|
|
109
|
+
execute: async (args, exec) => {
|
|
110
|
+
const project = await resolveProjectDir(ctx, args.projectDir, exec);
|
|
111
|
+
const projectDir = project.projectDir;
|
|
112
|
+
if (projectDir === "") {
|
|
113
|
+
return {
|
|
114
|
+
ok: false,
|
|
115
|
+
error: "没有工程目录:从工具栏「工程」下拉里选一个,或先打开调试会话。",
|
|
116
|
+
code: "",
|
|
117
|
+
mpn: "",
|
|
118
|
+
brand: "",
|
|
119
|
+
datasheet: "",
|
|
120
|
+
library: "",
|
|
121
|
+
footprintName: "",
|
|
122
|
+
source: "",
|
|
123
|
+
footprintFile: "",
|
|
124
|
+
symbolFile: "",
|
|
125
|
+
modelFile: "",
|
|
126
|
+
modelBytes: 0,
|
|
127
|
+
padCount: 0,
|
|
128
|
+
pads: [],
|
|
129
|
+
written: [],
|
|
130
|
+
notes: [],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const located = locateEcadToolchain();
|
|
134
|
+
if (!located.ok || located.toolchain === null) {
|
|
135
|
+
return {
|
|
136
|
+
ok: false,
|
|
137
|
+
error: "找不到 KiCad:" + located.error + "(封装来源是 KiCad 官方库,需要先装 KiCad)",
|
|
138
|
+
code: "",
|
|
139
|
+
mpn: "",
|
|
140
|
+
brand: "",
|
|
141
|
+
datasheet: "",
|
|
142
|
+
library: "",
|
|
143
|
+
footprintName: "",
|
|
144
|
+
source: "",
|
|
145
|
+
footprintFile: "",
|
|
146
|
+
symbolFile: "",
|
|
147
|
+
padCount: 0,
|
|
148
|
+
pads: [],
|
|
149
|
+
written: [],
|
|
150
|
+
notes: [],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const report = await importPart(projectDir, located.toolchain, {
|
|
154
|
+
footprint: (args.footprint ?? "").trim(),
|
|
155
|
+
code: (args.code ?? "").trim(),
|
|
156
|
+
source: args.source ?? "auto",
|
|
157
|
+
library: (args.library ?? "").trim(),
|
|
158
|
+
name: (args.name ?? "").trim(),
|
|
159
|
+
write: args.write === true,
|
|
160
|
+
});
|
|
161
|
+
return {
|
|
162
|
+
ok: report.ok,
|
|
163
|
+
error: report.error,
|
|
164
|
+
code: report.code,
|
|
165
|
+
mpn: report.mpn,
|
|
166
|
+
brand: report.brand,
|
|
167
|
+
datasheet: report.datasheet,
|
|
168
|
+
library: report.footprint?.library ?? "",
|
|
169
|
+
footprintName: report.footprint?.name ?? "",
|
|
170
|
+
source: report.footprint?.source ?? "",
|
|
171
|
+
footprintFile: report.footprint?.file ?? "",
|
|
172
|
+
symbolFile: report.symbol?.file ?? "",
|
|
173
|
+
modelFile: report.model?.file ?? "",
|
|
174
|
+
modelBytes: report.model?.bytes ?? 0,
|
|
175
|
+
padCount: report.pads.length,
|
|
176
|
+
pads: [...report.pads],
|
|
177
|
+
written: [...report.written],
|
|
178
|
+
notes: [...report.notes],
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
}
|