diff --git a/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs b/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs index 8b0ee14a..7fca05c9 100644 --- a/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs +++ b/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using Crestron.SimplSharp; using Crestron.SimplSharpPro; @@ -54,17 +55,22 @@ namespace PepperDash.Essentials.Core void Port_SerialDataReceived(ComPort ReceivingComPort, ComPortSerialDataEventArgs args) { - var bytesHandler = BytesReceived; - if (bytesHandler != null) - { - var bytes = Encoding.GetEncoding(28591).GetBytes(args.SerialData); - bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); - } - var textHandler = TextReceived; - if (textHandler != null) - textHandler(this, new GenericCommMethodReceiveTextArgs(args.SerialData)); + OnDataReceived(args.SerialData); } + void OnDataReceived(string s) + { + var bytesHandler = BytesReceived; + if (bytesHandler != null) + { + var bytes = Encoding.GetEncoding(28591).GetBytes(s); + bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); + } + var textHandler = TextReceived; + if (textHandler != null) + textHandler(this, new GenericCommMethodReceiveTextArgs(s)); + } + public override bool Deactivate() { return Port.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success; @@ -83,8 +89,6 @@ namespace PepperDash.Essentials.Core Port.Send(text); } - //public BoolFeedback IsConnected { get; private set; } - public void Connect() { } @@ -94,5 +98,18 @@ namespace PepperDash.Essentials.Core } #endregion + + /// + /// + /// + /// + 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)); + + + //OnDataReceived(s); + } } } \ 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 35cd164d..601381bc 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 00885fe7..69f86c37 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/Display/SamsungMDCDisplay.cs b/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs index a23a0e9f..90af7af1 100644 --- a/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs +++ b/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs @@ -161,61 +161,69 @@ namespace PepperDash.Essentials.Devices.Displays e.Bytes.CopyTo(newBytes, IncomingBuffer.Length); Debug.Console(2, this, "Buffer+new: {0}", ComTextHelper.GetEscapedText(newBytes)); - ADD A while HERE TOMORROW. - // If it's at least got the header, then process it, - if (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF) + // Need to find AA FF and have + for (int i = 0; i < newBytes.Length; i++) { - var msgLen = newBytes[3]; - // if the buffer is shorter than the header (3) + message (msgLen) + checksum (1), - // give and save it for next time - if (newBytes.Length < msgLen + 4) + if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF) { - IncomingBuffer = newBytes; - return; - } + newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer - // Good length, grab the message - var message = newBytes.Skip(4).Take(msgLen).ToArray(); - Debug.Console(0, this, "Parsing: {0}", ComTextHelper.GetEscapedText(message)); - - // At this point, the ack/nak is the first byte - if (message[0] == 0x41) - { - switch (message[1]) // type byte + // parse it + // If it's at least got the header, then process it, + while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF) { - case 0x00: // General status - UpdatePowerFB(message[2]); - UpdateVolumeFB(message[3]); - UpdateMuteFb(message[4]); - UpdateInputFb(message[5]); + var msgLen = newBytes[3]; + // if the buffer is shorter than the header (3) + message (msgLen) + checksum (1), + // give and save it for next time + if (newBytes.Length < msgLen + 4) break; - case 0x11: - UpdatePowerFB(message[2]); - break; + // Good length, grab the message + var message = newBytes.Skip(4).Take(msgLen).ToArray(); + Debug.Console(0, this, "Parsing: {0}", ComTextHelper.GetEscapedText(message)); - case 0x12: - UpdateVolumeFB(message[2]); - break; + // At this point, the ack/nak is the first byte + if (message[0] == 0x41) + { + switch (message[1]) // type byte + { + case 0x00: // General status + UpdatePowerFB(message[2]); + UpdateVolumeFB(message[3]); + UpdateMuteFb(message[4]); + UpdateInputFb(message[5]); + break; - case 0x13: - UpdateMuteFb(message[2]); - break; + case 0x11: + UpdatePowerFB(message[2]); + break; - case 0x14: - UpdateInputFb(message[2]); - break; + case 0x12: + UpdateVolumeFB(message[2]); + break; - default: - break; + case 0x13: + UpdateMuteFb(message[2]); + break; + + case 0x14: + UpdateInputFb(message[2]); + break; + + default: + break; + } + } + // Skip over what we've used and save the rest for next time + newBytes = newBytes.Skip(5 + msgLen).ToArray(); } + + break; // parsing will mean we can stop looking for header in loop } - // Skip over what we've used and save the rest for next time - IncomingBuffer = newBytes.Skip(5 + msgLen).ToArray(); } - // there's not even a full header in the event. Save it for next time. - else - IncomingBuffer = newBytes; + + // Save whatever partial message is here + IncomingBuffer = newBytes; } /// 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 2cc951ac..0ce6f395 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 8d1df04c..10db3d6a 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ diff --git a/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs b/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs index baf71ee5..985abf01 100644 --- a/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs +++ b/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs @@ -114,9 +114,14 @@ namespace PepperDash.Essentials DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice; CurrentVolumeControls = DefaultVolumeControls; + var disp = DefaultDisplay as DisplayBase; OnFeedback = new BoolFeedback(() => - { return CurrentSourceInfo != null - && CurrentSourceInfo.Type == eSourceListItemType.Route; }); + { + return CurrentSourceInfo != null + && CurrentSourceInfo.Type == eSourceListItemType.Route + && disp != null + && disp.PowerIsOnFeedback.BoolValue; + }); SourceListKey = "default"; EnablePowerOnToLastSource = true; } diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 855569fc..33232a00 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 ae5cc038..41e531f5 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ diff --git a/devjson commands.json b/devjson commands.json index 6bc0e637..b471d531 100644 --- a/devjson commands.json +++ b/devjson commands.json @@ -1 +1,3 @@ -devjson:1 {"deviceKey":"display-1-comMonitor","methodName":"PrintStatus"} \ No newline at end of file +devjson:1 {"deviceKey":"display-1-comMonitor","methodName":"PrintStatus"} + +devjson:1 {"deviceKey":"display-1-com","methodName":"SimulateReceive", "params": ["taco"]} \ No newline at end of file