diff --git a/src/sbus.c b/src/sbus.c index 2bd02b2..7ee7a79 100644 --- a/src/sbus.c +++ b/src/sbus.c @@ -83,6 +83,8 @@ void SBusListGet( uint16_t ch_list[ SBUS_CH_MAX ] ) //////////////////////////////////////////////////////////////////////////////// static void SBusProcess( uint8_t byte_in ) { + static uint8_t byte_in_prev = SBUS_HEADER_VALUE; + /// Structure defining the contents of an S.Bus data payload. Each of the /// channel fields (ch1:ch16) occupies 11 bytes. typedef union @@ -127,11 +129,10 @@ static void SBusProcess( uint8_t byte_in ) static enum { - SM_END, SM_START, SM_DATA, - } sm_state = SM_END; + } sm_state = SM_START; static SBUS_DATA_U sbus_data; @@ -141,29 +142,14 @@ static void SBusProcess( uint8_t byte_in ) // packet - i.e. rather than only checking the start/header byte. switch( sm_state ) { - case SM_END: - { - // End byte received ? - if( byte_in == SBUS_FOOTER_VALUE ) - { - sm_state++; - } - - break; - } case SM_START: { - // Start byte received ? - if( byte_in == SBUS_HEADER_VALUE ) + // Footer followed by Header byte has been received ? + if( ( byte_in_prev == SBUS_FOOTER_VALUE ) && + ( byte_in == SBUS_HEADER_VALUE ) ) { sm_state++; } - else - { - // Start byte needs to be next received byte following the - // end byte of the previous message. - sm_state = SM_END; - } break; } @@ -178,7 +164,7 @@ static void SBusProcess( uint8_t byte_in ) { // Reset for reception of next data stream. ch_data_idx = 0; - sm_state = SM_END; + sm_state = SM_START; // Process the received data. sbus_ch_data[ 0 ] = sbus_data.ch1; @@ -202,4 +188,7 @@ static void SBusProcess( uint8_t byte_in ) break; } } + + // Latch current byte for next evaluation. + byte_in_prev = byte_in; } \ No newline at end of file diff --git a/src/status.c b/src/status.c index db1bdb5..e7438ce 100644 --- a/src/status.c +++ b/src/status.c @@ -47,7 +47,7 @@ typedef struct /// The node type - value of '0' identifies node as a FMU node. static const uint8_t status_node_type = 0; -static const uint8_t status_fw_rev_ver = 2; ///< Firmware revision version number. +static const uint8_t status_fw_rev_ver = 3; ///< Firmware revision version number. static const uint8_t status_fw_min_ver = 2; ///< Firmware minor version number. static const uint8_t status_fw_maj_ver = 1; ///< Firmware major version number.