From 139cfb9cab4a86764fd617f530bbdc68f8b1c73c Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Tue, 16 Apr 2024 17:17:36 -0500 Subject: [PATCH] add escaping to slip decode --- .../Communication/SharpOSC/SlipFrame.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs b/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs index 98c0390..53b4671 100644 --- a/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs +++ b/qController.Standard/Classes/Communication/SharpOSC/SlipFrame.cs @@ -14,14 +14,32 @@ namespace SharpOSC List messages = new List(); List buffer = new List(); + bool escapeNext = false; for (int i = 0; i < data.Length; i++) { - if (data[i] == END && buffer.Count > 0) + if (data[i] == ESC) + { + escapeNext = true; + continue; + } + + if (escapeNext) + { + if (data[i] == ESC_END) + { + buffer.Add(END); + } + else if (data[i] == ESC_ESC) + { + buffer.Add(ESC); + } + } + else if (data[i] == END) { messages.Add(buffer.ToArray()); buffer.Clear(); } - else if (data[i] != END) + else { buffer.Add(data[i]); }