Added try/catch to ParseUptime with a way to view what was being parsed

This commit is contained in:
Trevor Payne
2020-08-18 10:17:13 -05:00
parent 383777c0f5
commit 7ac11952eb
4 changed files with 55 additions and 16 deletions

View File

@@ -91,6 +91,9 @@ namespace PepperDash.Essentials
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); }, "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) if (!Debug.DoNotLoadOnNextBoot)
{ {
GoWithLoad(null); GoWithLoad(null);

View File

@@ -339,6 +339,35 @@ namespace PepperDash.Essentials.Core
com.SimulateReceive(match.Groups[2].Value); com.SimulateReceive(match.Groups[2].Value);
} }
/// <summary>
/// Prints a list of routing inputs and outputs by device key.
/// </summary>
/// <param name="s">Device key from which to report data</param>
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);
}
}
}
/// <summary> /// <summary>
/// Attempts to set the debug level of a device /// Attempts to set the debug level of a device
/// </summary> /// </summary>

View File

@@ -103,6 +103,8 @@ namespace PepperDash.Essentials.Core.Monitoring
} }
private void ParseUptime(string response) private void ParseUptime(string response)
{
try
{ {
var splitString = response.Trim().Split('\r', '\n'); var splitString = response.Trim().Split('\r', '\n');
@@ -118,6 +120,11 @@ namespace PepperDash.Essentials.Core.Monitoring
//4 => "for " to get what's on the right //4 => "for " to get what's on the right
_uptime = uptimeRaw.Substring(forIndex + 4); _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) private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs)
{ {