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/test-buck-enable.py
"""Negative controls prove neither a schematic-only nor a copper-only fix passes."""
import importlib.util
from pathlib import Path
import copy,json
spec=importlib.util.spec_from_file_location('buck_enable',Path(__file__).with_name('check-buck-enable.py'))
module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
check=module.check
current=json.loads(Path('dist/index/circuit.json').read_text())
check(current)
component=next(e for e in current if e['type']=='source_component' and e['name']=='U_BUCK')
en=next(e for e in current if e['type']=='source_port' and e['source_component_id']==component['source_component_id'] and e['name']=='EN')
vin=next(e for e in current if e['type']=='source_port' and e['source_component_id']==component['source_component_id'] and e['name']=='VIN')
def rejects(c,expected):
try:check(c)
except AssertionError as error:
assert expected in str(error),str(error)
return
raise AssertionError('unsafe mutation incorrectly passed')
logical=copy.deepcopy(current)
logical.append(dict(type='source_trace',source_trace_id='unsafe_test',connected_source_port_ids=[en['source_port_id'],vin['source_port_id']]))
rejects(logical,'unsafe external connection')
physical=copy.deepcopy(current)
port=next(e for e in physical if e['type']=='pcb_port' and e['source_port_id']==en['source_port_id'])
physical.append(dict(type='pcb_trace',route=[dict(route_type='wire',layer='bottom',width=.15,x=port['x'],y=port['y']),
dict(route_type='wire',layer='bottom',width=.15,x=port['x']-1,y=port['y'])]))
rejects(physical,'emitted tracks')
unmarked=copy.deepcopy(current)
next(e for e in unmarked if e.get('source_port_id')==en['source_port_id'] and e['type']=='source_port').pop('do_not_connect')
rejects(unmarked,'explicitly use')
print('PASS: open EN; rejects missing no-connect, logical reconnection and copper-only reconnection')