From a2388acf6428ba5d5a694520f8832eca2aa5fb1c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:06:54 +0000 Subject: [PATCH] fix: deactivate ComPortController on program stopping event --- .../Comm and IR/ComPortController.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs b/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs index 3dfd8632..8b28d23b 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs @@ -50,6 +50,7 @@ namespace PepperDash.Essentials.Core ComPort.ComPortSpec spec, EssentialsControlPropertiesConfig config) : base(key) { StreamDebugging = new CommunicationStreamDebugging(key); + CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler; Spec = spec; @@ -70,6 +71,8 @@ namespace PepperDash.Essentials.Core public ComPortController(string key, ComPort port, ComPort.ComPortSpec spec) : base(key) { + CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler; + if (port == null) { Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Invalid com port, continuing but comms will not function"); @@ -142,6 +145,12 @@ namespace PepperDash.Essentials.Core if (!eventSubscribed) Debug.LogMessage(LogEventLevel.Warning, this, "Received data but no handler is registered"); } + void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType) + { + if (programEventType == eProgramStatusEventType.Stopping) + Deactivate(); + } + /// /// Deactivate method ///