From 7ac11952ebab5cfdcc63ad0ec66b2111df2f2b4f Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 18 Aug 2020 10:17:13 -0500 Subject: [PATCH] Added try/catch to ParseUptime with a way to view what was being parsed --- PepperDashEssentials/ControlSystem.cs | 3 ++ .../Devices/DeviceManager.cs | 31 +++++++++++++++- .../Monitoring/SystemMonitorController.cs | 35 +++++++++++-------- essentials-framework/pepperdashcore-builds | 2 +- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index cd9a99cb..12cba0d4 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -91,6 +91,9 @@ namespace PepperDash.Essentials }, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(DeviceManager.GetRoutingPorts, + "getroutingports", "Reports all routing ports, if any. Requires a device key", ConsoleAccessLevelEnum.AccessOperator); + if (!Debug.DoNotLoadOnNextBoot) { GoWithLoad(null); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs index dfc63911..d50de428 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs @@ -337,7 +337,36 @@ namespace PepperDash.Essentials.Core return; } com.SimulateReceive(match.Groups[2].Value); - } + } + + /// + /// Prints a list of routing inputs and outputs by device key. + /// + /// Device key from which to report data + public static void GetRoutingPorts(string s) + { + var device = GetDeviceForKey(s); + + if (device == null) return; + var inputPorts = (device as IRoutingInputsOutputs).InputPorts; + var outputPorts = (device as IRoutingInputsOutputs).OutputPorts; + if (inputPorts != null) + { + Debug.Console(0, "Device {0} has {1} Input Ports:", s, inputPorts.Count); + foreach (var routingInputPort in inputPorts) + { + Debug.Console(0, "{0}", routingInputPort.Key); + } + } + if (outputPorts != null) + { + Debug.Console(0, "Device {0} has {1} Output Ports:", s, outputPorts.Count); + foreach (var routingOutputPort in outputPorts) + { + Debug.Console(0, "{0}", routingOutputPort.Key); + } + } + } /// /// Attempts to set the debug level of a device diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs index b523d2c8..43a9ad9e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs @@ -103,20 +103,27 @@ namespace PepperDash.Essentials.Core.Monitoring } private void ParseUptime(string response) - { - var splitString = response.Trim().Split('\r', '\n'); - - var lastStartRaw = splitString[2]; - var lastStartIndex = lastStartRaw.IndexOf(':'); - - _lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim(); - - var uptimeRaw = splitString[0]; - - var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal); - - //4 => "for " to get what's on the right - _uptime = uptimeRaw.Substring(forIndex + 4); + { + try + { + var splitString = response.Trim().Split('\r', '\n'); + + var lastStartRaw = splitString[2]; + var lastStartIndex = lastStartRaw.IndexOf(':'); + + _lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim(); + + var uptimeRaw = splitString[0]; + + var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal); + + //4 => "for " to get what's on the right + _uptime = uptimeRaw.Substring(forIndex + 4); + } + catch (Exception e) + { + ErrorLog.Exception(String.Format("Exception unable to parse string '{1}'", response), e); + } } private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs) diff --git a/essentials-framework/pepperdashcore-builds b/essentials-framework/pepperdashcore-builds index b64665a6..18cb0c27 160000 --- a/essentials-framework/pepperdashcore-builds +++ b/essentials-framework/pepperdashcore-builds @@ -1 +1 @@ -Subproject commit b64665a60ebfa8cd4dc680acccb3ef0d94cbbf82 +Subproject commit 18cb0c273eb8b750f657d74160ad82eff1b24bca