From 3725980462c8f95e9501562435a1cc5c530bc201 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 4 Mar 2021 11:02:19 -0500 Subject: [PATCH 01/13] Adds better stream debugging for SendText methods --- Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs | 2 +- Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs | 2 +- Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs | 2 +- Pepperdash Core/Pepperdash Core/CommunicationExtras.cs | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs index 3bc7c21..904f87a 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs @@ -432,7 +432,7 @@ namespace PepperDash.Core if (Client != null) { if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text); + Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, ComTextHelper.GetDebugText(text)); TheStream.Write(text); TheStream.Flush(); diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs index f151b57..9f2102b 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs @@ -376,7 +376,7 @@ namespace PepperDash.Core var bytes = Encoding.GetEncoding(28591).GetBytes(text); // Check debug level before processing byte array if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); + Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, ComTextHelper.GetDebugText(text)); if(Client != null) Client.SendData(bytes, bytes.Length); diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs index 1ed3d68..81cf4a2 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs @@ -329,7 +329,7 @@ namespace PepperDash.Core if (IsConnected && Server != null) { if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text); + Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, ComTextHelper.GetDebugText(text)); Server.SendData(bytes, bytes.Length); } diff --git a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs index c5892a4..6c40979 100644 --- a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs +++ b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronSockets; - +using System.Text.RegularExpressions; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -138,5 +138,10 @@ namespace PepperDash.Core var bytes = Encoding.GetEncoding(28591).GetBytes(text); return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray()); } + + public static string GetDebugText(string text) + { + return Regex.Replace(text, @"[^\u0000-\u007F]|\p{Cc}", a => string.Format("[{0:X2}]", (byte)a.Value[0])); + } } } \ No newline at end of file From 1ae2483110c55450d281b35908a691c4516980a7 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 4 Mar 2021 11:47:25 -0500 Subject: [PATCH 02/13] Uses existing method to get escaped text for console --- Pepperdash Core/Pepperdash Core/CommunicationExtras.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs index 6c40979..207f438 100644 --- a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs +++ b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs @@ -141,7 +141,7 @@ namespace PepperDash.Core public static string GetDebugText(string text) { - return Regex.Replace(text, @"[^\u0000-\u007F]|\p{Cc}", a => string.Format("[{0:X2}]", (byte)a.Value[0])); + return Regex.Replace(text, @"[^\u0000-\u007F]|\p{Cc}", a => GetEscapedText(a.Value)); } } } \ No newline at end of file From e7d54092d89f0e0a8b01fcb63d36f6bf600806ec Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 4 Mar 2021 12:07:07 -0500 Subject: [PATCH 03/13] Simplifies regex for detecting non-printable characters --- Pepperdash Core/Pepperdash Core/CommunicationExtras.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs index 207f438..9dc4b48 100644 --- a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs +++ b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs @@ -141,7 +141,7 @@ namespace PepperDash.Core public static string GetDebugText(string text) { - return Regex.Replace(text, @"[^\u0000-\u007F]|\p{Cc}", a => GetEscapedText(a.Value)); + return Regex.Replace(text, @"[^\u0020-\u007E]", a => GetEscapedText(a.Value)); } } } \ No newline at end of file From 81b274fa99b95f1129e931fcf5991d0dfd9c7f81 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 22 Apr 2021 14:26:36 -0600 Subject: [PATCH 04/13] #94 adds null check in timer callback and stops timer on user disconnect call --- .../Comm/GenericTcpIpClient.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs index f151b57..90314bd 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs @@ -284,9 +284,17 @@ namespace PepperDash.Core /// public void Disconnect() { + DisconnectCalledByUser = true; + + // Stop trying reconnects, if we are + if (RetryTimer != null) + { + RetryTimer.Stop(); + RetryTimer = null; + } + if (Client != null) { - DisconnectCalledByUser = true; DisconnectClient(); Client = null; Debug.Console(1, this, "Disconnected"); @@ -329,7 +337,15 @@ namespace PepperDash.Core Debug.Console(1, this, "Attempting reconnect, status={0}", Client.ClientStatus); if (!DisconnectCalledByUser) - RetryTimer = new CTimer(o => { Client.ConnectToServerAsync(ConnectToServerCallback); }, AutoReconnectIntervalMs); + RetryTimer = new CTimer(o => + { + if (Client == null) + { + return; + } + + Client.ConnectToServerAsync(ConnectToServerCallback); + }, AutoReconnectIntervalMs); } } From 0a77b8681d542bd52ad5447571fab58a9e069e87 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 9 Jun 2021 16:41:49 -0600 Subject: [PATCH 05/13] fix indexing for tokens --- .../Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs | 2 +- .../Pepperdash Core/XSigUtility/Tokens/XSigDigitalToken.cs | 2 +- .../Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs index 41427fe..276bc1a 100644 --- a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs +++ b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs @@ -29,7 +29,7 @@ namespace PepperDash.Core.Intersystem.Tokens public override byte[] GetBytes() { return new[] { - (byte)(0xC0 | ((Value & 0xC000) >> 10) | (Index >> 7)), + (byte)(0xC0 | ((Value & 0xC000) >> 10) | (Index-1 >> 7)), (byte)((Index - 1) & 0x7F), (byte)((Value & 0x3F80) >> 7), (byte)(Value & 0x7F) diff --git a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigDigitalToken.cs b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigDigitalToken.cs index f721387..7840e90 100644 --- a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigDigitalToken.cs +++ b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigDigitalToken.cs @@ -29,7 +29,7 @@ namespace PepperDash.Core.Intersystem.Tokens public override byte[] GetBytes() { return new[] { - (byte)(0x80 | (Value ? 0 : 0x20) | (Index >> 7)), + (byte)(0x80 | (Value ? 0 : 0x20) | ((Index - 1) >> 7)), (byte)((Index - 1) & 0x7F) }; } diff --git a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs index cc61b1f..af47f71 100644 --- a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs +++ b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs @@ -32,7 +32,7 @@ namespace PepperDash.Core.Intersystem.Tokens var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value); var xsig = new byte[serialBytes.Length + 3]; - xsig[0] = (byte)(0xC8 | (Index >> 7)); + xsig[0] = (byte)(0xC8 | (Index-1 >> 7)); xsig[1] = (byte)((Index - 1) & 0x7F); xsig[xsig.Length - 1] = 0xFF; From a92b489e52adf441e665ae94ba448cd987d0d52f Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 10 Jun 2021 09:00:38 -0600 Subject: [PATCH 06/13] fix formatting --- .../Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs | 2 +- .../Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs index 276bc1a..6236f3e 100644 --- a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs +++ b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigAnalogToken.cs @@ -29,7 +29,7 @@ namespace PepperDash.Core.Intersystem.Tokens public override byte[] GetBytes() { return new[] { - (byte)(0xC0 | ((Value & 0xC000) >> 10) | (Index-1 >> 7)), + (byte)(0xC0 | ((Value & 0xC000) >> 10) | (Index - 1 >> 7)), (byte)((Index - 1) & 0x7F), (byte)((Value & 0x3F80) >> 7), (byte)(Value & 0x7F) diff --git a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs index af47f71..deb721a 100644 --- a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs +++ b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs @@ -32,7 +32,7 @@ namespace PepperDash.Core.Intersystem.Tokens var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value); var xsig = new byte[serialBytes.Length + 3]; - xsig[0] = (byte)(0xC8 | (Index-1 >> 7)); + xsig[0] = (byte)(0xC8 | (Index - 1 >> 7)); xsig[1] = (byte)((Index - 1) & 0x7F); xsig[xsig.Length - 1] = 0xFF; From 14b3f1b493875c92d8a5d5dd08cf4fc0c93b8149 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 17 Jun 2021 08:51:31 -0700 Subject: [PATCH 07/13] removed udp server queue --- .../Pepperdash Core/Comm/GenericUdpServer.cs | 89 ++++++------------- 1 file changed, 28 insertions(+), 61 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs index 1ed3d68..8a19c4c 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs @@ -34,11 +34,6 @@ namespace PepperDash.Core /// public event EventHandler DataRecievedExtra; - /// - /// Queue to temporarily store received messages with the source IP and Port info - /// - private CrestronQueue MessageQueue; - /// /// /// @@ -68,8 +63,6 @@ namespace PepperDash.Core get { return (ushort)Server.ServerStatus; } } - - CCriticalSection DequeueLock; /// /// Address of server /// @@ -124,8 +117,6 @@ namespace PepperDash.Core { StreamDebugging = new CommunicationStreamDebugging(SplusKey); BufferSize = 5000; - DequeueLock = new CCriticalSection(); - MessageQueue = new CrestronQueue(); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler); @@ -146,9 +137,6 @@ namespace PepperDash.Core Port = port; BufferSize = buffefSize; - DequeueLock = new CCriticalSection(); - MessageQueue = new CrestronQueue(); - CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler); } @@ -186,11 +174,11 @@ namespace PepperDash.Core /// void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType) { - if (programEventType == eProgramStatusEventType.Stopping) - { - Debug.Console(1, this, "Program stopping. Disabling Server"); - Disconnect(); - } + if (programEventType != eProgramStatusEventType.Stopping) + return; + + Debug.Console(1, this, "Program stopping. Disabling Server"); + Disconnect(); } /// @@ -255,69 +243,48 @@ namespace PepperDash.Core { Debug.Console(2, this, "Received {0} bytes", numBytes); - if (numBytes > 0) + try { - var sourceIp = Server.IPAddressLastMessageReceivedFrom; - var sourcePort = Server.IPPortLastMessageReceivedFrom; - var bytes = server.IncomingDataBuffer.Take(numBytes).ToArray(); - var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length); - MessageQueue.TryToEnqueue(new GenericUdpReceiveTextExtraArgs(str, sourceIp, sourcePort, bytes)); + if (numBytes <= 0) + return; - Debug.Console(2, this, "Bytes: {0}", bytes.ToString()); + var sourceIp = Server.IPAddressLastMessageReceivedFrom; + var sourcePort = Server.IPPortLastMessageReceivedFrom; + var bytes = server.IncomingDataBuffer.Take(numBytes).ToArray(); + var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length); + + var dataRecivedExtra = DataRecievedExtra; + if (dataRecivedExtra != null) + dataRecivedExtra(this, new GenericUdpReceiveTextExtraArgs(str, sourceIp, sourcePort, bytes)); + + Debug.Console(2, this, "Bytes: {0}", bytes.ToString()); var bytesHandler = BytesReceived; if (bytesHandler != null) bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); else Debug.Console(2, this, "bytesHandler is null"); + var textHandler = TextReceived; if (textHandler != null) { if (StreamDebugging.RxStreamDebuggingIsEnabled) Debug.Console(0, this, "Recevied: '{0}'", str); - + textHandler(this, new GenericCommMethodReceiveTextArgs(str)); } else Debug.Console(2, this, "textHandler is null"); } - server.ReceiveDataAsync(Receive); - - // Attempt to enter the CCritical Secion and if we can, start the dequeue thread - var gotLock = DequeueLock.TryEnter(); - if (gotLock) - CrestronInvoke.BeginInvoke((o) => DequeueEvent()); + catch (Exception ex) + { + Debug.Console(0, "GenericUdpServer Receive error: {0}{1}", ex.Message, ex.StackTrace); + } + finally + { + server.ReceiveDataAsync(Receive); + } } - /// - /// This method gets spooled up in its own thread an protected by a CCriticalSection to prevent multiple threads from running concurrently. - /// It will dequeue items as they are enqueued automatically. - /// - void DequeueEvent() - { - try - { - while (true) - { - // Pull from Queue and fire an event. Block indefinitely until an item can be removed, similar to a Gather. - var message = MessageQueue.Dequeue(); - var dataRecivedExtra = DataRecievedExtra; - if (dataRecivedExtra != null) - { - dataRecivedExtra(this, message); - } - } - } - catch (Exception e) - { - Debug.Console(0, "GenericUdpServer DequeueEvent error: {0}\r", e); - } - // Make sure to leave the CCritical section in case an exception above stops this thread, or we won't be able to restart it. - if (DequeueLock != null) - { - DequeueLock.Leave(); - } - } - /// /// General send method /// From 43efa2de189e0370cf5c397d3a2d7af76ed11fba Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 1 Jul 2021 14:00:27 -0600 Subject: [PATCH 08/13] fix: (PepperDash Core) Fix issue with stream debugging and bytes received Also fixed some spelling errors and added length info to the received messages for UDP, TCP, and SSH clients --- .../Pepperdash Core/Comm/GenericSshClient.cs | 18 ++++++++++++------ .../Pepperdash Core/Comm/GenericTcpIpClient.cs | 8 +++++++- .../Pepperdash Core/Comm/GenericUdpServer.cs | 12 +++++++----- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs index 904f87a..f81936c 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs @@ -379,18 +379,24 @@ namespace PepperDash.Core if (bytes.Length > 0) { var bytesHandler = BytesReceived; - if (bytesHandler != null) - bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); + if (bytesHandler != null) + { + if (StreamDebugging.RxStreamDebuggingIsEnabled) + { + Debug.Console(0, this, "Received {1} bytes: '{0}'", ComTextHelper.GetEscapedText(bytes), bytes.Length); + } + bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); + } + var textHandler = TextReceived; if (textHandler != null) { var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length); - textHandler(this, new GenericCommMethodReceiveTextArgs(str)); - if (StreamDebugging.RxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Recevied: '{0}'", str); + Debug.Console(0, this, "Received: '{0}'", ComTextHelper.GetDebugText(str)); - } + textHandler(this, new GenericCommMethodReceiveTextArgs(str)); + } } } diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs index 3b41d37..480e4d1 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs @@ -364,14 +364,20 @@ namespace PepperDash.Core var bytes = client.IncomingDataBuffer.Take(numBytes).ToArray(); var bytesHandler = BytesReceived; if (bytesHandler != null) + { + if (StreamDebugging.RxStreamDebuggingIsEnabled) + { + Debug.Console(0, this, "Received {1} bytes: '{0}'", ComTextHelper.GetEscapedText(bytes), bytes.Length); + } bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); + } var textHandler = TextReceived; if (textHandler != null) { var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length); if (StreamDebugging.RxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Recevied: '{0}'", str); + Debug.Console(0, this, "Received {1} characters of text: '{0}'", ComTextHelper.GetDebugText(str), str.Length); textHandler(this, new GenericCommMethodReceiveTextArgs(str)); diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs index 81cf4a2..2f9769e 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericUdpServer.cs @@ -266,19 +266,21 @@ namespace PepperDash.Core Debug.Console(2, this, "Bytes: {0}", bytes.ToString()); var bytesHandler = BytesReceived; if (bytesHandler != null) + { + if (StreamDebugging.RxStreamDebuggingIsEnabled) + { + Debug.Console(0, this, "Received {1} bytes: '{0}'", ComTextHelper.GetEscapedText(bytes), bytes.Length); + } bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); - else - Debug.Console(2, this, "bytesHandler is null"); + } var textHandler = TextReceived; if (textHandler != null) { if (StreamDebugging.RxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Recevied: '{0}'", str); + Debug.Console(0, this, "Received {1} characters of text: '{0}'", ComTextHelper.GetDebugText(str), str.Length); textHandler(this, new GenericCommMethodReceiveTextArgs(str)); } - else - Debug.Console(2, this, "textHandler is null"); } server.ReceiveDataAsync(Receive); From ee7e5f15485760a1cf2804769be76d0352ab85dc Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 23 Jul 2021 14:46:32 -0600 Subject: [PATCH 09/13] feat: Add Initialize method This method is to be used for starting communications with a device, or other actions that aren't internal to the program. --- Pepperdash Core/Pepperdash Core/Device.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Pepperdash Core/Pepperdash Core/Device.cs b/Pepperdash Core/Pepperdash Core/Device.cs index 62dc6b1..bfbe359 100644 --- a/Pepperdash Core/Pepperdash Core/Device.cs +++ b/Pepperdash Core/Pepperdash Core/Device.cs @@ -119,7 +119,14 @@ namespace PepperDash.Core /// public virtual bool Deactivate() { return true; } - /// + /// + /// Call this method to start communications with a device. Overriding classes do not need to call base.Initialize() + /// + public virtual void Initialize() + { + } + + /// /// Helper method to check object for bool value false and fire an Action method /// /// Should be of type bool, others will be ignored From 5779842e9a2c6778adacc59400c86bf4208394a0 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 30 Jul 2021 13:49:57 -0600 Subject: [PATCH 10/13] fix(GenericSshClient): #110 Adds check to ensure TheStream != null and IsConnected in SendText() and SentBytes() --- .../Pepperdash Core/Comm/GenericSshClient.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs index f81936c..515c226 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs @@ -435,7 +435,7 @@ namespace PepperDash.Core { try { - if (Client != null) + if (Client != null && TheStream != null && IsConnected) { if (StreamDebugging.TxStreamDebuggingIsEnabled) Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, ComTextHelper.GetDebugText(text)); @@ -443,6 +443,10 @@ namespace PepperDash.Core TheStream.Write(text); TheStream.Flush(); + } + else + { + Debug.Console(2, this, "Client is null or disconnected. Cannot Send Text"); } } catch (Exception ex) @@ -464,13 +468,17 @@ namespace PepperDash.Core { try { - if (Client != null) + if (Client != null && TheStream != null && IsConnected) { if (StreamDebugging.TxStreamDebuggingIsEnabled) Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); TheStream.Write(bytes, 0, bytes.Length); TheStream.Flush(); + } + else + { + Debug.Console(2, this, "Client is null or disconnected. Cannot Send Bytes"); } } catch From 4af5eede4085f01935a113ddbc4646933d2e8d48 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 24 Aug 2021 10:28:46 -0600 Subject: [PATCH 11/13] feat(PepperDashCore): #114 Adds QscCoreDoubleTcpIpClient --- .../Comm/QscCoreDoubleTcpIpClient.cs | 312 ++++++++++++++++++ .../Pepperdash Core/PepperDash_Core.csproj | 1 + 2 files changed, 313 insertions(+) create mode 100644 Pepperdash Core/Pepperdash Core/Comm/QscCoreDoubleTcpIpClient.cs diff --git a/Pepperdash Core/Pepperdash Core/Comm/QscCoreDoubleTcpIpClient.cs b/Pepperdash Core/Pepperdash Core/Comm/QscCoreDoubleTcpIpClient.cs new file mode 100644 index 0000000..2f61dc8 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/Comm/QscCoreDoubleTcpIpClient.cs @@ -0,0 +1,312 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Core +{ + public class QscCoreDoubleTcpIpClient : IKeyed + { + public string Key { get; private set; } + + public event EventHandler BoolChange; + public event EventHandler UshortChange; + public event EventHandler StringChange; + + public GenericTcpIpClient MasterClient { get; private set; } + public GenericTcpIpClient SlaveClient { get; private set; } + + string Username; + string Password; + string LineEnding; + + CommunicationGather MasterGather; + CommunicationGather SlaveGather; + + bool IsPolling; + int PollingIntervalSeconds; + CTimer PollTimer; + + bool SlaveIsActive; + + /// + /// Default constuctor for S+ + /// + public QscCoreDoubleTcpIpClient() + { + MasterClient = new GenericTcpIpClient("temp-master"); + MasterClient.AutoReconnect = true; + MasterClient.AutoReconnectIntervalMs = 2000; + SlaveClient = new GenericTcpIpClient("temp-slave"); + SlaveClient.AutoReconnect = true; + SlaveClient.AutoReconnectIntervalMs = 2000; + + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void Connect(string key, string masterAddress, int masterPort, + string slaveAddress, int slavePort, string username, string password, + int pollingIntervalSeconds, string lineEnding) + { + Key = key; + + PollingIntervalSeconds = pollingIntervalSeconds; + Username = username; + Password = password; + LineEnding = lineEnding; + + MasterClient.Initialize(key + "-master"); + SlaveClient.Initialize(key + "-slave"); + + MasterClient.Hostname = masterAddress; + MasterClient.Port = masterPort; + + if (MasterClient != null) + { + MasterClient.Disconnect(); + } + + if (SlaveClient != null) + { + SlaveClient.Disconnect(); + } + + if (MasterGather == null) + { + MasterGather = new CommunicationGather(MasterClient, lineEnding); + MasterGather.IncludeDelimiter = true; + } + + MasterGather.LineReceived -= MasterGather_LineReceived; + MasterGather.LineReceived += new EventHandler(MasterGather_LineReceived); + + MasterClient.ConnectionChange -= MasterClient_SocketStatusChange; + MasterClient.ConnectionChange += MasterClient_SocketStatusChange; + + SlaveClient.Hostname = slaveAddress; + SlaveClient.Port = slavePort; + + if (SlaveGather == null) + { + SlaveGather = new CommunicationGather(SlaveClient, lineEnding); + SlaveGather.IncludeDelimiter = true; + } + + SlaveGather.LineReceived -= MasterGather_LineReceived; + SlaveGather.LineReceived += new EventHandler(SlaveGather_LineReceived); + + SlaveClient.ConnectionChange -= SlaveClient_SocketStatusChange; + SlaveClient.ConnectionChange += SlaveClient_SocketStatusChange; + + MasterClient.Connect(); + SlaveClient.Connect(); + } + + /// + /// + /// + public void Disconnect() + { + if (MasterClient != null) + { + MasterGather.LineReceived -= MasterGather_LineReceived; + MasterClient.Disconnect(); + } + if (SlaveClient != null) + { + SlaveGather.LineReceived -= SlaveGather_LineReceived; + SlaveClient.Disconnect(); + } + if (PollTimer != null) + { + IsPolling = false; + + PollTimer.Stop(); + PollTimer = null; + } + } + + /// + /// Does not include line feed + /// + public void SendText(string s) + { + if (SlaveIsActive) + { + if (SlaveClient != null) + { + Debug.Console(2, this, "Sending to Slave: {0}", s); + SlaveClient.SendText(s); + } + } + else + { + if (MasterClient != null) + { + Debug.Console(2, this, "Sending to Master: {0}", s); + MasterClient.SendText(s); + } + } + } + + void MasterClient_SocketStatusChange(object sender, GenericSocketStatusChageEventArgs args) + { + OnUshortChange((ushort)args.Client.ClientStatus, MasterClientStatusId); + + if (args.Client.IsConnected) + { + MasterGather.LineReceived += MasterGather_LineReceived; + + StartPolling(); + } + else + MasterGather.LineReceived -= MasterGather_LineReceived; + } + + void SlaveClient_SocketStatusChange(object sender, GenericSocketStatusChageEventArgs args) + { + OnUshortChange((ushort)args.Client.ClientStatus, SlaveClientStatusId); + + if (args.Client.IsConnected) + { + SlaveGather.LineReceived += SlaveGather_LineReceived; + + StartPolling(); + } + else + SlaveGather.LineReceived -= SlaveGather_LineReceived; + + } + + + void MasterGather_LineReceived(object sender, GenericCommMethodReceiveTextArgs e) + { + if (e.Text.Contains("login_required")) + { + MasterClient.SendText(string.Format("login {0} {1} \x0d\x0a", Username, Password)); + } + else if (e.Text.Contains("login_success")) + { + // START THE POLLING, YO! + } + else if (e.Text.StartsWith("sr")) + { + // example response "sr "MyDesign" "NIEC2bxnVZ6a" 1 1" + + var split = e.Text.Trim().Split(' '); + if (split[split.Length - 1] == "1") + { + SlaveIsActive = false; + OnBoolChange(false, SlaveIsActiveId); + OnBoolChange(true, MasterIsActiveId); + } + } + if (!SlaveIsActive) + OnStringChange(e.Text, LineReceivedId); + } + + void SlaveGather_LineReceived(object sender, GenericCommMethodReceiveTextArgs e) + { + if (e.Text.Contains("login_required")) + { + SlaveClient.SendText(string.Format("login {0} {1} \x0d\x0a", Username, Password)); + } + else if (e.Text.Contains("login_success")) + { + // START THE POLLING, YO! + } + else if (e.Text.StartsWith("sr")) + { + var split = e.Text.Trim().Split(' '); + if (split[split.Length - 1] == "1") + { + SlaveIsActive = true; + OnBoolChange(true, SlaveIsActiveId); + OnBoolChange(false, MasterIsActiveId); + } + } + if (SlaveIsActive) + OnStringChange(e.Text, LineReceivedId); + } + + void StartPolling() + { + if (!IsPolling) + { + IsPolling = true; + + Poll(); + if (PollTimer != null) + PollTimer.Stop(); + + PollTimer = new CTimer(o => Poll(), null, PollingIntervalSeconds * 1000, PollingIntervalSeconds * 1000); + } + } + + void Poll() + { + if (MasterClient != null && MasterClient.IsConnected) + { + Debug.Console(2, this, "Polling Master."); + MasterClient.SendText("sg\x0d\x0a"); + + } + if (SlaveClient != null && SlaveClient.IsConnected) + { + Debug.Console(2, this, "Polling Slave."); + SlaveClient.SendText("sg\x0d\x0a"); + } + } + + + + // login NAME PIN ---> login_success, login_failed + + // status get + // sg --> sr DESIGN_NAME DESIGN_ID IS_PRIMARY IS_ACTIVE + + // CRLF + + void OnBoolChange(bool state, ushort type) + { + var handler = BoolChange; + if (handler != null) + handler(this, new BoolChangeEventArgs(state, type)); + } + + void OnUshortChange(ushort state, ushort type) + { + var handler = UshortChange; + if (handler != null) + handler(this, new UshrtChangeEventArgs(state, type)); + } + + void OnStringChange(string value, ushort type) + { + var handler = StringChange; + if (handler != null) + handler(this, new StringChangeEventArgs(value, type)); + } + + + public const ushort MasterIsActiveId = 3; + public const ushort SlaveIsActiveId = 4; + public const ushort MainModuleInitiailzeId = 5; + + public const ushort MasterClientStatusId = 101; + public const ushort SlaveClientStatusId = 102; + + public const ushort LineReceivedId = 201; + } +} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj index f746202..aa8d2c2 100644 --- a/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj +++ b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj @@ -83,6 +83,7 @@ + From c1f71c7f0f110d31314c928e1f3500479a1a5207 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Sat, 11 Sep 2021 13:37:23 -0600 Subject: [PATCH 12/13] ci: Update CI script to remove Newtonsoft.Json.Compact.dll --- .github/scripts/ZipBuildOutput.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/ZipBuildOutput.ps1 b/.github/scripts/ZipBuildOutput.ps1 index 6e44736..34856fb 100644 --- a/.github/scripts/ZipBuildOutput.ps1 +++ b/.github/scripts/ZipBuildOutput.ps1 @@ -8,6 +8,7 @@ $destination = "$($Env:GITHUB_HOME)\output" New-Item -ItemType Directory -Force -Path ($destination) Get-ChildItem ($destination) $exclusions = @(git submodule foreach --quiet 'echo $name') +$exclusions += "Newtonsoft.Json.Compact.dll" # Trying to get any .json schema files (not currently working) # Gets any files with the listed extensions. Get-ChildItem -recurse -Path "$($Env:GITHUB_WORKSPACE)" -include "*.clz", "*.cpz", "*.cplz", "*.json", "*.nuspec" | ForEach-Object { From 1cb9a04ccc6f04e0999833ce4b3b2bd6baab0dc2 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Sat, 11 Sep 2021 13:48:06 -0600 Subject: [PATCH 13/13] ci: Remove push to build repos from both workflows --- .github/workflows/docker.yml | 153 ----------------------------------- .github/workflows/main.yml | 145 --------------------------------- 2 files changed, 298 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9e09430..5449af9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -152,156 +152,3 @@ jobs: run: nuget push **/*.nupkg -source github - name: Publish nuget package to nuget.org run: nuget push **/*.nupkg -Source https://api.nuget.org/v3/index.json - # This step always runs and pushes the build to the internal build rep - Internal_Push_Output: - needs: Build_Project - runs-on: windows-latest - steps: - # Checkout the repo - - name: Checkout Builds Repo - uses: actions/checkout@v2 - with: - token: ${{ secrets.BUILDS_TOKEN }} - repository: PepperDash-Engineering/pepperdash-core-builds - ref: ${{ Env.GITHUB_REF }} - # Download the version artifact from the build job - - name: Download Build Version Info - uses: actions/download-artifact@v1 - with: - name: Version - - name: Check Directory - run: Get-ChildItem "./" - # Set the version number environment variable from the file we just downloaded - - name: Set Version Number - shell: powershell - run: | - Get-ChildItem "./Version" - $version = Get-Content -Path ./Version/version.txt - Write-Host "Version: $version" - echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Remove-Item -Path ./Version/version.txt - Remove-Item -Path ./Version - # Checkout/Create the branch - - name: Create new branch - run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/") - # Download the build output into the repo - - name: Download Build output - uses: actions/download-artifact@v1 - with: - name: Build - path: ./ - - name: Check directory - run: Get-ChildItem ./ - # Unzip the build package file - - name: Unzip Build file - run: | - Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\ - Remove-Item -Path .\*.zip - - name: Check directory again - run: Get-ChildItem ./ - # Copy Contents of output folder to root directory - - name: Copy Files to root & delete output directory - run: | - Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz") - Get-ChildItem -Path .\output\* | Copy-Item -Destination .\ - Remove-Item -Path .\output -Recurse - # Commits the build output to the branch and tags it with the version - - name: Commit build output and tag the commit - shell: powershell - run: | - git config user.email "actions@pepperdash.com" - git config user.name "GitHub Actions" - git add . - $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)" - Write-Host "Commit: $commit" - git commit -m $commit - git tag $($Env:VERSION) - # Push the commit - - name: Push to Builds Repo - shell: powershell - run: | - $branch = $($Env:GITHUB_REF) -replace "refs/heads/" - Write-Host "Branch: $branch" - git push -u origin $($branch) --force - # Push the tags - - name: Push tags - run: git push --tags origin - - name: Check Directory - run: Get-ChildItem ./ - # This step only runs if the branch is main or release/ runs and pushes the build to the public build repo - Public_Push_Output: - needs: Build_Project - runs-on: windows-latest - if: contains(github.ref, 'main') || contains(github.ref, 'release') - steps: - # Checkout the repo - - name: Checkout Builds Repo - uses: actions/checkout@v2 - with: - token: ${{ secrets.BUILDS_TOKEN }} - repository: PepperDash/PepperDashCore-Builds - ref: ${{ Env.GITHUB_REF }} - # Download the version artifact from the build job - - name: Download Build Version Info - uses: actions/download-artifact@v1 - with: - name: Version - - name: Check Directory - run: Get-ChildItem "./" - # Set the version number environment variable from the file we just downloaded - - name: Set Version Number - shell: powershell - run: | - Get-ChildItem "./Version" - $version = Get-Content -Path ./Version/version.txt - Write-Host "Version: $version" - echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Remove-Item -Path ./Version/version.txt - Remove-Item -Path ./Version - # Checkout/Create the branch - - name: Create new branch - run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/") - # Download the build output into the repo - - name: Download Build output - uses: actions/download-artifact@v1 - with: - name: Build - path: ./ - - name: Check directory - run: Get-ChildItem ./ - # Unzip the build package file - - name: Unzip Build file - run: | - Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\ - Remove-Item -Path .\*.zip - - name: Check directory again - run: Get-ChildItem ./ - # Copy Contents of output folder to root directory - - name: Copy Files to root & delete output directory - run: | - Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz") - Get-ChildItem -Path .\output\* | Copy-Item -Destination .\ - Remove-Item -Path .\output -Recurse - # Commits the build output to the branch and tags it with the version - - name: Commit build output and tag the commit - shell: powershell - run: | - git config user.email "actions@pepperdash.com" - git config user.name "GitHub Actions" - git add . - $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)" - Write-Host "Commit: $commit" - git commit -m $commit - git tag $($Env:VERSION) - # Push the commit - - name: Push to Builds Repo - shell: powershell - run: | - $branch = $($Env:GITHUB_REF) -replace "refs/heads/" - Write-Host "Branch: $branch" - git push -u origin $($branch) --force - # Push the tags - - name: Push tags - run: git push --tags origin - - name: Check Directory - run: Get-ChildItem ./ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c73887..5acc7a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -127,148 +127,3 @@ jobs: run: nuget push **/*.nupkg -source github - name: Publish nuget package to nuget.org run: nuget push **/*.nupkg -Source https://api.nuget.org/v3/index.json - Internal_Push_Output: - needs: Build_Project - runs-on: windows-latest - steps: - # Checkout the repo - - name: Checkout Builds Repo - uses: actions/checkout@v2 - with: - token: ${{ secrets.BUILDS_TOKEN }} - repository: PepperDash-Engineering/pepperdash-core-builds - ref: ${{ Env.GITHUB_REF }} - # Download the version artifact from the build job - - name: Download Build Version Info - uses: actions/download-artifact@v1 - with: - name: Version - - name: Check Directory - run: Get-ChildItem "./" - # Set the version number environment variable from the file we just downloaded - - name: Set Version Number - shell: powershell - run: | - Get-ChildItem "./Version" - $version = Get-Content -Path ./Version/version.txt - Write-Host "Version: $version" - echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Remove-Item -Path ./Version/version.txt - Remove-Item -Path ./Version - # Checkout/Create the branch - - name: Create new branch - run: git checkout main - # Download the build output into the repo - - name: Download Build output - uses: actions/download-artifact@v1 - with: - name: Build - path: ./ - - name: Check directory - run: Get-ChildItem ./ - # Unzip the build package file - - name: Unzip Build file - run: | - Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\ - Remove-Item -Path .\*.zip - - name: Check directory again - run: Get-ChildItem ./ - # Copy Contents of output folder to root directory - - name: Copy Files to root & delete output directory - run: | - Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz") - Get-ChildItem -Path .\output\* | Copy-Item -Destination .\ - Remove-Item -Path .\output -Recurse - # Commits the build output to the branch and tags it with the version - - name: Commit build output and tag the commit - shell: powershell - run: | - git config user.email "actions@pepperdash.com" - git config user.name "GitHub Actions" - git add . - $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)" - Write-Host "Commit: $commit" - git commit -m $commit - git tag $($Env:VERSION) - # Push the commit - - name: Push to Builds Repo - shell: powershell - run: git push -u origin main --force - # Push the tags - - name: Push tags - run: git push --tags origin - - name: Check Directory - run: Get-ChildItem ./ - # This step only runs if the branch is main or release/ runs and pushes the build to the public build repo - Public_Push_Output: - needs: Build_Project - runs-on: windows-latest - steps: - # Checkout the repo - - name: Checkout Builds Repo - uses: actions/checkout@v2 - with: - token: ${{ secrets.BUILDS_TOKEN }} - repository: PepperDash/PepperDashCore-Builds - ref: ${{ Env.GITHUB_REF }} - # Download the version artifact from the build job - - name: Download Build Version Info - uses: actions/download-artifact@v1 - with: - name: Version - - name: Check Directory - run: Get-ChildItem "./" - # Set the version number environment variable from the file we just downloaded - - name: Set Version Number - shell: powershell - run: | - Get-ChildItem "./Version" - $version = Get-Content -Path ./Version/version.txt - Write-Host "Version: $version" - echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - Remove-Item -Path ./Version/version.txt - Remove-Item -Path ./Version - # Checkout/Create the branch - - name: Create new branch - run: git checkout main - # Download the build output into the repo - - name: Download Build output - uses: actions/download-artifact@v1 - with: - name: Build - path: ./ - - name: Check directory - run: Get-ChildItem ./ - # Unzip the build package file - - name: Unzip Build file - run: | - Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\ - Remove-Item -Path .\*.zip - - name: Check directory again - run: Get-ChildItem ./ - # Copy Contents of output folder to root directory - - name: Copy Files to root & delete output directory - run: | - Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz") - Get-ChildItem -Path .\output\* | Copy-Item -Destination .\ - Remove-Item -Path .\output -Recurse - # Commits the build output to the branch and tags it with the version - - name: Commit build output and tag the commit - shell: powershell - run: | - git config user.email "actions@pepperdash.com" - git config user.name "GitHub Actions" - git add . - $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)" - Write-Host "Commit: $commit" - git commit -m $commit - git tag $($Env:VERSION) - # Push the commit - - name: Push to Builds Repo - shell: powershell - run: git push -u origin main --force - # Push the tags - - name: Push tags - run: git push --tags origin - - name: Check Directory - run: Get-ChildItem ./