shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

scripts/validate-usb-top.mjs

import fs from "node:fs"
import {spawn} from "node:child_process"
const bun=process.execPath,python="/tmp/nema17-routing-python/bin/python"
const cli=["node_modules/@tscircuit/cli/cli/entrypoint.js","--use-global"]
const baseline="../../checkpoints/nema17-before-usb-top-v052-UkdpHy/restore-verified"
const env={...process.env,PATH:"/opt/homebrew/bin:"+process.env.PATH,ROUTING_PYTHON:python,CIRCUIT_INPUT:"dist/index/circuit.json"}
async function run(name,command,args){
  const fd=fs.openSync("reports/usb-top-"+name+".log","w")
  await new Promise((resolve,reject)=>{
    const p=spawn(command,args,{env,stdio:["ignore",fd,fd]})
    p.once("error",reject)
    p.once("exit",code=>{fs.closeSync(fd);console.log(JSON.stringify({step:name,exit:code}));code===0?resolve():reject(new Error(name+" failed; inspect its log"))})
  })
}
const results=await Promise.allSettled([
  run("tests",bun,["test","./tests","./modules/f1c100s/tests"]),
  (async()=>{await run("stock",bun,["scripts/audit-jlcpcb-stock.mjs","dist/index/circuit.json","reports"]);await run("bom",bun,["scripts/validate-bom.mjs"])})(),
  (async()=>{await run("typecheck",bun,["node_modules/typescript/bin/tsc","--noEmit"]);await run("shorts",bun,[...cli,"check","shorts","dist/index/circuit.json","--mode","gerber","--layer","all"]);await run("style",bun,[...cli,"check","schematic-placement","dist/index/circuit.json"])})(),
  (async()=>{
    await run("continuity",bun,["scripts/check-continuity.mjs"])
    for(const [name,args] of [
      ["copper",["scripts/audit-local-copper.py"]],
      ["drill",["scripts/compare-drill-clearance.py",baseline+"/dist/index/circuit.json"]],
      ["dfm",["scripts/review-additional-dfm.py"]],
      ["solder",["scripts/audit-solder-process.py"]],
      ["kelvin",["scripts/audit-session-kelvin.py"]],
    ])await run(name,python,args)
    await run("motor",bun,["scripts/check-assembly-motor-reference.mjs"])
    await run("gerbers",bun,[...cli,"export","dist/index/circuit.json","--format","gerbers","--output","../../reports/usb-top-preview.zip"])
    await run("artwork",python,["scripts/audit-stencil-artwork.py","dist/index/circuit.json","reports/usb-top-preview.zip"])
  })(),
])
const failures=results.filter(r=>r.status==="rejected")
if(failures.length){console.error(failures.map(r=>r.reason.message).join("\n"));process.exitCode=1}
else await run("verify",bun,["scripts/verify.mjs"])