got DeviceInfo Parsing working correctly

This commit is contained in:
Andrew Welker
2021-02-04 11:17:49 -07:00
parent 2967a0f968
commit 4dfab9a287

View File

@@ -109,8 +109,6 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs
var tcpClient = new GenericTcpIpClient("", _dgeEthernetInfo.IpAddressFeedback.StringValue, CtpPort, 1024){AutoReconnect = false}; var tcpClient = new GenericTcpIpClient("", _dgeEthernetInfo.IpAddressFeedback.StringValue, CtpPort, 1024){AutoReconnect = false};
tcpClient.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Rx);
var gather = new CommunicationGather(tcpClient, "\r\n\r\n"); var gather = new CommunicationGather(tcpClient, "\r\n\r\n");
tcpClient.ConnectionChange += (sender, args) => tcpClient.ConnectionChange += (sender, args) =>
@@ -125,29 +123,56 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs
gather.LineReceived += (sender, args) => gather.LineReceived += (sender, args) =>
{ {
try
{
Debug.Console(1, this, "{0}", args.Text);
if (args.Text.ToLower().Contains("host")) if (args.Text.ToLower().Contains("host"))
{ {
DeviceInfo.HostName = args.Text.Split(';')[1].Trim(); DeviceInfo.HostName = args.Text.Split(':')[1].Trim();
Debug.Console(1, this, "hostname: {0}", DeviceInfo.HostName);
tcpClient.Disconnect(); tcpClient.Disconnect();
return; return;
} }
//ignore console prompt //ignore console prompt
if (args.Text.ToLower().Contains(">")) /*if (args.Text.ToLower().Contains(">"))
{ {
Debug.Console(1, this, "Ignoring console");
return; return;
} }
if (!args.Text.ToLower().Contains("dge")) if (args.Text.ToLower().Contains("dge"))
{
Debug.Console(1, this, "Ignoring DGE");
return;
}*/
if (!args.Text.Contains('['))
{ {
return; return;
} }
var splitResponse = args.Text.Split('[');
DeviceInfo.SerialNumber = args.Text.Split('[')[1].Split(' ')[4].Replace("#", ""); foreach (string t in splitResponse)
DeviceInfo.FirmwareVersion = args.Text.Split('[')[1].Split(' ')[1]; {
Debug.Console(1, this, "{0}", t);
}
DeviceInfo.SerialNumber = splitResponse[1].Split(' ')[4].Replace("#", "");
DeviceInfo.FirmwareVersion = splitResponse[1].Split(' ')[0];
Debug.Console(1, this, "Firmware: {0} SerialNumber: {1}", DeviceInfo.FirmwareVersion,
DeviceInfo.SerialNumber);
tcpClient.SendText("host\r\n"); tcpClient.SendText("host\r\n");
}
catch (Exception ex)
{
Debug.Console(0, this, "Exception getting data: {0}", ex.Message);
Debug.Console(0, this, "response: {0}", args.Text);
}
}; };
tcpClient.Connect(); tcpClient.Connect();