From ef399d0ca593bf818ae58c152f369797158105da Mon Sep 17 00:00:00 2001 From: Noah <2+noah@noreply.gitea.bluefla.re> Date: Thu, 22 Oct 2026 10:22:52 -0600 Subject: [PATCH] Drive fan probing through the HAL client HalClient implements FanProbe, so the measurement sweep runs against a real board over the same local contract: set_fan maps to SET_FAN_TARGET and read_zone maps to READ_TEMPERATURE. The wire round-trip test now exercises both fan verbs through the mock backend. --- src/hal_wire.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/hal_wire.rs b/src/hal_wire.rs index 4200c28..1f90d3d 100644 --- a/src/hal_wire.rs +++ b/src/hal_wire.rs @@ -464,6 +464,18 @@ impl DetectionBackend for HalClient { } } +impl crate::fanmap::FanProbe for HalClient { + type Error = HalError; + + fn set_fan(&mut self, fan: u8, pwm: u8) -> Result<(), Self::Error> { + self.set_fan_target(fan, pwm) + } + + fn read_zone(&mut self, zone: u8) -> Result { + self.read_temperature_mc(zone) + } +} + fn chip_from_wire(value: u8) -> Option { match value { 1 => Some(ChipModel::Bm1362), @@ -545,6 +557,7 @@ impl HardwareBackend for HalClient { #[cfg(test)] mod tests { use super::*; + use crate::fanmap::FanProbe; use std::os::unix::net::UnixStream; fn mock_backend(mut server: UnixStream) { @@ -584,6 +597,12 @@ mod tests { } body } + SET_FAN_TARGET => vec![0], + READ_TEMPERATURE => { + let mut body = vec![0_u8]; + body.extend_from_slice(&42_000_i32.to_le_bytes()); + body + } _ => vec![1], }; let mut out = [0_u8; 16]; @@ -628,6 +647,9 @@ mod tests { assert_eq!(psu.envelope.v_max_mv, 1600); assert_eq!(psu.max_dc_watts, 3600); + client.set_fan(1, 60).expect("set fan"); + assert_eq!(client.read_zone(2).expect("read zone"), 42_000); + drop(client); server.join().expect("server thread"); }