mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-21 23:19:17 +00:00
add escaping to slip decode
This commit is contained in:
@@ -14,14 +14,32 @@ namespace SharpOSC
|
|||||||
List<byte[]> messages = new List<byte[]>();
|
List<byte[]> messages = new List<byte[]>();
|
||||||
|
|
||||||
List<byte> buffer = new List<byte>();
|
List<byte> buffer = new List<byte>();
|
||||||
|
bool escapeNext = false;
|
||||||
for (int i = 0; i < data.Length; i++)
|
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());
|
messages.Add(buffer.ToArray());
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
}
|
}
|
||||||
else if (data[i] != END)
|
else
|
||||||
{
|
{
|
||||||
buffer.Add(data[i]);
|
buffer.Add(data[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user