Improved sbus handling with a possibility to abandon stuck SBUS frames

This commit is contained in:
Pawel Spychalski (DzikuVx)
2018-04-28 21:00:19 +02:00
parent 0f0dbf6cb3
commit 6a121df25d
3 changed files with 73 additions and 38 deletions

View File

@@ -5,6 +5,10 @@
#include "Arduino.h"
#include "tx_input.h"
enum sbusProtocolStates {
SBUS_DECODING_STATE_IDLE,
SBUS_DECODING_STATE_IN_PROGRESS
};
class SbusInput : public TxInput
{
@@ -14,9 +18,12 @@ class SbusInput : public TxInput
void restart(void);
void loop(void);
bool isReceiving(void);
void recoverStuckFrames(void);
private:
HardwareSerial &_serial;
uint32_t _lastChannelReceivedAt = 0;
uint32_t _frameDecodingStartedAt = 0;
uint32_t _frameDecodingEndedAt = 0 ;
uint8_t _protocolState = SBUS_DECODING_STATE_IDLE;
void sbusRead(void);
};