From 3d7bc32b8a71ec6d92411962272e5d4b68ccf4ed Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 15 Oct 2020 16:30:54 -0400 Subject: [PATCH] Fixes some exceptions when setting stream debugging mode. Changes stream debugging to clear both rx and tx flags before setting mode again. --- .../Comm/CommunicationStreamDebugging.cs | 20 +++++++++++++------ .../Pepperdash Core/Logging/DebugMemory.cs | 6 ++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs index f3b5613..1e9603e 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs @@ -81,9 +81,14 @@ namespace PepperDash.Core if (DebugExpiryPeriod != null) { - DisableDebugging(); + DebugExpiryPeriod.Stop(); + DebugExpiryPeriod.Dispose(); + DebugExpiryPeriod = null; } + RxStreamDebuggingIsEnabled = false; + TxStreamDebuggingIsEnabled = false; + DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs); if ((setting & eStreamDebuggingSetting.Rx) == eStreamDebuggingSetting.Rx) @@ -92,7 +97,7 @@ namespace PepperDash.Core if ((setting & eStreamDebuggingSetting.Tx) == eStreamDebuggingSetting.Tx) TxStreamDebuggingIsEnabled = true; - Debug.SetDeviceDebugSettings(ParentDeviceKey, setting); + Debug.SetDeviceDebugSettings(ParentDeviceKey, setting.ToString()); } @@ -101,14 +106,17 @@ namespace PepperDash.Core /// private void DisableDebugging() { - DebugExpiryPeriod.Stop(); - DebugExpiryPeriod.Dispose(); - DebugExpiryPeriod = null; + if (DebugExpiryPeriod != null) + { + DebugExpiryPeriod.Stop(); + DebugExpiryPeriod.Dispose(); + DebugExpiryPeriod = null; + } RxStreamDebuggingIsEnabled = false; TxStreamDebuggingIsEnabled = false; - Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off); + Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off.ToString()); } } diff --git a/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs b/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs index 1b0fea1..5162853 100644 --- a/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs +++ b/Pepperdash Core/Pepperdash Core/Logging/DebugMemory.cs @@ -68,11 +68,9 @@ namespace PepperDash.Core.DebugThings /// public void SetDebugSettingsForKey(string deviceKey, object settings) { - var existingSettings = DeviceDebugSettings[deviceKey]; - - if (existingSettings != null) + if(DeviceDebugSettings.ContainsKey(deviceKey)) { - existingSettings = settings; + DeviceDebugSettings[deviceKey] = settings; } else DeviceDebugSettings.Add(deviceKey, settings);