From d269a04bab45b0dc65cb0b1ce8d49101600068fd Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 10 Jan 2020 11:51:25 -0700 Subject: [PATCH 1/7] Modifes debug statments to also print to log as notices --- .../Room/EssentialsRoomBase.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs index e8193837..a7357f3f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs @@ -100,7 +100,8 @@ namespace PepperDash.Essentials.Core ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered ShutdownPromptSeconds = 60; - ShutdownVacancySeconds = 120; + ShutdownVacancySeconds = 120; + ShutdownType = eShutdownType.None; RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer"); @@ -140,7 +141,7 @@ namespace PepperDash.Essentials.Core case eVacancyMode.InShutdownWarning: { StartShutdown(eShutdownType.Vacancy); - Debug.Console(0, this, "Shutting Down due to vacancy."); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting Down due to vacancy."); break; } default: @@ -163,7 +164,7 @@ namespace PepperDash.Essentials.Core ShutdownType = type; ShutdownPromptTimer.Start(); - Debug.Console(0, this, "ShutdwonPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "ShutdwonPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount); } public void StartRoomVacancyTimer(eVacancyMode mode) @@ -175,7 +176,7 @@ namespace PepperDash.Essentials.Core VacancyMode = mode; RoomVacancyShutdownTimer.Start(); - Debug.Console(0, this, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount); } /// @@ -218,7 +219,7 @@ namespace PepperDash.Essentials.Core if(timeoutMinutes > 0) RoomVacancyShutdownSeconds = timeoutMinutes * 60; - Debug.Console(1, this, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds); RoomOccupancy = statusProvider; @@ -227,7 +228,7 @@ namespace PepperDash.Essentials.Core RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange; RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; - Debug.Console(0, this, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key); } void OnRoomOccupancyIsSet() @@ -252,13 +253,13 @@ namespace PepperDash.Essentials.Core { if (RoomOccupancy.RoomIsOccupiedFeedback.BoolValue == false) { - Debug.Console(1, this, "Notice: Vacancy Detected"); + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Vacancy Detected"); // Trigger the timer when the room is vacant StartRoomVacancyTimer(eVacancyMode.InInitialVacancy); } else { - Debug.Console(1, this, "Notice: Occupancy Detected"); + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Occupancy Detected"); // Reset the timer when the room is occupied RoomVacancyShutdownTimer.Cancel(); } From d63787bc783482164be5fd0857b5673a5b5c3b7a Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 13 Jan 2020 21:54:12 -0700 Subject: [PATCH 2/7] Adds logging for room on/off and occupancy events --- .../Room/Types/EssentialsHuddleSpaceRoom.cs | 6 ++++-- .../Room/Types/EssentialsHuddleVtc1Room.cs | 7 ++++++- .../PepperDashEssentialsBase/Room/EssentialsRoomBase.cs | 9 +++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs index e4b503c3..9bec05b8 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs @@ -223,6 +223,8 @@ namespace PepperDash.Essentials CrestronEnvironment.Sleep(1000); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room"); + RunRouteAction("roomOff"); } @@ -275,8 +277,8 @@ namespace PepperDash.Essentials // Run this on a separate thread new CTimer(o => { - Debug.Console(1, this, "Run route action '{0}'", routeKey); - var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey); + var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); if(dict == null) { Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index 62fbe754..b2db56ae 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -334,8 +334,11 @@ namespace PepperDash.Essentials { // Add Occupancy object from config if (PropertiesConfig.Occupancy != null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + } this.LogoUrl = PropertiesConfig.Logo.GetUrl(); this.SourceListKey = PropertiesConfig.SourceListKey; @@ -359,6 +362,8 @@ namespace PepperDash.Essentials CrestronEnvironment.Sleep(1000); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room"); + RunRouteAction("roomOff"); } @@ -408,7 +413,7 @@ namespace PepperDash.Essentials try { - Debug.Console(1, this, "Run route action '{0}'", routeKey); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey); var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); if (dict == null) { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs index a7357f3f..7781f468 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs @@ -164,7 +164,7 @@ namespace PepperDash.Essentials.Core ShutdownType = type; ShutdownPromptTimer.Start(); - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "ShutdwonPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "ShutdownPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount); } public void StartRoomVacancyTimer(eVacancyMode mode) @@ -212,6 +212,9 @@ namespace PepperDash.Essentials.Core return; } + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Timeout Minutes from Config is: {0}", timeoutMinutes); + // If status provider is fusion, set flag to remote if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase) OccupancyStatusProviderIsRemote = true; @@ -223,12 +226,10 @@ namespace PepperDash.Essentials.Core RoomOccupancy = statusProvider; - OnRoomOccupancyIsSet(); - RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange; RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key); + OnRoomOccupancyIsSet(); } void OnRoomOccupancyIsSet() From 45788a4d6b674000b15d24189fef935c9a41e042 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 13 Jan 2020 21:54:49 -0700 Subject: [PATCH 3/7] Adds debug statments with logging for Samsung MDC power on/off events --- .../Essentials Devices Common/Display/SamsungMDCDisplay.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs index 4c7779ab..47d0296f 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs @@ -256,6 +256,7 @@ namespace PepperDash.Essentials.Devices.Displays if (newVal != _PowerIsOn) { _PowerIsOn = newVal; + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Feedback Power State: {0}", _PowerIsOn); PowerIsOnFeedback.FireUpdate(); } } @@ -364,6 +365,8 @@ namespace PepperDash.Essentials.Devices.Displays /// public override void PowerOn() { + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering On Display"); + IsPoweringOnIgnorePowerFb = true; //Send(PowerOnCmd); SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x01, 0x00 }); @@ -387,6 +390,8 @@ namespace PepperDash.Essentials.Devices.Displays /// public override void PowerOff() { + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering Off Display"); + IsPoweringOnIgnorePowerFb = false; // If a display has unreliable-power off feedback, just override this and // remove this check. From c3dbd419420392b3cc5a9820ff38723b740c2f0f Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 13 Jan 2020 21:55:59 -0700 Subject: [PATCH 4/7] Adds configuratble property for current audio/video output text. Defaults to "". --- .../Essentials_DM/Chassis/DmChassisController.cs | 13 +++++++++++-- .../Essentials_DM/Chassis/DmpsRoutingController.cs | 12 ++++++++++-- .../Essentials_DM/Config/DMChassisConfig.cs | 3 +++ .../Essentials_DM/Config/DmpsRoutingConfig.cs | 3 +++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index 136f3c86..e5a2d4a7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -66,6 +66,11 @@ namespace PepperDash.Essentials.DM public const int RouteOffTime = 500; Dictionary RouteOffTimers = new Dictionary(); + /// + /// Text that represents when an output has no source routed to it + /// + public string NoRouteText = ""; + /// /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now /// @@ -128,6 +133,10 @@ namespace PepperDash.Essentials.DM controller.InputNames = properties.InputNames; controller.OutputNames = properties.OutputNames; + + if (!string.IsNullOrEmpty(properties.NoRouteText)) + controller.NoRouteText = properties.NoRouteText; + controller.PropertiesConfig = properties; return controller; } @@ -217,7 +226,7 @@ namespace PepperDash.Essentials.DM } else { - return ""; + return NoRouteText; } }); OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => @@ -228,7 +237,7 @@ namespace PepperDash.Essentials.DM } else { - return ""; + return NoRouteText; } }); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 0c4ff887..6ed0e63b 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -48,6 +48,11 @@ namespace PepperDash.Essentials.DM public const int RouteOffTime = 500; Dictionary RouteOffTimers = new Dictionary(); + /// + /// Text that represents when an output has no source routed to it + /// + public string NoRouteText = ""; + public static DmpsRoutingController GetDmpsRoutingController(string key, string name, DmpsRoutingPropertiesConfig properties) { @@ -67,6 +72,9 @@ namespace PepperDash.Essentials.DM controller.InputNames = properties.InputNames; controller.OutputNames = properties.OutputNames; + if (!string.IsNullOrEmpty(properties.NoRouteText)) + controller.NoRouteText = properties.NoRouteText; + return controller; } @@ -191,7 +199,7 @@ namespace PepperDash.Essentials.DM } else { - return ""; + return NoRouteText; } }); OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => @@ -202,7 +210,7 @@ namespace PepperDash.Essentials.DM } else { - return ""; + return NoRouteText; } }); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs index 22da6c44..d347fbc8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs @@ -32,6 +32,9 @@ namespace PepperDash.Essentials.DM.Config [JsonProperty("outputNames")] public Dictionary OutputNames { get; set; } + [JsonProperty("noRouteText")] + public string NoRouteText { get; set; } + [JsonProperty("inputSlotSupportsHdcp2")] public Dictionary InputSlotSupportsHdcp2 { get; set; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs index 57dd4a72..b4ed5342 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs @@ -20,6 +20,9 @@ namespace PepperDash.Essentials.DM.Config [JsonProperty("outputNames")] public Dictionary OutputNames { get; set; } + [JsonProperty("noRouteText")] + public string NoRouteText { get; set; } + public DmpsRoutingPropertiesConfig() { InputNames = new Dictionary(); From 47f4d90c5a7edd75e4a6266934d9abdecad6f276 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 13 Jan 2020 21:56:41 -0700 Subject: [PATCH 5/7] Adds support for CEN-IO-DIGIN-104 --- .../Inputs/CenIoDigIn104Controller.cs | 40 +++++++++++++++++++ .../Factory/DeviceFactory.cs | 7 ++++ .../PepperDash_Essentials_Core.csproj | 5 +++ 3 files changed, 52 insertions(+) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs new file mode 100644 index 00000000..6bdfc25c --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.GeneralIO; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Wrapper class for CEN-IO-DIGIN-104 digital input module + /// + public class CenIoDigIn104Controller : Device, IDigitalInputPorts + { + public CenIoDi104 Di104 { get; private set; } + + public CenIoDigIn104Controller(string key, string name, CenIoDi104 di104) + : base(key, name) + { + Di104 = di104; + } + + #region IDigitalInputPorts Members + + public CrestronCollection DigitalInputPorts + { + get { return Di104.DigitalInputPorts; } + } + + public int NumberOfDigitalInputPorts + { + get { return Di104.NumberOfDigitalInputPorts; } + } + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index cfe5af0a..4eddd6ee 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -52,6 +52,13 @@ namespace PepperDash.Essentials.Core Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); return new GenericComm(dc); } + else if (typeName == "ceniodigin104") + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var ipid = control.CresnetIdInt; + + return new CenIoDigIn104Controller(key, name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem)); + } // then check for types that have been added by plugin dlls. if (FactoryMethods.ContainsKey(typeName)) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 7c3cd563..c6915164 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -62,6 +62,10 @@ False ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll + + False + ..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll + False ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll @@ -114,6 +118,7 @@ + From 1017464980170a13a503cf1f91759cc402965521 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 16 Jan 2020 16:40:02 -0700 Subject: [PATCH 6/7] Adds try/catch to Communication_BytesReceived callback to prevent exception from getting logged when malformed message is received --- .../Display/SamsungMDCDisplay.cs | 133 +++++++++--------- 1 file changed, 70 insertions(+), 63 deletions(-) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs index 47d0296f..975487e0 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs @@ -167,84 +167,91 @@ namespace PepperDash.Essentials.Devices.Displays /// void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e) { - // This is probably not thread-safe buffering - // Append the incoming bytes with whatever is in the buffer - var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length]; - IncomingBuffer.CopyTo(newBytes, 0); - e.Bytes.CopyTo(newBytes, IncomingBuffer.Length); - - if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1 - Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes)); - - // Need to find AA FF and have - for (int i = 0; i < newBytes.Length; i++) + try { - if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF) + // This is probably not thread-safe buffering + // Append the incoming bytes with whatever is in the buffer + var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length]; + IncomingBuffer.CopyTo(newBytes, 0); + e.Bytes.CopyTo(newBytes, IncomingBuffer.Length); + + if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1 + Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes)); + + // Need to find AA FF and have + for (int i = 0; i < newBytes.Length; i++) { - newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer - - // parse it - // If it's at least got the header, then process it, - while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF) + if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF) { - 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; + 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(); - - // At this point, the ack/nak is the first byte - if (message[0] == 0x41) + // parse it + // If it's at least got the header, then process it, + while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF) { - switch (message[1]) // type byte + 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; + + // Good length, grab the message + var message = newBytes.Skip(4).Take(msgLen).ToArray(); + + // At this point, the ack/nak is the first byte + if (message[0] == 0x41) { - case 0x00: // General status - //UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps + switch (message[1]) // type byte + { + case 0x00: // General status + //UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps - // Handle the first power on fb when waiting for it. - if (IsPoweringOnIgnorePowerFb && message[2] == 0x01) - IsPoweringOnIgnorePowerFb = false; - // Ignore general-status power off messages when powering up - if (!(IsPoweringOnIgnorePowerFb && message[2] == 0x00)) - UpdatePowerFB(message[2]); - UpdateVolumeFB(message[3]); - UpdateMuteFb(message[4]); - UpdateInputFb(message[5]); - break; + // Handle the first power on fb when waiting for it. + if (IsPoweringOnIgnorePowerFb && message[2] == 0x01) + IsPoweringOnIgnorePowerFb = false; + // Ignore general-status power off messages when powering up + if (!(IsPoweringOnIgnorePowerFb && message[2] == 0x00)) + UpdatePowerFB(message[2]); + UpdateVolumeFB(message[3]); + UpdateMuteFb(message[4]); + UpdateInputFb(message[5]); + break; - case 0x11: - UpdatePowerFB(message[2]); - break; + case 0x11: + UpdatePowerFB(message[2]); + break; - case 0x12: - UpdateVolumeFB(message[2]); - break; + case 0x12: + UpdateVolumeFB(message[2]); + break; - case 0x13: - UpdateMuteFb(message[2]); - break; + case 0x13: + UpdateMuteFb(message[2]); + break; - case 0x14: - UpdateInputFb(message[2]); - break; + case 0x14: + UpdateInputFb(message[2]); + break; - default: - break; + default: + break; + } } + // Skip over what we've used and save the rest for next time + newBytes = newBytes.Skip(5 + msgLen).ToArray(); } - // 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 - } - } - // Save whatever partial message is here - IncomingBuffer = newBytes; + break; // parsing will mean we can stop looking for header in loop + } + } + + // Save whatever partial message is here + IncomingBuffer = newBytes; + } + catch (Exception err) + { + Debug.Console(2, this, "Error parsing feedback: {0}", err); + } } /// From b72f55228a0598effafa6396b0a622f0420be545 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 23 Jan 2020 10:53:41 -0700 Subject: [PATCH 7/7] Adds some debug statements to help with NoRouteText property on DmChassisController config --- .../Essentials_DM/Chassis/DmChassisController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index e5a2d4a7..094b8022 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -135,7 +135,12 @@ namespace PepperDash.Essentials.DM controller.OutputNames = properties.OutputNames; if (!string.IsNullOrEmpty(properties.NoRouteText)) + { controller.NoRouteText = properties.NoRouteText; + Debug.Console(1, controller, "Setting No Route Text value to: {0}", controller.NoRouteText); + } + else + Debug.Console(1, controller, "NoRouteText not specified. Defaulting to blank string.", controller.NoRouteText); controller.PropertiesConfig = properties; return controller;