Added Simulate receive on com port

This commit is contained in:
Heath Volmer
2017-08-16 11:15:49 -06:00
parent 667c511515
commit 7320f47d60
8 changed files with 37 additions and 4 deletions

View File

@@ -105,11 +105,18 @@ namespace PepperDash.Essentials.Core
/// <param name="s"></param>
public void SimulateReceive(string s)
{
var split = Regex.Split(s, @"(\\{Xx}{0-9a-fA-F}{0-9a-fA-F})");
Debug.Console(2, this, "Tokens: {0}", string.Join("--", split));
// split out hex chars and build string
var split = Regex.Split(s, @"(\\[Xx][0-9a-fA-F][0-9a-fA-F])");
StringBuilder b = new StringBuilder();
foreach (var t in split)
{
if (t.StartsWith(@"\") && t.Length == 4)
b.Append((char)(Convert.ToByte(t.Substring(2, 2), 16)));
else
b.Append(t);
}
//OnDataReceived(s);
OnDataReceived(b.ToString());
}
}
}