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/prepare-swap-protected.py

"""Keep all untouched published nets protected during independent source import."""
from route_geometry import *
import hashlib
baseline=Path('../../checkpoints/nema17-before-rishabh-review-v053-DuFOGi/restore-verified/dist/index/circuit.json')
before=load_circuit(str(baseline));c=load_circuit('routing/review-placement.circuit.json');root=connectivity(c)
mapping=json.loads(Path('routing/net-map.json').read_text())['roots']
sources={e['source_trace_id']:e for e in c if e['type']=='source_trace'}
def net(t):
    s=sources[t['source_trace_id']];return mapping[root((s.get('connected_source_port_ids',[])+s.get('connected_source_net_ids',[]))[0])]
prep=json.loads(Path('reports/swap-preparation.json').read_text())
affected={e['net'] for key in ['authoredWires','authoredVias','removedWires','removedVias'] for e in prep[key]}
affected|={e['net'] for e in json.loads(Path('reports/bulk-top-physical-islands.json').read_text())['removedForManualEscapes']}
parts={e['source_component_id']:e['name'] for e in c if e['type']=='source_component'}
affected|={mapping[root(e['source_port_id'])] for e in c if e['type']=='source_port' and parts[e['source_component_id']] in json.loads(Path('review-placement.json').read_text())}
protected=[{**e,'connection_name':net(e)} for e in before if e['type']=='pcb_trace' and e.get('source_trace_id') and net(e) not in affected]
assert protected and not any(net(e) in affected for e in protected)
Path('routing/protected-routes.json').write_text(json.dumps(protected,indent=2)+'\n')
report=dict(baselineSha256=hashlib.sha256(baseline.read_bytes()).hexdigest(),protectedRoutes=len(protected),protectedNets=sorted({net(e) for e in protected}),reworkedNets=sorted(affected))
Path('reports/swap-protected.json').write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps(dict(protectedRoutes=len(protected),protectedNets=len(report['protectedNets']),reworkedNets=report['reworkedNets'])))