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/check-software-current-warnings.mjs

import fs from "node:fs"
import assert from "node:assert/strict"
import crypto from "node:crypto"
const read=p=>JSON.parse(fs.readFileSync(p,"utf8"))
const before=read("baseline/v055-circuit.json"),after=read("dist/index/circuit.json")
const warnings=c=>c.filter(e=>e.type.endsWith("_warning"))
const key=w=>`${w.type}:${w.source_trace_id??w.source_component_id??w.pcb_component_id??""}`
const old=new Map(warnings(before).map(w=>[key(w),w]))
const width=w=>w.message?.match(/requested: ([\d.]+)mm, actual: ([\d.]+)mm/)
const stable=w=>w.message?.replace(/(<testpoint)#\d+(?= name=)/g,"$1#INSTANCE")
const scopedNames=new Set(["CURRENT_DAC_SUPPLY","CURRENT_DAC_VDDA","CURRENT_DAC_BYPASS_GROUND","CURRENT_DAC_ADDRESS"])
const parent=new Map()
function root(x){if(!parent.has(x))parent.set(x,x);const p=parent.get(x);if(p!==x)parent.set(x,root(p));return parent.get(x)}
for(const e of after){const ids=e.type==="source_trace"?[...e.connected_source_port_ids??[],...e.connected_source_net_ids??[]]:e.type==="source_component_internal_connection"?e.source_port_ids:[];for(const id of ids.slice(1))parent.set(root(id),root(ids[0]))}
const sourceNet=s=>root((s.connected_source_port_ids??[]).concat(s.connected_source_net_ids??[])[0])
const minWidth=traces=>Math.min(...traces.flatMap(t=>t.route.filter(p=>p.route_type==="wire").map(p=>p.width)))
const regressions=[],newWidthReportingDiagnostics=[]
for(const w of warnings(after)) {
  const b=old.get(key(w)),aWidth=width(w),bWidth=b&&width(b)
  if(!b) {
    const s=after.find(e=>e.type==="source_trace"&&e.source_trace_id===w.source_trace_id)
    if(!scopedNames.has(s?.name)||!aWidth){regressions.push({kind:"new_warning",warning:w});continue}
    const local=after.filter(e=>e.type==="pcb_trace"&&e.source_trace_id===s.source_trace_id)
    const reported=after.find(e=>e.type==="pcb_trace"&&e.pcb_trace_id===w.pcb_trace_id)
    const foreign=after.find(e=>e.type==="source_trace"&&e.source_trace_id===reported?.source_trace_id)
    const historical=before.filter(e=>e.type==="pcb_trace"&&e.source_trace_id===foreign?.source_trace_id)
    assert.ok(local.length&&reported&&foreign&&historical.length)
    assert.notEqual(foreign.source_trace_id,s.source_trace_id,"warning selects a different same-net path, not the authored DAC branch")
    assert.equal(sourceNet(foreign),sourceNet(s))
    assert.ok(minWidth(local)>=Number(aWidth[1])-1e-8,"every actual dedicated DAC path meets its declared width")
    assert.ok(Math.abs(minWidth(historical)-Number(aWidth[2]))<1e-8,"the reported whole-net minimum already exists on v0.4.55")
    newWidthReportingDiagnostics.push({name:s.name,warning:w,actualDedicatedPathMinMm:minWidth(local),
      existingNetMinimumMm:minWidth(historical),classification:"Native checker selected an older same-net rail/ground path. Original native diagnostic remains visible; no width rule or check was disabled."})
  } else if(aWidth&&bWidth) {
    if(Math.abs(Number(aWidth[1])-Number(bWidth[1]))>1e-6||Number(aWidth[2])+1e-6<Number(bWidth[2]))regressions.push({kind:"narrower_than_published",before:b,after:w})
  } else if(stable(w)!==stable(b))regressions.push({kind:"changed_warning",before:b,after:w})
}
const errors=after.filter(e=>e.type.endsWith("_error"))
const report={circuitSha256:crypto.createHash("sha256").update(fs.readFileSync("dist/index/circuit.json")).digest("hex"),
  baselineWarnings:warnings(before).length,currentWarnings:warnings(after).length,errors,regressions,newWidthReportingDiagnostics}
fs.writeFileSync("reports/review-warning-regression.json",JSON.stringify(report,null,2)+"\n")
console.log(JSON.stringify({baselineWarnings:report.baselineWarnings,currentWarnings:report.currentWarnings,
  errors:errors.length,regressions:regressions.length,retainedNetWideReportingDiagnostics:newWidthReportingDiagnostics.length}))
assert.deepEqual(errors,[])
assert.deepEqual(regressions,[])