From 8793abeebe557c72eff11b1e69e66c1b69ab0386 Mon Sep 17 00:00:00 2001 From: Adam Sasine Date: Wed, 22 Oct 2025 15:01:45 -0700 Subject: [PATCH 1/6] Indicate local vs. global in all logging --- embedded-service/src/power/policy/mod.rs | 7 +++ examples/std/src/bin/type_c/basic.rs | 8 ++-- examples/std/src/bin/type_c/service.rs | 6 +-- .../std/src/lib/type_c/mock_controller.rs | 32 ++++++------- type-c-service/src/driver/tps6699x.rs | 46 +++++++++---------- type-c-service/src/service/mod.rs | 14 +++--- type-c-service/src/service/power.rs | 4 +- type-c-service/src/wrapper/cfu.rs | 22 ++++----- type-c-service/src/wrapper/dp.rs | 2 +- type-c-service/src/wrapper/mod.rs | 32 ++++++------- type-c-service/src/wrapper/pd.rs | 22 ++++----- type-c-service/src/wrapper/power.rs | 14 +++--- type-c-service/src/wrapper/vdm.rs | 2 +- 13 files changed, 109 insertions(+), 102 deletions(-) diff --git a/embedded-service/src/power/policy/mod.rs b/embedded-service/src/power/policy/mod.rs index 65fc5b90..fd7a4382 100644 --- a/embedded-service/src/power/policy/mod.rs +++ b/embedded-service/src/power/policy/mod.rs @@ -40,6 +40,13 @@ pub enum Error { #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct DeviceId(pub u8); +#[cfg(not(feature = "defmt"))] +impl core::fmt::Display for DeviceId { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "DeviceId({})", self.0) + } +} + /// Amount of power that a device can provider or consume #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] diff --git a/examples/std/src/bin/type_c/basic.rs b/examples/std/src/bin/type_c/basic.rs index 7f8903d1..2c057bfc 100644 --- a/examples/std/src/bin/type_c/basic.rs +++ b/examples/std/src/bin/type_c/basic.rs @@ -72,14 +72,14 @@ mod test_controller { async fn process_ucsi_command(&self, command: &lpm::GlobalCommand) -> ucsi::GlobalResponse { match command.operation() { lpm::CommandData::ConnectorReset => { - info!("Reset for port {:#?}", command.port()); + info!("Reset for {}", command.port()); ucsi::Response { cci: ucsi::cci::Cci::new_cmd_complete(), data: None, } } rest => { - info!("UCSI command {:#?} for port {:#?}", rest, command.port()); + info!("UCSI command {:#?} for {}", rest, command.port()); ucsi::Response { cci: ucsi::cci::Cci::new_cmd_complete(), data: None, @@ -94,11 +94,11 @@ mod test_controller { ) -> Result { Ok(match command.data { controller::PortCommandData::PortStatus(Cached(true)) => { - info!("Port status for port {}", command.port.0); + info!("Port status for {}", command.port); controller::PortResponseData::PortStatus(PortStatus::new()) } _ => { - info!("Port command for port {}", command.port.0); + info!("Port command for {}", command.port); controller::PortResponseData::Complete } }) diff --git a/examples/std/src/bin/type_c/service.rs b/examples/std/src/bin/type_c/service.rs index d3305dc3..0534cb72 100644 --- a/examples/std/src/bin/type_c/service.rs +++ b/examples/std/src/bin/type_c/service.rs @@ -42,9 +42,9 @@ mod debug { fn receive(&self, message: &comms::Message) -> Result<(), comms::MailboxDelegateError> { if let Some(message) = message.data.get::() { if message.connected { - info!("Port{}: Debug accessory connected", message.port.0); + info!("{}: Debug accessory connected", message.port); } else { - info!("Port{}: Debug accessory disconnected", message.port.0); + info!("{}: Debug accessory disconnected", message.port); } } @@ -88,7 +88,7 @@ async fn controller_task(state: &'static mock_controller::ControllerState) { let output = output.unwrap(); if let Output::PdAlert(OutputPdAlert { port, ado }) = &output { - info!("Port{}: PD alert received: {:?}", port.0, ado); + info!("{}: PD alert received: {:?}", port, ado); } if let Err(e) = wrapper.finalize(output).await { diff --git a/examples/std/src/lib/type_c/mock_controller.rs b/examples/std/src/lib/type_c/mock_controller.rs index b877bc7b..75f8f581 100644 --- a/examples/std/src/lib/type_c/mock_controller.rs +++ b/examples/std/src/lib/type_c/mock_controller.rs @@ -182,10 +182,10 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { async fn get_pd_alert(&mut self, port: LocalPortId) -> Result, Error> { let pd_alert = self.state.pd_alert.lock().await; if let Some(ado) = *pd_alert { - debug!("Port{}: Get PD alert: {ado:#?}", port.0); + debug!("{}: Get PD alert: {ado:#?}", port); Ok(Some(ado)) } else { - debug!("Port{}: No PD alert", port.0); + debug!("{}: No PD alert", port); Ok(None) } } @@ -224,32 +224,32 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { port: LocalPortId, voltage_mv: Option, ) -> Result<(), Error> { - debug!("Set max sink voltage for port {}: {:?}", port.0, voltage_mv); + debug!("Set max sink voltage for {}: {:?}", port, voltage_mv); Ok(()) } async fn reconfigure_retimer(&mut self, port: LocalPortId) -> Result<(), Error> { - debug!("reconfigure_retimer(port: {port:?})"); + debug!("reconfigure_retimer(port: {port})"); Ok(()) } async fn clear_dead_battery_flag(&mut self, port: LocalPortId) -> Result<(), Error> { - debug!("clear_dead_battery_flag(port: {port:?})"); + debug!("clear_dead_battery_flag(port: {port})"); Ok(()) } async fn get_other_vdm(&mut self, port: LocalPortId) -> Result> { - debug!("Get other VDM for port {port:?}"); + debug!("Get other VDM for {port}"); Ok(OtherVdm::default()) } async fn get_attn_vdm(&mut self, port: LocalPortId) -> Result> { - debug!("Get attention VDM for port {port:?}"); + debug!("Get attention VDM for {port}"); Ok(AttnVdm::default()) } async fn send_vdm(&mut self, port: LocalPortId, tx_vdm: SendVdm) -> Result<(), Error> { - debug!("Send VDM for port {port:?}: {tx_vdm:?}"); + debug!("Send VDM for {port}: {tx_vdm:?}"); Ok(()) } @@ -259,14 +259,14 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { config: UsbControlConfig, ) -> Result<(), Error> { debug!( - "set_usb_control(port: {port:?}, usb2: {}, usb3: {}, usb4: {})", + "set_usb_control(port: {port}, usb2: {}, usb3: {}, usb4: {})", config.usb2_enabled, config.usb3_enabled, config.usb4_enabled ); Ok(()) } async fn get_dp_status(&mut self, port: LocalPortId) -> Result> { - debug!("Get DisplayPort status for port {port:?}"); + debug!("Get DisplayPort status for {port}"); Ok(DpStatus { alt_mode_entered: false, dfp_d_pin_cfg: DpPinConfig::default(), @@ -275,19 +275,19 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { async fn set_dp_config(&mut self, port: LocalPortId, config: DpConfig) -> Result<(), Error> { debug!( - "Set DisplayPort config for port {port:?}: enable={}, pin_cfg={:?}", + "Set DisplayPort config for {port}: enable={}, pin_cfg={:?}", config.enable, config.dfp_d_pin_cfg ); Ok(()) } async fn execute_drst(&mut self, port: LocalPortId) -> Result<(), Error> { - debug!("Execute PD Data Reset for port {port:?}"); + debug!("Execute PD Data Reset for {port}"); Ok(()) } async fn set_tbt_config(&mut self, port: LocalPortId, config: TbtConfig) -> Result<(), Error> { - debug!("Set Thunderbolt config for port {port:?}: {config:?}"); + debug!("Set Thunderbolt config for {port}: {config:?}"); Ok(()) } @@ -296,7 +296,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { port: LocalPortId, config: PdStateMachineConfig, ) -> Result<(), Error> { - debug!("Set PD State Machine config for port {port:?}: {config:?}"); + debug!("Set PD State Machine config for {port}: {config:?}"); Ok(()) } @@ -305,7 +305,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { port: LocalPortId, state: TypeCStateMachineState, ) -> Result<(), Error> { - debug!("Set Type-C State Machine state for port {port:?}: {state:?}"); + debug!("Set Type-C State Machine state for {port}: {state:?}"); Ok(()) } @@ -313,7 +313,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { &mut self, command: lpm::LocalCommand, ) -> Result, Error> { - debug!("Execute UCSI command for port {:?}: {command:?}", command.port()); + debug!("Execute UCSI command for {}: {command:?}", command.port()); match command.operation() { lpm::CommandData::GetConnectorStatus => Ok(Some(lpm::ResponseData::GetConnectorStatus( lpm::get_connector_status::ResponseData::default(), diff --git a/type-c-service/src/driver/tps6699x.rs b/type-c-service/src/driver/tps6699x.rs index 1acb07b5..60360e39 100644 --- a/type-c-service/src/driver/tps6699x.rs +++ b/type-c-service/src/driver/tps6699x.rs @@ -294,21 +294,21 @@ impl Controller for Tps6699x<'_, M, B> { } let status = self.tps6699x.get_port_status(port).await?; - trace!("Port{} status: {:#?}", port.0, status); + trace!("{} status: {:#?}", port, status); let pd_status = self.tps6699x.get_pd_status(port).await?; - trace!("Port{} PD status: {:#?}", port.0, pd_status); + trace!("{} PD status: {:#?}", port, pd_status); let port_control = self.tps6699x.get_port_control(port).await?; - trace!("Port{} control: {:#?}", port.0, port_control); + trace!("{} control: {:#?}", port, port_control); let mut port_status = PortStatus::default(); let plug_present = status.plug_present(); port_status.connection_state = status.connection_state().try_into().ok(); - debug!("Port{} Plug present: {}", port.0, plug_present); - debug!("Port{} Valid connection: {}", port.0, port_status.is_connected()); + debug!("{} Plug present: {}", port, plug_present); + debug!("{} Valid connection: {}", port, port_status.is_connected()); if port_status.is_connected() { // Determine current contract if any @@ -339,7 +339,7 @@ impl Controller for Tps6699x<'_, M, B> { if num_sprs == 0 { // USB PD spec requires at least one source PDO be present, something is really wrong - error!("Port{} no source PDOs found", port.0); + error!("{} no source PDOs found", port); return Err(PdError::InvalidParams.into()); } @@ -354,7 +354,7 @@ impl Controller for Tps6699x<'_, M, B> { } else if pd_status.is_source() { // Implicit source contract let current = TypecCurrent::try_from(port_control.typec_current()).map_err(Error::Pd)?; - debug!("Port{} type-C source current: {:#?}", port.0, current); + debug!("{} type-C source current: {:#?}", port, current); let new_contract = Some(PowerCapability::from(current)); port_status.available_source_contract = new_contract; } else { @@ -362,11 +362,11 @@ impl Controller for Tps6699x<'_, M, B> { let pull = pd_status.cc_pull_up(); let new_contract = if pull == PdCcPullUp::NoPull { // No pull up means no contract - debug!("Port{} no pull up", port.0); + debug!("{} no pull up", port); None } else { let current = TypecCurrent::try_from(pd_status.cc_pull_up()).map_err(Error::Pd)?; - debug!("Port{} type-C sink current: {:#?}", port.0, current); + debug!("{} type-C sink current: {:#?}", port, current); Some(PowerCapability::from(current)) }; port_status.available_sink_contract = new_contract; @@ -390,12 +390,12 @@ impl Controller for Tps6699x<'_, M, B> { // Update alt-mode status let alt_mode = self.tps6699x.get_alt_mode_status(port).await?; - debug!("Port{} alt mode: {:#?}", port.0, alt_mode); + debug!("{} alt mode: {:#?}", port, alt_mode); port_status.alt_mode = alt_mode; // Update power path status let power_path = self.tps6699x.get_power_path_status(port).await?; - trace!("Port{} power source: {:#?}", port.0, power_path); + trace!("{} power source: {:#?}", port, power_path); port_status.power_path = match port { PORT0 => PowerPathStatus::new( power_path.pa_ext_vbus_sw() == PpExtVbusSw::EnabledInput, @@ -407,7 +407,7 @@ impl Controller for Tps6699x<'_, M, B> { ), _ => Err(PdError::InvalidPort)?, }; - debug!("Port{} power path: {:#?}", port.0, port_status.power_path); + debug!("{} power path: {:#?}", port, port_status.power_path); } Ok(port_status) @@ -449,7 +449,7 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.execute_muxr(port, input).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing MuxR on port {}: {:#?}", port.0, r); + debug!("Error executing MuxR on {}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } @@ -459,19 +459,19 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.execute_dbfg(port).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing DBfg on port {}: {:#?}", port.0, r); + debug!("Error executing DBfg on {}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } } async fn enable_sink_path(&mut self, port: LocalPortId, enable: bool) -> Result<(), Error> { - debug!("Port{} enable sink path: {}", port.0, enable); + debug!("{} enable sink path: {}", port, enable); match self.tps6699x.enable_sink_path(port, enable).await { // Temporary workaround for autofet rejection // Tracking bug: https://github.com/OpenDevicePartnership/embedded-services/issues/268 Err(Error::Pd(PdError::Rejected)) | Err(Error::Pd(PdError::Timeout)) => { - info!("Port{} autofet rejection, ignored", port.0); + info!("{} autofet rejection, ignored", port); Ok(()) } rest => rest, @@ -638,7 +638,7 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.send_vdms(port, input).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing VDMs on port {}: {:#?}", port.0, r); + debug!("Error executing VDMs on {}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } @@ -675,7 +675,7 @@ impl Controller for Tps6699x<'_, M, B> { async fn get_dp_status(&mut self, port: LocalPortId) -> Result> { let dp_status = self.tps6699x.get_dp_status(port).await?; - debug!("Port{} DP status: {:#?}", port.0, dp_status); + debug!("{} DP status: {:#?}", port, dp_status); let alt_mode_entered = dp_status.dp_mode_active() != 0; @@ -694,7 +694,7 @@ impl Controller for Tps6699x<'_, M, B> { port: LocalPortId, config: controller::DpConfig, ) -> Result<(), Error> { - debug!("Port{} setting DP config: {:#?}", port.0, config); + debug!("{} setting DP config: {:#?}", port, config); let mut dp_config_reg = self.tps6699x.get_dp_config(port).await?; @@ -712,14 +712,14 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.execute_drst(port).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing DRST on port {}: {:#?}", port.0, r); + debug!("Error executing DRST on {}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } } async fn set_tbt_config(&mut self, port: LocalPortId, config: TbtConfig) -> Result<(), Error> { - debug!("Port{} setting TBT config: {:#?}", port.0, config); + debug!("{} setting TBT config: {:#?}", port, config); let mut config_reg = self.tps6699x.lock_inner().await.get_tbt_config(port).await?; @@ -734,7 +734,7 @@ impl Controller for Tps6699x<'_, M, B> { port: LocalPortId, config: controller::PdStateMachineConfig, ) -> Result<(), Error> { - debug!("Port{} setting PD state machine config: {:#?}", port.0, config); + debug!("{} setting PD state machine config: {:#?}", port, config); let mut config_reg = self.tps6699x.lock_inner().await.get_port_config(port).await?; @@ -748,7 +748,7 @@ impl Controller for Tps6699x<'_, M, B> { port: LocalPortId, state: controller::TypeCStateMachineState, ) -> Result<(), Error> { - debug!("Port{} setting Type-C state machine state: {:#?}", port.0, state); + debug!("{} setting Type-C state machine state: {:#?}", port, state); let mut config_reg = self.tps6699x.lock_inner().await.get_port_config(port).await?; let typec_state = match state { diff --git a/type-c-service/src/service/mod.rs b/type-c-service/src/service/mod.rs index 1678664c..f475a5e0 100644 --- a/type-c-service/src/service/mod.rs +++ b/type-c-service/src/service/mod.rs @@ -137,9 +137,9 @@ impl<'a> Service<'a> { ) -> Result<(), Error> { let old_status = self.get_cached_port_status(port_id).await?; - debug!("Port{}: Event: {:#?}", port_id.0, event); - debug!("Port{} Previous status: {:#?}", port_id.0, old_status); - debug!("Port{} Status: {:#?}", port_id.0, status); + debug!("{}: Event: {:#?}", port_id, event); + debug!("{} Previous status: {:#?}", port_id, old_status); + debug!("{} Status: {:#?}", port_id, status); let connection_changed = status.is_connected() != old_status.is_connected(); if connection_changed && (status.is_debug_accessory() || old_status.is_debug_accessory()) { @@ -150,9 +150,9 @@ impl<'a> Service<'a> { }; if status.is_connected() { - debug!("Port{}: Debug accessory connected", port_id.0); + debug!("{}: Debug accessory connected", port_id); } else { - debug!("Port{}: Debug accessory disconnected", port_id.0); + debug!("{}: Debug accessory disconnected", port_id); } if self.tp.send(EndpointID::Internal(Internal::Usbc), &msg).await.is_err() { @@ -219,12 +219,12 @@ impl<'a> Service<'a> { pub async fn process_event(&self, event: Event<'_>) -> Result<(), Error> { match event { Event::PortStatusChanged(port, event_kind, status) => { - trace!("Port{}: Processing port status changed", port.0); + trace!("{}: Processing port status changed", port); self.process_port_event(port, event_kind, status).await } Event::PortNotification(port, notification) => { // Other port notifications - info!("Port{}: Got port notification: {:?}", port.0, notification); + info!("{}: Got port notification: {:?}", port, notification); Ok(()) } Event::ExternalCommand(request) => { diff --git a/type-c-service/src/service/power.rs b/type-c-service/src/service/power.rs index 972184ea..0eee4028 100644 --- a/type-c-service/src/service/power.rs +++ b/type-c-service/src/service/power.rs @@ -63,8 +63,8 @@ impl<'a> Service<'a> { // If it switches to sourcing then the system will no longer be unconstrained // So set that port to constrained and unconstrain all others info!( - "Setting port{} to constrained, all others unconstrained", - unconstrained_index + "Setting {} to constrained, all others unconstrained", + GlobalPortId(unconstrained_index as u8) ); for port_index in 0..num_ports { self.context diff --git a/type-c-service/src/wrapper/cfu.rs b/type-c-service/src/wrapper/cfu.rs index 2568b91c..629a2804 100644 --- a/type-c-service/src/wrapper/cfu.rs +++ b/type-c-service/src/wrapper/cfu.rs @@ -128,25 +128,25 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let controller_id = self.registration.pd_controller.id(); let mut detached_all = true; for power in self.registration.power_devices { - info!("Controller{}: checking power device", controller_id.0); + info!("{}: checking power device", controller_id); if power.state().await != power::policy::device::State::Detached { - info!("Controller{}: Detaching power device", controller_id.0); + info!("{}: Detaching power device", controller_id); if let Err(e) = power.detach().await { - error!("Controller{}: Failed to detach power device: {:?}", controller_id.0, e); + error!("{}: Failed to detach power device: {:?}", controller_id, e); // Sync to bring the controller to a known state with all services match self.sync_state_internal(controller, state).await { Ok(_) => debug!( - "Controller{}: Synced state after detaching power device", - controller_id.0 + "{}: Synced state after detaching power device", + controller_id ), Err(Error::Pd(e)) => error!( - "Controller{}: Failed to sync state after detaching power device: {:?}", - controller_id.0, e + "{}: Failed to sync state after detaching power device: {:?}", + controller_id, e ), Err(Error::Bus(_)) => error!( - "Controller{}: Failed to sync state after detaching power device, bus error", - controller_id.0 + "{}: Failed to sync state after detaching power device, bus error", + controller_id ), } @@ -158,8 +158,8 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, if !detached_all { error!( - "Controller{}: Failed to detach all power devices, rejecting offer", - controller_id.0 + "{}: Failed to detach all power devices, rejecting offer", + controller_id ); return InternalResponseData::ContentResponse(FwUpdateContentResponse::new( content.header.sequence_num, diff --git a/type-c-service/src/wrapper/dp.rs b/type-c-service/src/wrapper/dp.rs index c93b2723..0b13b29e 100644 --- a/type-c-service/src/wrapper/dp.rs +++ b/type-c-service/src/wrapper/dp.rs @@ -11,7 +11,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, controller: &mut C, port: LocalPortId, ) -> Result::BusError>> { - trace!("Processing DP status update event on port {}", port.0); + trace!("Processing DP status update event on {}", port); let status = controller.get_dp_status(port).await?; Ok(OutputDpStatusChanged { port, status }) diff --git a/type-c-service/src/wrapper/mod.rs b/type-c-service/src/wrapper/mod.rs index 16a3cd3d..160e192e 100644 --- a/type-c-service/src/wrapper/mod.rs +++ b/type-c-service/src/wrapper/mod.rs @@ -139,7 +139,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let mut status_changed = port_state.sw_status_event; let local_port = LocalPortId(i as u8); let status = controller.get_port_status(local_port).await?; - trace!("Port{} status: {:#?}", i, status); + trace!("{} status: {:#?}", local_port, status); let previous_status = port_state.status; @@ -158,7 +158,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, port_state.sw_status_event = status_changed; if port_state.sw_status_event != PortStatusChanged::none() { // Have a status changed event, notify - trace!("Port{} status changed: {:#?}", i, status); + trace!("{} status changed: {:#?}", local_port, status); self.sw_status_event.signal(()); } } @@ -174,7 +174,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, status: &PortStatus, ) -> Result<(), Error<::BusError>> { if port.0 as usize >= self.registration.num_ports() { - error!("Invalid port {}", port.0); + error!("Invalid {}", port); return PdError::InvalidPort.into(); } @@ -227,12 +227,12 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .map_err(Error::Pd)?; let status = controller.get_port_status(local_port_id).await?; - trace!("Port{} status: {:#?}", global_port_id.0, status); + trace!("{} status: {:#?}", global_port_id, status); let power = self .get_power_device(local_port_id) .ok_or(Error::Pd(PdError::InvalidPort))?; - trace!("Port{} status events: {:#?}", global_port_id.0, status_event); + trace!("{} status events: {:#?}", global_port_id, status_event); if status_event.plug_inserted_or_removed() { self.process_plug_event(controller, power, local_port_id, &status) .await?; @@ -292,7 +292,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let mut pending = PortPending::none(); pending.pend_port(global_port_id.0 as usize); self.registration.pd_controller.notify_ports(pending).await; - trace!("P{}: Notified service for events: {:#?}", global_port_id.0, events); + trace!("{}: Notified service for events: {:#?}", global_port_id, events); } Ok(()) @@ -436,7 +436,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, Either5::Fourth(event) => return Ok(Event::CfuEvent(event)), Either5::Fifth(port) => { // Sink ready timeout event - debug!("Port{0}: Sink ready timeout", port.0); + debug!("{}: Sink ready timeout", port); self.state.lock().await.port_states_mut()[port.0 as usize].sink_ready_deadline = None; let mut status_event = PortStatusChanged::none(); status_event.set_sink_ready(true); @@ -456,7 +456,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, match notification { PortNotificationSingle::Alert => { let ado = controller.get_pd_alert(port).await?; - trace!("Port{}: PD alert: {:#?}", port.0, ado); + trace!("{}: PD alert: {:#?}", port, ado); if let Some(ado) = ado { Ok(Output::PdAlert(OutputPdAlert { port, ado })) } else { @@ -473,7 +473,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .map(Output::DpStatusUpdate), rest => { // Nothing currently implemented for these - trace!("Port{}: Notification: {:#?}", port.0, rest); + trace!("{}: Notification: {:#?}", port, rest); Ok(Output::Nop) } } @@ -590,9 +590,9 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, for device in self.registration.power_devices { policy::register_device(device).await.map_err(|_| { error!( - "Controller{}: Failed to register power device {}", - self.registration.pd_controller.id().0, - device.id().0 + "{}: Failed to register power device {}", + self.registration.pd_controller.id(), + device.id() ); Error::Pd(PdError::Failed) })?; @@ -602,8 +602,8 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .await .map_err(|_| { error!( - "Controller{}: Failed to register PD controller", - self.registration.pd_controller.id().0 + "{}: Failed to register PD controller", + self.registration.pd_controller.id() ); Error::Pd(PdError::Failed) })?; @@ -613,8 +613,8 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .await .map_err(|_| { error!( - "Controller{}: Failed to register CFU device", - self.registration.pd_controller.id().0 + "{}: Failed to register CFU device", + self.registration.pd_controller.id() ); Error::Pd(PdError::Failed) })?; diff --git a/type-c-service/src/wrapper/pd.rs b/type-c-service/src/wrapper/pd.rs index e2e8fa5a..f849d7fe 100644 --- a/type-c-service/src/wrapper/pd.rs +++ b/type-c-service/src/wrapper/pd.rs @@ -28,7 +28,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, Some(WaitResult::Message(alert)) => return Ok(Some(alert)), None => return Ok(None), Some(WaitResult::Lagged(count)) => { - warn!("Port{}: Lagged PD alert channel: {}", local_port.0, count); + warn!("{}: Lagged PD alert channel: {}", local_port, count); // Yield to avoid starving other tasks since we're in a loop and try_next_message isn't async yield_now().await; } @@ -62,13 +62,13 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, } else { T_SRC_TRANS_REQ_SPR_MS }; - debug!("Port{}: Sink ready timeout started for {}ms", port.0, timeout_ms); + debug!("{}: Sink ready timeout started for {}ms", port, timeout_ms); *deadline = Some(Instant::now() + Duration::from_millis(timeout_ms as u64)); } else if deadline.is_some() && (!status.is_connected() || status.available_sink_contract.is_none() || sink_ready) { // Clear the timeout - debug!("Port{}: Sink ready timeout cleared", port.0); + debug!("{}: Sink ready timeout cleared", port); *deadline = None; } Ok(()) @@ -89,7 +89,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, if let Some(deadline) = deadline { Timer::at(deadline).await; - debug!("Port{}: Sink ready timeout reached", i); + debug!("{}: Sink ready timeout reached", LocalPortId(i as u8)); self.state.lock().await.port_states_mut()[i].sink_ready_deadline = None; } else { pending::<()>().await; @@ -120,9 +120,9 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let power_device = self.get_power_device(local_port).ok_or(PdError::InvalidPort)?; let state = power_device.state().await; - debug!("Port{}: Current state: {:#?}", local_port.0, state); + debug!("{}: Current state: {:#?}", local_port, state); if let Ok(connected_consumer) = power_device.try_device_action::().await { - debug!("Port{}: Set max sink voltage, connected consumer found", local_port.0); + debug!("{}: Set max sink voltage, connected consumer found", local_port); if voltage_mv.is_some() && voltage_mv < power_device @@ -133,8 +133,8 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, // New max voltage is lower than current consumer capability which will trigger a renegociation // So disconnect first debug!( - "Port{}: Disconnecting consumer before setting max sink voltage", - local_port.0 + "{}: Disconnecting consumer before setting max sink voltage", + local_port ); let _ = connected_consumer.disconnect().await; } @@ -278,7 +278,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, } controller::PortCommandData::GetOtherVdm => match controller.get_other_vdm(local_port).await { Ok(vdm) => { - debug!("Port{}: Other VDM: {:?}", local_port.0, vdm); + debug!("{}: Other VDM: {:?}", local_port, vdm); Ok(controller::PortResponseData::OtherVdm(vdm)) } Err(e) => match e { @@ -288,7 +288,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, }, controller::PortCommandData::GetAttnVdm => match controller.get_attn_vdm(local_port).await { Ok(vdm) => { - debug!("Port{}: Attention VDM: {:?}", local_port.0, vdm); + debug!("{}: Attention VDM: {:?}", local_port, vdm); Ok(controller::PortResponseData::AttnVdm(vdm)) } Err(e) => match e { @@ -314,7 +314,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, } controller::PortCommandData::GetDpStatus => match controller.get_dp_status(local_port).await { Ok(status) => { - debug!("Port{}: DP Status: {:?}", local_port.0, status); + debug!("{}: DP Status: {:?}", local_port, status); Ok(controller::PortResponseData::DpStatus(status)) } Err(e) => match e { diff --git a/type-c-service/src/wrapper/power.rs b/type-c-service/src/wrapper/power.rs index 56f0a6ba..dab2a484 100644 --- a/type-c-service/src/wrapper/power.rs +++ b/type-c-service/src/wrapper/power.rs @@ -136,7 +136,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, ) -> Result<(), Error<::BusError>> { let state = power.state().await.kind(); if state == StateKind::ConnectedConsumer { - info!("Port{}: Disconnect from ConnectedConsumer", port.0); + info!("{}: Disconnect from ConnectedConsumer", port); if controller.enable_sink_path(port, false).await.is_err() { error!("Error disabling sink path"); return PdError::Failed.into(); @@ -153,7 +153,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, capability: ProviderPowerCapability, _controller: &mut C, ) -> Result<(), Error> { - info!("Port{}: Connect as provider: {:#?}", port.0, capability); + info!("{}: Connect as provider: {:#?}", port, capability); // TODO: double check explicit contract handling Ok(()) } @@ -190,16 +190,16 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, port: LocalPortId, command: &CommandData, ) -> InternalResponseData { - trace!("Processing power command: device{} {:#?}", port.0, command); + trace!("Processing power command: {} {:#?}", port, command); if state.controller_state().fw_update_state.in_progress() { - debug!("Port{}: Firmware update in progress", port.0); + debug!("{}: Firmware update in progress", port); return Err(policy::Error::Busy); } let power = match self.get_power_device(port) { Some(power) => power, None => { - error!("Port{}: Error getting power device for port", port.0); + error!("{}: Error getting power device for port", port); return Err(policy::Error::InvalidDevice); } }; @@ -207,8 +207,8 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, match command { policy::device::CommandData::ConnectAsConsumer(capability) => { info!( - "Port{}: Connect as consumer: {:?}, enable input switch", - port.0, capability + "{}: Connect as consumer: {:?}, enable input switch", + port, capability ); if controller.enable_sink_path(port, true).await.is_err() { error!("Error enabling sink path"); diff --git a/type-c-service/src/wrapper/vdm.rs b/type-c-service/src/wrapper/vdm.rs index 8fdd64d4..bb2b5c4b 100644 --- a/type-c-service/src/wrapper/vdm.rs +++ b/type-c-service/src/wrapper/vdm.rs @@ -20,7 +20,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, port: LocalPortId, event: VdmNotification, ) -> Result::BusError>> { - trace!("Processing VDM event: {:?} on port {}", event, port.0); + trace!("Processing VDM event: {:?} on {}", event, port); let kind = match event { VdmNotification::Entered => OutputKind::Entered(controller.get_other_vdm(port).await?), VdmNotification::Exited => OutputKind::Exited(controller.get_other_vdm(port).await?), From 4197a4f9d90dd5ab4bbd14e973d39a5b4f0aa06e Mon Sep 17 00:00:00 2001 From: Adam Sasine Date: Wed, 22 Oct 2025 15:20:01 -0700 Subject: [PATCH 2/6] Change to debug formatting --- embedded-service/src/power/policy/mod.rs | 7 --- examples/std/src/bin/type_c/basic.rs | 8 ++-- examples/std/src/bin/type_c/service.rs | 6 +-- .../std/src/lib/type_c/mock_controller.rs | 8 ++-- type-c-service/src/driver/tps6699x.rs | 46 +++++++++---------- type-c-service/src/service/mod.rs | 14 +++--- type-c-service/src/service/power.rs | 2 +- type-c-service/src/wrapper/cfu.rs | 14 +++--- type-c-service/src/wrapper/dp.rs | 2 +- type-c-service/src/wrapper/mod.rs | 24 +++++----- type-c-service/src/wrapper/pd.rs | 20 ++++---- type-c-service/src/wrapper/power.rs | 17 +++---- type-c-service/src/wrapper/vdm.rs | 2 +- 13 files changed, 82 insertions(+), 88 deletions(-) diff --git a/embedded-service/src/power/policy/mod.rs b/embedded-service/src/power/policy/mod.rs index fd7a4382..65fc5b90 100644 --- a/embedded-service/src/power/policy/mod.rs +++ b/embedded-service/src/power/policy/mod.rs @@ -40,13 +40,6 @@ pub enum Error { #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct DeviceId(pub u8); -#[cfg(not(feature = "defmt"))] -impl core::fmt::Display for DeviceId { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "DeviceId({})", self.0) - } -} - /// Amount of power that a device can provider or consume #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] diff --git a/examples/std/src/bin/type_c/basic.rs b/examples/std/src/bin/type_c/basic.rs index 2c057bfc..5f99d3ff 100644 --- a/examples/std/src/bin/type_c/basic.rs +++ b/examples/std/src/bin/type_c/basic.rs @@ -72,14 +72,14 @@ mod test_controller { async fn process_ucsi_command(&self, command: &lpm::GlobalCommand) -> ucsi::GlobalResponse { match command.operation() { lpm::CommandData::ConnectorReset => { - info!("Reset for {}", command.port()); + info!("Reset for {:?}", command.port()); ucsi::Response { cci: ucsi::cci::Cci::new_cmd_complete(), data: None, } } rest => { - info!("UCSI command {:#?} for {}", rest, command.port()); + info!("UCSI command {:#?} for {:?}", rest, command.port()); ucsi::Response { cci: ucsi::cci::Cci::new_cmd_complete(), data: None, @@ -94,11 +94,11 @@ mod test_controller { ) -> Result { Ok(match command.data { controller::PortCommandData::PortStatus(Cached(true)) => { - info!("Port status for {}", command.port); + info!("Port status for {:?}", command.port); controller::PortResponseData::PortStatus(PortStatus::new()) } _ => { - info!("Port command for {}", command.port); + info!("Port command for {:?}", command.port); controller::PortResponseData::Complete } }) diff --git a/examples/std/src/bin/type_c/service.rs b/examples/std/src/bin/type_c/service.rs index 0534cb72..fb900709 100644 --- a/examples/std/src/bin/type_c/service.rs +++ b/examples/std/src/bin/type_c/service.rs @@ -42,9 +42,9 @@ mod debug { fn receive(&self, message: &comms::Message) -> Result<(), comms::MailboxDelegateError> { if let Some(message) = message.data.get::() { if message.connected { - info!("{}: Debug accessory connected", message.port); + info!("{:?}: Debug accessory connected", message.port); } else { - info!("{}: Debug accessory disconnected", message.port); + info!("{:?}: Debug accessory disconnected", message.port); } } @@ -88,7 +88,7 @@ async fn controller_task(state: &'static mock_controller::ControllerState) { let output = output.unwrap(); if let Output::PdAlert(OutputPdAlert { port, ado }) = &output { - info!("{}: PD alert received: {:?}", port, ado); + info!("{:?}: PD alert received: {:?}", port, ado); } if let Err(e) = wrapper.finalize(output).await { diff --git a/examples/std/src/lib/type_c/mock_controller.rs b/examples/std/src/lib/type_c/mock_controller.rs index 75f8f581..f1a76a04 100644 --- a/examples/std/src/lib/type_c/mock_controller.rs +++ b/examples/std/src/lib/type_c/mock_controller.rs @@ -182,10 +182,10 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { async fn get_pd_alert(&mut self, port: LocalPortId) -> Result, Error> { let pd_alert = self.state.pd_alert.lock().await; if let Some(ado) = *pd_alert { - debug!("{}: Get PD alert: {ado:#?}", port); + debug!("{:?}: Get PD alert: {ado:#?}", port); Ok(Some(ado)) } else { - debug!("{}: No PD alert", port); + debug!("{:?}: No PD alert", port); Ok(None) } } @@ -224,7 +224,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { port: LocalPortId, voltage_mv: Option, ) -> Result<(), Error> { - debug!("Set max sink voltage for {}: {:?}", port, voltage_mv); + debug!("Set max sink voltage for {:?}: {:?}", port, voltage_mv); Ok(()) } @@ -313,7 +313,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { &mut self, command: lpm::LocalCommand, ) -> Result, Error> { - debug!("Execute UCSI command for {}: {command:?}", command.port()); + debug!("Execute UCSI command for {:?}: {command:?}", command.port()); match command.operation() { lpm::CommandData::GetConnectorStatus => Ok(Some(lpm::ResponseData::GetConnectorStatus( lpm::get_connector_status::ResponseData::default(), diff --git a/type-c-service/src/driver/tps6699x.rs b/type-c-service/src/driver/tps6699x.rs index 60360e39..81f519e7 100644 --- a/type-c-service/src/driver/tps6699x.rs +++ b/type-c-service/src/driver/tps6699x.rs @@ -294,21 +294,21 @@ impl Controller for Tps6699x<'_, M, B> { } let status = self.tps6699x.get_port_status(port).await?; - trace!("{} status: {:#?}", port, status); + trace!("{:?} status: {:#?}", port, status); let pd_status = self.tps6699x.get_pd_status(port).await?; - trace!("{} PD status: {:#?}", port, pd_status); + trace!("{:?} PD status: {:#?}", port, pd_status); let port_control = self.tps6699x.get_port_control(port).await?; - trace!("{} control: {:#?}", port, port_control); + trace!("{:?} control: {:#?}", port, port_control); let mut port_status = PortStatus::default(); let plug_present = status.plug_present(); port_status.connection_state = status.connection_state().try_into().ok(); - debug!("{} Plug present: {}", port, plug_present); - debug!("{} Valid connection: {}", port, port_status.is_connected()); + debug!("{:?} Plug present: {}", port, plug_present); + debug!("{:?} Valid connection: {}", port, port_status.is_connected()); if port_status.is_connected() { // Determine current contract if any @@ -339,7 +339,7 @@ impl Controller for Tps6699x<'_, M, B> { if num_sprs == 0 { // USB PD spec requires at least one source PDO be present, something is really wrong - error!("{} no source PDOs found", port); + error!("{:?} no source PDOs found", port); return Err(PdError::InvalidParams.into()); } @@ -354,7 +354,7 @@ impl Controller for Tps6699x<'_, M, B> { } else if pd_status.is_source() { // Implicit source contract let current = TypecCurrent::try_from(port_control.typec_current()).map_err(Error::Pd)?; - debug!("{} type-C source current: {:#?}", port, current); + debug!("{:?} type-C source current: {:#?}", port, current); let new_contract = Some(PowerCapability::from(current)); port_status.available_source_contract = new_contract; } else { @@ -362,11 +362,11 @@ impl Controller for Tps6699x<'_, M, B> { let pull = pd_status.cc_pull_up(); let new_contract = if pull == PdCcPullUp::NoPull { // No pull up means no contract - debug!("{} no pull up", port); + debug!("{:?} no pull up", port); None } else { let current = TypecCurrent::try_from(pd_status.cc_pull_up()).map_err(Error::Pd)?; - debug!("{} type-C sink current: {:#?}", port, current); + debug!("{:?} type-C sink current: {:#?}", port, current); Some(PowerCapability::from(current)) }; port_status.available_sink_contract = new_contract; @@ -390,12 +390,12 @@ impl Controller for Tps6699x<'_, M, B> { // Update alt-mode status let alt_mode = self.tps6699x.get_alt_mode_status(port).await?; - debug!("{} alt mode: {:#?}", port, alt_mode); + debug!("{:?} alt mode: {:#?}", port, alt_mode); port_status.alt_mode = alt_mode; // Update power path status let power_path = self.tps6699x.get_power_path_status(port).await?; - trace!("{} power source: {:#?}", port, power_path); + trace!("{:?} power source: {:#?}", port, power_path); port_status.power_path = match port { PORT0 => PowerPathStatus::new( power_path.pa_ext_vbus_sw() == PpExtVbusSw::EnabledInput, @@ -407,7 +407,7 @@ impl Controller for Tps6699x<'_, M, B> { ), _ => Err(PdError::InvalidPort)?, }; - debug!("{} power path: {:#?}", port, port_status.power_path); + debug!("{:?} power path: {:#?}", port, port_status.power_path); } Ok(port_status) @@ -449,7 +449,7 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.execute_muxr(port, input).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing MuxR on {}: {:#?}", port, r); + debug!("Error executing MuxR on {:?}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } @@ -459,19 +459,19 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.execute_dbfg(port).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing DBfg on {}: {:#?}", port, r); + debug!("Error executing DBfg on {:?}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } } async fn enable_sink_path(&mut self, port: LocalPortId, enable: bool) -> Result<(), Error> { - debug!("{} enable sink path: {}", port, enable); + debug!("{:?} enable sink path: {}", port, enable); match self.tps6699x.enable_sink_path(port, enable).await { // Temporary workaround for autofet rejection // Tracking bug: https://github.com/OpenDevicePartnership/embedded-services/issues/268 Err(Error::Pd(PdError::Rejected)) | Err(Error::Pd(PdError::Timeout)) => { - info!("{} autofet rejection, ignored", port); + info!("{:?} autofet rejection, ignored", port); Ok(()) } rest => rest, @@ -638,7 +638,7 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.send_vdms(port, input).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing VDMs on {}: {:#?}", port, r); + debug!("Error executing VDMs on {:?}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } @@ -675,7 +675,7 @@ impl Controller for Tps6699x<'_, M, B> { async fn get_dp_status(&mut self, port: LocalPortId) -> Result> { let dp_status = self.tps6699x.get_dp_status(port).await?; - debug!("{} DP status: {:#?}", port, dp_status); + debug!("{:?} DP status: {:#?}", port, dp_status); let alt_mode_entered = dp_status.dp_mode_active() != 0; @@ -694,7 +694,7 @@ impl Controller for Tps6699x<'_, M, B> { port: LocalPortId, config: controller::DpConfig, ) -> Result<(), Error> { - debug!("{} setting DP config: {:#?}", port, config); + debug!("{:?} setting DP config: {:#?}", port, config); let mut dp_config_reg = self.tps6699x.get_dp_config(port).await?; @@ -712,14 +712,14 @@ impl Controller for Tps6699x<'_, M, B> { match self.tps6699x.execute_drst(port).await? { ReturnValue::Success => Ok(()), r => { - debug!("Error executing DRST on {}: {:#?}", port, r); + debug!("Error executing DRST on {:?}: {:#?}", port, r); Err(Error::Pd(PdError::InvalidResponse)) } } } async fn set_tbt_config(&mut self, port: LocalPortId, config: TbtConfig) -> Result<(), Error> { - debug!("{} setting TBT config: {:#?}", port, config); + debug!("{:?} setting TBT config: {:#?}", port, config); let mut config_reg = self.tps6699x.lock_inner().await.get_tbt_config(port).await?; @@ -734,7 +734,7 @@ impl Controller for Tps6699x<'_, M, B> { port: LocalPortId, config: controller::PdStateMachineConfig, ) -> Result<(), Error> { - debug!("{} setting PD state machine config: {:#?}", port, config); + debug!("{:?} setting PD state machine config: {:#?}", port, config); let mut config_reg = self.tps6699x.lock_inner().await.get_port_config(port).await?; @@ -748,7 +748,7 @@ impl Controller for Tps6699x<'_, M, B> { port: LocalPortId, state: controller::TypeCStateMachineState, ) -> Result<(), Error> { - debug!("{} setting Type-C state machine state: {:#?}", port, state); + debug!("{:?} setting Type-C state machine state: {:#?}", port, state); let mut config_reg = self.tps6699x.lock_inner().await.get_port_config(port).await?; let typec_state = match state { diff --git a/type-c-service/src/service/mod.rs b/type-c-service/src/service/mod.rs index f475a5e0..dd82fb55 100644 --- a/type-c-service/src/service/mod.rs +++ b/type-c-service/src/service/mod.rs @@ -137,9 +137,9 @@ impl<'a> Service<'a> { ) -> Result<(), Error> { let old_status = self.get_cached_port_status(port_id).await?; - debug!("{}: Event: {:#?}", port_id, event); - debug!("{} Previous status: {:#?}", port_id, old_status); - debug!("{} Status: {:#?}", port_id, status); + debug!("{:?}: Event: {:#?}", port_id, event); + debug!("{:?} Previous status: {:#?}", port_id, old_status); + debug!("{:?} Status: {:#?}", port_id, status); let connection_changed = status.is_connected() != old_status.is_connected(); if connection_changed && (status.is_debug_accessory() || old_status.is_debug_accessory()) { @@ -150,9 +150,9 @@ impl<'a> Service<'a> { }; if status.is_connected() { - debug!("{}: Debug accessory connected", port_id); + debug!("{:?}: Debug accessory connected", port_id); } else { - debug!("{}: Debug accessory disconnected", port_id); + debug!("{:?}: Debug accessory disconnected", port_id); } if self.tp.send(EndpointID::Internal(Internal::Usbc), &msg).await.is_err() { @@ -219,12 +219,12 @@ impl<'a> Service<'a> { pub async fn process_event(&self, event: Event<'_>) -> Result<(), Error> { match event { Event::PortStatusChanged(port, event_kind, status) => { - trace!("{}: Processing port status changed", port); + trace!("{:?}: Processing port status changed", port); self.process_port_event(port, event_kind, status).await } Event::PortNotification(port, notification) => { // Other port notifications - info!("{}: Got port notification: {:?}", port, notification); + info!("{:?}: Got port notification: {:?}", port, notification); Ok(()) } Event::ExternalCommand(request) => { diff --git a/type-c-service/src/service/power.rs b/type-c-service/src/service/power.rs index 0eee4028..32ad34e9 100644 --- a/type-c-service/src/service/power.rs +++ b/type-c-service/src/service/power.rs @@ -63,7 +63,7 @@ impl<'a> Service<'a> { // If it switches to sourcing then the system will no longer be unconstrained // So set that port to constrained and unconstrain all others info!( - "Setting {} to constrained, all others unconstrained", + "Setting {:?} to constrained, all others unconstrained", GlobalPortId(unconstrained_index as u8) ); for port_index in 0..num_ports { diff --git a/type-c-service/src/wrapper/cfu.rs b/type-c-service/src/wrapper/cfu.rs index 629a2804..7125b6d2 100644 --- a/type-c-service/src/wrapper/cfu.rs +++ b/type-c-service/src/wrapper/cfu.rs @@ -128,24 +128,24 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let controller_id = self.registration.pd_controller.id(); let mut detached_all = true; for power in self.registration.power_devices { - info!("{}: checking power device", controller_id); + info!("{:?}: checking power device", controller_id); if power.state().await != power::policy::device::State::Detached { - info!("{}: Detaching power device", controller_id); + info!("{:?}: Detaching power device", controller_id); if let Err(e) = power.detach().await { - error!("{}: Failed to detach power device: {:?}", controller_id, e); + error!("{:?}: Failed to detach power device: {:?}", controller_id, e); // Sync to bring the controller to a known state with all services match self.sync_state_internal(controller, state).await { Ok(_) => debug!( - "{}: Synced state after detaching power device", + "{:?}: Synced state after detaching power device", controller_id ), Err(Error::Pd(e)) => error!( - "{}: Failed to sync state after detaching power device: {:?}", + "{:?}: Failed to sync state after detaching power device: {:?}", controller_id, e ), Err(Error::Bus(_)) => error!( - "{}: Failed to sync state after detaching power device, bus error", + "{:?}: Failed to sync state after detaching power device, bus error", controller_id ), } @@ -158,7 +158,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, if !detached_all { error!( - "{}: Failed to detach all power devices, rejecting offer", + "{:?}: Failed to detach all power devices, rejecting offer", controller_id ); return InternalResponseData::ContentResponse(FwUpdateContentResponse::new( diff --git a/type-c-service/src/wrapper/dp.rs b/type-c-service/src/wrapper/dp.rs index 0b13b29e..4ce84fb6 100644 --- a/type-c-service/src/wrapper/dp.rs +++ b/type-c-service/src/wrapper/dp.rs @@ -11,7 +11,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, controller: &mut C, port: LocalPortId, ) -> Result::BusError>> { - trace!("Processing DP status update event on {}", port); + trace!("Processing DP status update event on {:?}", port); let status = controller.get_dp_status(port).await?; Ok(OutputDpStatusChanged { port, status }) diff --git a/type-c-service/src/wrapper/mod.rs b/type-c-service/src/wrapper/mod.rs index 160e192e..0edc947c 100644 --- a/type-c-service/src/wrapper/mod.rs +++ b/type-c-service/src/wrapper/mod.rs @@ -139,7 +139,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let mut status_changed = port_state.sw_status_event; let local_port = LocalPortId(i as u8); let status = controller.get_port_status(local_port).await?; - trace!("{} status: {:#?}", local_port, status); + trace!("{:?} status: {:#?}", local_port, status); let previous_status = port_state.status; @@ -158,7 +158,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, port_state.sw_status_event = status_changed; if port_state.sw_status_event != PortStatusChanged::none() { // Have a status changed event, notify - trace!("{} status changed: {:#?}", local_port, status); + trace!("{:?} status changed: {:#?}", local_port, status); self.sw_status_event.signal(()); } } @@ -174,7 +174,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, status: &PortStatus, ) -> Result<(), Error<::BusError>> { if port.0 as usize >= self.registration.num_ports() { - error!("Invalid {}", port); + error!("Invalid {:?}", port); return PdError::InvalidPort.into(); } @@ -227,12 +227,12 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .map_err(Error::Pd)?; let status = controller.get_port_status(local_port_id).await?; - trace!("{} status: {:#?}", global_port_id, status); + trace!("{:?} status: {:#?}", global_port_id, status); let power = self .get_power_device(local_port_id) .ok_or(Error::Pd(PdError::InvalidPort))?; - trace!("{} status events: {:#?}", global_port_id, status_event); + trace!("{:?} status events: {:#?}", global_port_id, status_event); if status_event.plug_inserted_or_removed() { self.process_plug_event(controller, power, local_port_id, &status) .await?; @@ -292,7 +292,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let mut pending = PortPending::none(); pending.pend_port(global_port_id.0 as usize); self.registration.pd_controller.notify_ports(pending).await; - trace!("{}: Notified service for events: {:#?}", global_port_id, events); + trace!("{:?}: Notified service for events: {:#?}", global_port_id, events); } Ok(()) @@ -436,7 +436,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, Either5::Fourth(event) => return Ok(Event::CfuEvent(event)), Either5::Fifth(port) => { // Sink ready timeout event - debug!("{}: Sink ready timeout", port); + debug!("{:?}: Sink ready timeout", port); self.state.lock().await.port_states_mut()[port.0 as usize].sink_ready_deadline = None; let mut status_event = PortStatusChanged::none(); status_event.set_sink_ready(true); @@ -456,7 +456,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, match notification { PortNotificationSingle::Alert => { let ado = controller.get_pd_alert(port).await?; - trace!("{}: PD alert: {:#?}", port, ado); + trace!("{:?}: PD alert: {:#?}", port, ado); if let Some(ado) = ado { Ok(Output::PdAlert(OutputPdAlert { port, ado })) } else { @@ -473,7 +473,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .map(Output::DpStatusUpdate), rest => { // Nothing currently implemented for these - trace!("{}: Notification: {:#?}", port, rest); + trace!("{:?}: Notification: {:#?}", port, rest); Ok(Output::Nop) } } @@ -590,7 +590,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, for device in self.registration.power_devices { policy::register_device(device).await.map_err(|_| { error!( - "{}: Failed to register power device {}", + "{:?}: Failed to register power device {:?}", self.registration.pd_controller.id(), device.id() ); @@ -602,7 +602,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .await .map_err(|_| { error!( - "{}: Failed to register PD controller", + "{:?}: Failed to register PD controller", self.registration.pd_controller.id() ); Error::Pd(PdError::Failed) @@ -613,7 +613,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, .await .map_err(|_| { error!( - "{}: Failed to register CFU device", + "{:?}: Failed to register CFU device", self.registration.pd_controller.id() ); Error::Pd(PdError::Failed) diff --git a/type-c-service/src/wrapper/pd.rs b/type-c-service/src/wrapper/pd.rs index f849d7fe..396cd7f8 100644 --- a/type-c-service/src/wrapper/pd.rs +++ b/type-c-service/src/wrapper/pd.rs @@ -28,7 +28,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, Some(WaitResult::Message(alert)) => return Ok(Some(alert)), None => return Ok(None), Some(WaitResult::Lagged(count)) => { - warn!("{}: Lagged PD alert channel: {}", local_port, count); + warn!("{:?}: Lagged PD alert channel: {}", local_port, count); // Yield to avoid starving other tasks since we're in a loop and try_next_message isn't async yield_now().await; } @@ -62,13 +62,13 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, } else { T_SRC_TRANS_REQ_SPR_MS }; - debug!("{}: Sink ready timeout started for {}ms", port, timeout_ms); + debug!("{:?}: Sink ready timeout started for {}ms", port, timeout_ms); *deadline = Some(Instant::now() + Duration::from_millis(timeout_ms as u64)); } else if deadline.is_some() && (!status.is_connected() || status.available_sink_contract.is_none() || sink_ready) { // Clear the timeout - debug!("{}: Sink ready timeout cleared", port); + debug!("{:?}: Sink ready timeout cleared", port); *deadline = None; } Ok(()) @@ -89,7 +89,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, if let Some(deadline) = deadline { Timer::at(deadline).await; - debug!("{}: Sink ready timeout reached", LocalPortId(i as u8)); + debug!("{:?}: Sink ready timeout reached", LocalPortId(i as u8)); self.state.lock().await.port_states_mut()[i].sink_ready_deadline = None; } else { pending::<()>().await; @@ -120,9 +120,9 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, let power_device = self.get_power_device(local_port).ok_or(PdError::InvalidPort)?; let state = power_device.state().await; - debug!("{}: Current state: {:#?}", local_port, state); + debug!("{:?}: Current state: {:#?}", local_port, state); if let Ok(connected_consumer) = power_device.try_device_action::().await { - debug!("{}: Set max sink voltage, connected consumer found", local_port); + debug!("{:?}: Set max sink voltage, connected consumer found", local_port); if voltage_mv.is_some() && voltage_mv < power_device @@ -133,7 +133,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, // New max voltage is lower than current consumer capability which will trigger a renegociation // So disconnect first debug!( - "{}: Disconnecting consumer before setting max sink voltage", + "{:?}: Disconnecting consumer before setting max sink voltage", local_port ); let _ = connected_consumer.disconnect().await; @@ -278,7 +278,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, } controller::PortCommandData::GetOtherVdm => match controller.get_other_vdm(local_port).await { Ok(vdm) => { - debug!("{}: Other VDM: {:?}", local_port, vdm); + debug!("{:?}: Other VDM: {:?}", local_port, vdm); Ok(controller::PortResponseData::OtherVdm(vdm)) } Err(e) => match e { @@ -288,7 +288,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, }, controller::PortCommandData::GetAttnVdm => match controller.get_attn_vdm(local_port).await { Ok(vdm) => { - debug!("{}: Attention VDM: {:?}", local_port, vdm); + debug!("{:?}: Attention VDM: {:?}", local_port, vdm); Ok(controller::PortResponseData::AttnVdm(vdm)) } Err(e) => match e { @@ -314,7 +314,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, } controller::PortCommandData::GetDpStatus => match controller.get_dp_status(local_port).await { Ok(status) => { - debug!("{}: DP Status: {:?}", local_port, status); + debug!("{:?}: DP Status: {:?}", local_port, status); Ok(controller::PortResponseData::DpStatus(status)) } Err(e) => match e { diff --git a/type-c-service/src/wrapper/power.rs b/type-c-service/src/wrapper/power.rs index dab2a484..779cd1c8 100644 --- a/type-c-service/src/wrapper/power.rs +++ b/type-c-service/src/wrapper/power.rs @@ -136,7 +136,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, ) -> Result<(), Error<::BusError>> { let state = power.state().await.kind(); if state == StateKind::ConnectedConsumer { - info!("{}: Disconnect from ConnectedConsumer", port); + info!("{:?}: Disconnect from ConnectedConsumer", port); if controller.enable_sink_path(port, false).await.is_err() { error!("Error disabling sink path"); return PdError::Failed.into(); @@ -153,7 +153,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, capability: ProviderPowerCapability, _controller: &mut C, ) -> Result<(), Error> { - info!("{}: Connect as provider: {:#?}", port, capability); + info!("{:?}: Connect as provider: {:#?}", port, capability); // TODO: double check explicit contract handling Ok(()) } @@ -177,8 +177,9 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, }); // DROP SAFETY: Select over drop safe futures let (request, local_id) = select_array(futures).await; - trace!("Power command: device{} {:#?}", local_id, request.command); - (LocalPortId(local_id as u8), request) + let local_id = LocalPortId(local_id as u8); + trace!("Power command: {:?} {:#?}", local_id, request.command); + (local_id, request) } /// Process a power command @@ -190,16 +191,16 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, port: LocalPortId, command: &CommandData, ) -> InternalResponseData { - trace!("Processing power command: {} {:#?}", port, command); + trace!("Processing power command: {:?} {:#?}", port, command); if state.controller_state().fw_update_state.in_progress() { - debug!("{}: Firmware update in progress", port); + debug!("{:?}: Firmware update in progress", port); return Err(policy::Error::Busy); } let power = match self.get_power_device(port) { Some(power) => power, None => { - error!("{}: Error getting power device for port", port); + error!("{:?}: Error getting power device for port", port); return Err(policy::Error::InvalidDevice); } }; @@ -207,7 +208,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, match command { policy::device::CommandData::ConnectAsConsumer(capability) => { info!( - "{}: Connect as consumer: {:?}, enable input switch", + "{:?}: Connect as consumer: {:?}, enable input switch", port, capability ); if controller.enable_sink_path(port, true).await.is_err() { diff --git a/type-c-service/src/wrapper/vdm.rs b/type-c-service/src/wrapper/vdm.rs index bb2b5c4b..28ee334f 100644 --- a/type-c-service/src/wrapper/vdm.rs +++ b/type-c-service/src/wrapper/vdm.rs @@ -20,7 +20,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, port: LocalPortId, event: VdmNotification, ) -> Result::BusError>> { - trace!("Processing VDM event: {:?} on {}", event, port); + trace!("Processing VDM event: {:?} on {:?}", event, port); let kind = match event { VdmNotification::Entered => OutputKind::Entered(controller.get_other_vdm(port).await?), VdmNotification::Exited => OutputKind::Exited(controller.get_other_vdm(port).await?), From c4b335eaf8bc593bb7a08ddb194d5116a57d31a1 Mon Sep 17 00:00:00 2001 From: Adam Sasine Date: Wed, 22 Oct 2025 15:21:18 -0700 Subject: [PATCH 3/6] Format code --- type-c-service/src/wrapper/cfu.rs | 5 +---- type-c-service/src/wrapper/power.rs | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/type-c-service/src/wrapper/cfu.rs b/type-c-service/src/wrapper/cfu.rs index 7125b6d2..8207ae8c 100644 --- a/type-c-service/src/wrapper/cfu.rs +++ b/type-c-service/src/wrapper/cfu.rs @@ -136,10 +136,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, // Sync to bring the controller to a known state with all services match self.sync_state_internal(controller, state).await { - Ok(_) => debug!( - "{:?}: Synced state after detaching power device", - controller_id - ), + Ok(_) => debug!("{:?}: Synced state after detaching power device", controller_id), Err(Error::Pd(e)) => error!( "{:?}: Failed to sync state after detaching power device: {:?}", controller_id, e diff --git a/type-c-service/src/wrapper/power.rs b/type-c-service/src/wrapper/power.rs index 779cd1c8..0241fd74 100644 --- a/type-c-service/src/wrapper/power.rs +++ b/type-c-service/src/wrapper/power.rs @@ -207,10 +207,7 @@ impl<'a, M: RawMutex, C: Controller, V: FwOfferValidator> ControllerWrapper<'a, match command { policy::device::CommandData::ConnectAsConsumer(capability) => { - info!( - "{:?}: Connect as consumer: {:?}, enable input switch", - port, capability - ); + info!("{:?}: Connect as consumer: {:?}, enable input switch", port, capability); if controller.enable_sink_path(port, true).await.is_err() { error!("Error enabling sink path"); return Err(policy::Error::Failed); From fb15da875a8effd7ab2ea97d586cfabeea3e7dad Mon Sep 17 00:00:00 2001 From: Adam Sasine Date: Wed, 22 Oct 2025 15:22:07 -0700 Subject: [PATCH 4/6] Change examples to debug formatting --- .../std/src/lib/type_c/mock_controller.rs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/std/src/lib/type_c/mock_controller.rs b/examples/std/src/lib/type_c/mock_controller.rs index f1a76a04..3e9193bb 100644 --- a/examples/std/src/lib/type_c/mock_controller.rs +++ b/examples/std/src/lib/type_c/mock_controller.rs @@ -229,27 +229,27 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { } async fn reconfigure_retimer(&mut self, port: LocalPortId) -> Result<(), Error> { - debug!("reconfigure_retimer(port: {port})"); + debug!("reconfigure_retimer(port: {port:?})"); Ok(()) } async fn clear_dead_battery_flag(&mut self, port: LocalPortId) -> Result<(), Error> { - debug!("clear_dead_battery_flag(port: {port})"); + debug!("clear_dead_battery_flag(port: {port:?})"); Ok(()) } async fn get_other_vdm(&mut self, port: LocalPortId) -> Result> { - debug!("Get other VDM for {port}"); + debug!("Get other VDM for {port:?}"); Ok(OtherVdm::default()) } async fn get_attn_vdm(&mut self, port: LocalPortId) -> Result> { - debug!("Get attention VDM for {port}"); + debug!("Get attention VDM for {port:?}"); Ok(AttnVdm::default()) } async fn send_vdm(&mut self, port: LocalPortId, tx_vdm: SendVdm) -> Result<(), Error> { - debug!("Send VDM for {port}: {tx_vdm:?}"); + debug!("Send VDM for {port:?}: {tx_vdm:?}"); Ok(()) } @@ -259,14 +259,14 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { config: UsbControlConfig, ) -> Result<(), Error> { debug!( - "set_usb_control(port: {port}, usb2: {}, usb3: {}, usb4: {})", + "set_usb_control(port: {port:?}, usb2: {}, usb3: {}, usb4: {})", config.usb2_enabled, config.usb3_enabled, config.usb4_enabled ); Ok(()) } async fn get_dp_status(&mut self, port: LocalPortId) -> Result> { - debug!("Get DisplayPort status for {port}"); + debug!("Get DisplayPort status for {port:?}"); Ok(DpStatus { alt_mode_entered: false, dfp_d_pin_cfg: DpPinConfig::default(), @@ -275,19 +275,19 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { async fn set_dp_config(&mut self, port: LocalPortId, config: DpConfig) -> Result<(), Error> { debug!( - "Set DisplayPort config for {port}: enable={}, pin_cfg={:?}", + "Set DisplayPort config for {port:?}: enable={}, pin_cfg={:?}", config.enable, config.dfp_d_pin_cfg ); Ok(()) } async fn execute_drst(&mut self, port: LocalPortId) -> Result<(), Error> { - debug!("Execute PD Data Reset for {port}"); + debug!("Execute PD Data Reset for {port:?}"); Ok(()) } async fn set_tbt_config(&mut self, port: LocalPortId, config: TbtConfig) -> Result<(), Error> { - debug!("Set Thunderbolt config for {port}: {config:?}"); + debug!("Set Thunderbolt config for {port:?}: {config:?}"); Ok(()) } @@ -296,7 +296,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { port: LocalPortId, config: PdStateMachineConfig, ) -> Result<(), Error> { - debug!("Set PD State Machine config for {port}: {config:?}"); + debug!("Set PD State Machine config for {port:?}: {config:?}"); Ok(()) } @@ -305,7 +305,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { port: LocalPortId, state: TypeCStateMachineState, ) -> Result<(), Error> { - debug!("Set Type-C State Machine state for {port}: {state:?}"); + debug!("Set Type-C State Machine state for {port:?}: {state:?}"); Ok(()) } From 7a3bf1e6479fdb60b2862220d8b7c613de39db23 Mon Sep 17 00:00:00 2001 From: Adam Sasine Date: Wed, 22 Oct 2025 15:26:26 -0700 Subject: [PATCH 5/6] Inline format args --- examples/std/src/lib/type_c/mock_controller.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/std/src/lib/type_c/mock_controller.rs b/examples/std/src/lib/type_c/mock_controller.rs index 3e9193bb..4e909123 100644 --- a/examples/std/src/lib/type_c/mock_controller.rs +++ b/examples/std/src/lib/type_c/mock_controller.rs @@ -182,10 +182,10 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { async fn get_pd_alert(&mut self, port: LocalPortId) -> Result, Error> { let pd_alert = self.state.pd_alert.lock().await; if let Some(ado) = *pd_alert { - debug!("{:?}: Get PD alert: {ado:#?}", port); + debug!("{port:?}: Get PD alert: {ado:#?}"); Ok(Some(ado)) } else { - debug!("{:?}: No PD alert", port); + debug!("{port:?}: No PD alert"); Ok(None) } } @@ -224,7 +224,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> { port: LocalPortId, voltage_mv: Option, ) -> Result<(), Error> { - debug!("Set max sink voltage for {:?}: {:?}", port, voltage_mv); + debug!("Set max sink voltage for {port:?}: {voltage_mv:?}"); Ok(()) } From bd1f8c942e43afef69c184bda3d7a9e04c199046 Mon Sep 17 00:00:00 2001 From: Adam Sasine Date: Wed, 22 Oct 2025 15:34:01 -0700 Subject: [PATCH 6/6] Inline format args --- examples/std/src/bin/type_c/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/std/src/bin/type_c/service.rs b/examples/std/src/bin/type_c/service.rs index fb900709..fbc94143 100644 --- a/examples/std/src/bin/type_c/service.rs +++ b/examples/std/src/bin/type_c/service.rs @@ -88,7 +88,7 @@ async fn controller_task(state: &'static mock_controller::ControllerState) { let output = output.unwrap(); if let Output::PdAlert(OutputPdAlert { port, ado }) = &output { - info!("{:?}: PD alert received: {:?}", port, ado); + info!("{port:?}: PD alert received: {ado:?}"); } if let Err(e) = wrapper.finalize(output).await {