24 lines
547 B
C#
24 lines
547 B
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Threading;
|
|
using LoraGamepad.Models;
|
|
|
|
namespace LoraGamepad.Util;
|
|
|
|
public class CrsfParserPipeIn: IAsyncPipe<byte[],CrsfChMsg>
|
|
{
|
|
protected override void Process(ConcurrentQueue<byte[]> queue)
|
|
{
|
|
if (!queue.TryDequeue(out var data))
|
|
{
|
|
SpinWait.SpinUntil(() => false, 1);
|
|
return;
|
|
}
|
|
switch (data[0])
|
|
{
|
|
case 0x16:
|
|
OnOut(CrsfChMsg.FromBytes(data));
|
|
break;
|
|
}
|
|
}
|
|
} |