diff --git a/src/dc_out_controller.rs b/src/dc_out_controller.rs index 98e9020..14edd85 100644 --- a/src/dc_out_controller.rs +++ b/src/dc_out_controller.rs @@ -47,7 +47,6 @@ impl DcOutControllerState { } fn handle_adapter_down(&mut self) { - info!("status: {:?}", self); match self.status { DcOutStatus::On => { self.status = DcOutStatus::WaitingOff; @@ -208,7 +207,7 @@ impl DcOutController { match pin.lock() { Ok(pin) => { - if let Err(err) = Self::output_ctl(state, pin) { + if let Err(err) = Self::output_ctl(&mut state, pin) { warn!("Put Control Pin State Failed. {}", err); } } @@ -222,7 +221,6 @@ impl DcOutController { } else { warn!("DC_OUT_STATE_EVENT_LOOP is None"); } - debug!("status: {:?}", state); }) .map_err(|err| anyhow::anyhow!("Subscribe Voltage Failed. {}", err))?; self.voltage_subscription = Some(voltage_subscription); @@ -232,14 +230,14 @@ impl DcOutController { anyhow::Ok(()) } fn output_ctl( - mut state: DcOutControllerState, + state: &mut DcOutControllerState, mut pin: MutexGuard, ) -> anyhow::Result<()> { - if DcOutStatus::Off == state.status && state.pin_state == PinState::Low { + if DcOutStatus::Off == state.status { pin.set_high() .map_err(|err| anyhow::anyhow!("Set DC Output Control Pin High Failed. {}", err))?; state.pin_state = PinState::High; - } else if DcOutStatus::On == state.status && state.pin_state == PinState::High { + } else if DcOutStatus::On == state.status { pin.set_low() .map_err(|err| anyhow::anyhow!("Set DC Output Control Pin Low Failed. {}", err))?; state.pin_state = PinState::Low;