Files
forgefirm/scripts/bench/fan_test.py
T
ScottW514 cd8a01a3d9 bench: every board-runnable tool ported to the bench page
The remaining bench diagnostics run from forgetest's #bench tab. The
tools that also run from a LAN host share scripts/bench/gfbench.py:
GF_HOST names a remote machine (host mode, sysfs through ssh, Grbl and
forgectrl over the LAN); unset, the tool runs on the board itself
(local mode, sysfs directly, everything on 127.0.0.1), which is how the
page runs them - with GF_HOST=127.0.0.1, the panel token in GF_TOKEN
and their data files under <data>/bench/ (FORGETEST_BENCH_DATA). The
helper also reads a machine setting from forgectrl, or from the settings
file on the board while forgectrl is stopped.

Ported: pwm_sweep / pwm_hold (scope = a takeover; the latch relocked,
the write refused if FIRE or LASER_ON reads active), pwm_stream_test
(PASS/FAIL exit), flow_characterize, flow_recheck_char,
flow_warm_validate and flow_matrix (takeovers: forgectrl owns the
thermal hardware, so the page's takeover replaces the tools' own
controller stop/restart, whose command line predated the supervisor;
results and logs in the bench data directory), flow_sustained,
fan_test, temp_calibrate (dry; watch bounded in seconds; the threshold
and the coolant conversion from the shared code), flow_escalate_drill
(cool_confirm_max_s shortened through forgectrl's settings for the
drill and restored; the setting's minimum is the default budget), and
live_fire_drills (<drill> [S] [F], all six drills, host from GF_HOST,
token from the board). flow_matrix joins the registry. What stays
unported cannot run against the machine at all: the two null-sink CI
harnesses and the .puls decoder.

Runner: a scope tool runs inside the takeover wrapper; the bench
environment above is passed to every tool. Tests: test_bench_registry
(registry <-> scripts/bench consistency, every ported tool builds its
command line, every script compiles, gfbench host/local modes) and the
server test (scope tool takeover, the environment reaching the tool).
Local mode smoke-run on the bench (temp_calibrate watch, setting, token)
from /tmp, removed after.

No catalog consequence: bench tools are not image components (dev-only
forgetest); the acceptance catalog is unchanged.
2026-08-16 16:28:39 -04:00

65 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Fan/coolant bench: snapshots the fan PWMs, tachs and coolant readings,
drives M8 (cut-profile fans), then M9 (cooldown -> idle), and prints
each snapshot for the tach readbacks to be judged. Needs the controller
running with forgectrl's cooling engine. Runs on the board or from a
host (gfbench: GF_HOST)."""
import socket
import time
from gfbench import HOST, board as _board, degc
def board(cmd):
return _board(cmd).strip().replace('\n', ' ')
ATTRS = ('head/air_assist_pwm head/air_assist_tach head/purge_air '
'thermal/exhaust_pwm thermal/tach_exhaust '
'thermal/intake_pwm thermal/tach_intake_1 thermal/tach_intake_2 '
'thermal/water_pump_on thermal/tec_on pic/water_temp_1 pic/water_temp_2')
def snap(tag):
vals = board('cd /sys/glowforge && cat ' + ATTRS).split()
keys = [a.split('/')[-1] for a in ATTRS.split()]
print(tag)
for k, v in zip(keys, vals):
print(' %-18s %s' % (k, v))
s = socket.create_connection((HOST, 23), timeout=5)
s.settimeout(0.15)
def drain():
out = b''
try:
while True:
d = s.recv(4096)
if not d: break
out += d
except socket.timeout: pass
return out.decode('ascii', 'replace')
def cmd(l, w=0.4):
s.sendall(l.encode() + b'\n'); time.sleep(w); return drain().strip()
time.sleep(0.5); drain()
snap('--- baseline (driver idle profile)')
w2 = board('cat /sys/glowforge/pic/water_temp_2')
print('water_temp_2 = %s -> %.1f C' % (w2, degc(w2)))
print()
print('=== M8: cut-profile fans ON (loud) ===')
print('M8:', cmd('M8'))
time.sleep(4) # spin-up
snap('--- during M8')
print()
print('=== M9: cooldown (fans stay on ~15 s) ===')
print('M9:', cmd('M9'))
time.sleep(3)
snap('--- during cooldown (should still be at run values)')
time.sleep(14) # past the 15 s cooldown
snap('--- after cooldown (should be idle: AA 204, EF 0, IF 0)')
s.sendall(b'?'); time.sleep(0.3)
t = drain()
print('grbl:', t[t.rfind('<'):t.rfind('>') + 1] if '<' in t else t)