mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-20 14:39:12 +00:00
filter empty messages from slip decode
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace SharpOSC
|
namespace SharpOSC
|
||||||
{
|
{
|
||||||
@@ -8,6 +9,7 @@ namespace SharpOSC
|
|||||||
public static readonly byte ESC = 0xdb;
|
public static readonly byte ESC = 0xdb;
|
||||||
public static readonly byte ESC_END = 0xDC;
|
public static readonly byte ESC_END = 0xDC;
|
||||||
public static readonly byte ESC_ESC = 0xDD;
|
public static readonly byte ESC_ESC = 0xDD;
|
||||||
|
public static ILogger _log = Log.Logger.ForContext<TCPClient>();
|
||||||
|
|
||||||
public static List<byte[]> Decode(byte[] data)
|
public static List<byte[]> Decode(byte[] data)
|
||||||
{
|
{
|
||||||
@@ -17,6 +19,7 @@ namespace SharpOSC
|
|||||||
bool escapeNext = false;
|
bool escapeNext = false;
|
||||||
for (int i = 0; i < data.Length; i++)
|
for (int i = 0; i < data.Length; i++)
|
||||||
{
|
{
|
||||||
|
_log.Information(data[1].ToString());
|
||||||
if (data[i] == ESC)
|
if (data[i] == ESC)
|
||||||
{
|
{
|
||||||
escapeNext = true;
|
escapeNext = true;
|
||||||
@@ -33,10 +36,14 @@ namespace SharpOSC
|
|||||||
{
|
{
|
||||||
buffer.Add(ESC);
|
buffer.Add(ESC);
|
||||||
}
|
}
|
||||||
|
escapeNext = false;
|
||||||
}
|
}
|
||||||
else if (data[i] == END)
|
else if (data[i] == END)
|
||||||
{
|
{
|
||||||
messages.Add(buffer.ToArray());
|
if(buffer.Count > 0)
|
||||||
|
{
|
||||||
|
messages.Add(buffer.ToArray());
|
||||||
|
}
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -44,7 +51,6 @@ namespace SharpOSC
|
|||||||
buffer.Add(data[i]);
|
buffer.Add(data[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user