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/rebind-stock-after-routing.mjs

import fs from "node:fs"
import crypto from "node:crypto"
import assert from "node:assert/strict"
import {validateCatalogPart} from "./validate-bom.mjs"

const bytes=fs.readFileSync("dist/index/circuit.json"), c=JSON.parse(bytes)
const stock=JSON.parse(fs.readFileSync("reports/jlcpcb-stock-audit.json","utf8"))
const sources=new Map(c.filter(e=>e.type==="source_component").map(e=>[e.source_component_id,e]))
const populated=c.filter(e=>e.type==="pcb_component"&&!e.do_not_place&&sources.get(e.source_component_id)?.ftype!=="simple_test_point")
  .map(e=>sources.get(e.source_component_id))
const checked=new Set()
for(const part of stock.parts)for(const name of part.designators){
  const source=populated.find(e=>e.name===name)
  assert.ok(source,`catalog part ${name} remains populated`)
  assert.equal(source.supplier_part_numbers?.jlcpcb?.[0],part.code)
  assert.deepEqual(validateCatalogPart(source,part),[],`electrical catalog contract ${name}`)
  assert.ok(!checked.has(name));checked.add(name)
}
assert.equal(checked.size,populated.length)
assert.equal(checked.size,stock.populatedComponentCount)
const sha=crypto.createHash("sha256").update(bytes).digest("hex")
stock.geometryRebindings??=[]
if(stock.circuitSha256!==sha)stock.geometryRebindings.push({at:new Date().toISOString(),
  previousCircuitSha256:stock.circuitSha256,newCircuitSha256:sha,
  reason:"Routing-only rebuild; every populated designator, catalog code and declared electrical value revalidated. Inventory timestamps unchanged; no new reservation or lookup claimed."})
stock.circuitSha256=sha
fs.writeFileSync("reports/jlcpcb-stock-audit.json",JSON.stringify(stock,null,2)+"\n")
console.log(JSON.stringify({populated:checked.size,circuitSha256:sha,inventoryCheckedAt:stock.checkedAt}))