From 177ce011a859bb06db3d35d81714bf308bde352b Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Sun, 21 Apr 2024 20:00:19 -0500 Subject: [PATCH] filter empty messages from slip decode --- .../Classes/Communication/SharpOSC/SlipFrame.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs b/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs index 53b4671..53c81a5 100644 --- a/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs +++ b/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Serilog; namespace SharpOSC { @@ -8,6 +9,7 @@ namespace SharpOSC public static readonly byte ESC = 0xdb; public static readonly byte ESC_END = 0xDC; public static readonly byte ESC_ESC = 0xDD; + public static ILogger _log = Log.Logger.ForContext(); public static List Decode(byte[] data) { @@ -17,6 +19,7 @@ namespace SharpOSC bool escapeNext = false; for (int i = 0; i < data.Length; i++) { + _log.Information(data[1].ToString()); if (data[i] == ESC) { escapeNext = true; @@ -33,10 +36,14 @@ namespace SharpOSC { buffer.Add(ESC); } + escapeNext = false; } else if (data[i] == END) { - messages.Add(buffer.ToArray()); + if(buffer.Count > 0) + { + messages.Add(buffer.ToArray()); + } buffer.Clear(); } else @@ -44,7 +51,6 @@ namespace SharpOSC buffer.Add(data[i]); } } - return messages; }