mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-13 04:26:49 +00:00
Added Simulate receive on com port
This commit is contained in:
parent
667c511515
commit
7320f47d60
8 changed files with 37 additions and 4 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue