diff --git a/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs b/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs index 7fca05c9..4bccd704 100644 --- a/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs +++ b/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs @@ -105,11 +105,18 @@ namespace PepperDash.Essentials.Core /// 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()); } } } \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs b/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs index aecce485..ca81a982 100644 --- a/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs +++ b/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs @@ -53,6 +53,8 @@ namespace PepperDash.Essentials.Core { CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s)); }, "apimethods", "", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive", + "Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator); } /// @@ -206,5 +208,29 @@ namespace PepperDash.Essentials.Core return null; } + + /// + /// Console handler that simulates com port data receive + /// + /// + public static void SimulateComReceiveOnDevice(string s) + { + // devcomsim:1 xyzabc + var match = Regex.Match(s, @"(\S*)\s*(.*)"); + if (match.Groups.Count < 3) + { + CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P "); + return; + } + //Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value); + + ComPortController com = GetDeviceForKey(match.Groups[1].Value) as ComPortController; + if (com == null) + { + CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value); + return; + } + com.SimulateReceive(match.Groups[2].Value); + } } } \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index 601381bc..d80d91e0 100644 Binary files a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo and b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo differ diff --git a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo index 69f86c37..8c65323f 100644 Binary files a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo and b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo differ diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo index 0ce6f395..b6b819e4 100644 Binary files a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo and b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo differ diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index 10db3d6a..1f88e7d0 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 33232a00..915cfb00 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index 41e531f5..007d3282 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ