From 3d7bc32b8a71ec6d92411962272e5d4b68ccf4ed Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 15 Oct 2020 16:30:54 -0400 Subject: [PATCH 1/3] 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); From c253007def2e1136680ddcf91ce5ff4bb4a1dbf0 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 15 Oct 2020 16:52:24 -0400 Subject: [PATCH 2/3] Update CommunicationStreamDebugging.cs Removed unneeded change to convert item to string. --- .../Pepperdash Core/Comm/CommunicationStreamDebugging.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs index 1e9603e..4248203 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs @@ -97,7 +97,7 @@ namespace PepperDash.Core if ((setting & eStreamDebuggingSetting.Tx) == eStreamDebuggingSetting.Tx) TxStreamDebuggingIsEnabled = true; - Debug.SetDeviceDebugSettings(ParentDeviceKey, setting.ToString()); + Debug.SetDeviceDebugSettings(ParentDeviceKey, setting); } @@ -116,7 +116,7 @@ namespace PepperDash.Core RxStreamDebuggingIsEnabled = false; TxStreamDebuggingIsEnabled = false; - Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off.ToString()); + Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off); } } @@ -131,4 +131,4 @@ namespace PepperDash.Core Tx = 2, Both = Rx | Tx } -} \ No newline at end of file +} From 895873c51e767ac832899aa6933f0695a00f86f9 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 28 Oct 2020 08:58:07 -0600 Subject: [PATCH 3/3] add StopDebugTimer method --- .../Comm/CommunicationStreamDebugging.cs | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs index 4248203..b5b1c15 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/CommunicationStreamDebugging.cs @@ -79,15 +79,7 @@ namespace PepperDash.Core _DebugTimeoutInMs = minutes * 60000; - if (DebugExpiryPeriod != null) - { - DebugExpiryPeriod.Stop(); - DebugExpiryPeriod.Dispose(); - DebugExpiryPeriod = null; - } - - RxStreamDebuggingIsEnabled = false; - TxStreamDebuggingIsEnabled = false; + StopDebugTimer(); DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs); @@ -106,17 +98,24 @@ namespace PepperDash.Core /// private void DisableDebugging() { - if (DebugExpiryPeriod != null) - { - DebugExpiryPeriod.Stop(); - DebugExpiryPeriod.Dispose(); - DebugExpiryPeriod = null; - } + StopDebugTimer(); + Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off); + } + + private void StopDebugTimer() + { RxStreamDebuggingIsEnabled = false; TxStreamDebuggingIsEnabled = false; - Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off); + if (DebugExpiryPeriod == null) + { + return; + } + + DebugExpiryPeriod.Stop(); + DebugExpiryPeriod.Dispose(); + DebugExpiryPeriod = null; } }