Skip to content

Commit

Permalink
Merge pull request #43 from SenteraLLC/release-1.2.3
Browse files Browse the repository at this point in the history
Release 1.2.3
  • Loading branch information
jonrwat authored Jul 7, 2016
2 parents 074ac62 + 44c4953 commit bb2c152
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
31 changes: 10 additions & 21 deletions src/sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -202,4 +188,7 @@ static void SBusProcess( uint8_t byte_in )
break;
}
}

// Latch current byte for next evaluation.
byte_in_prev = byte_in;
}
2 changes: 1 addition & 1 deletion src/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit bb2c152

Please sign in to comment.