private void Receiver()
{
// Run until stopped...
while (!_stop.IsCancellationRequested)
{
// Wait for frame
PwmFrame frame;
if (!_frameBuffer.TryDequeue(out frame))
{
_frameTrigger.WaitOne(1000);
continue;
}
// Validate
var channelCount = frame.Channels.Length;
if (channelCount > _channels.Length)
{
// Too many channels
Debug.WriteLine(Resources.Strings.NavioRCInputDecoderChannelOverflow, channelCount, _channels.Length);
continue;
}
// Copy new channel data
Array.Copy(frame.Channels, _channels, channelCount);
// Fire event
ChannelsChanged?.Invoke(this, frame);
}
}