1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Adding R7008SB end byte as a possible end of frame check for S.Bus

This commit is contained in:
Mikael Blomqvist 2014-01-03 18:25:44 +01:00
parent 1cb402ff22
commit b1d2c1b83e
2 changed files with 11 additions and 1 deletions

View File

@ -250,7 +250,7 @@ static void PIOS_SBus_UpdateState(struct pios_sbus_state *state, uint8_t b)
state->received_data[state->byte_count - 1] = b;
state->byte_count++;
} else {
if (b == SBUS_EOF_BYTE) {
if (b == SBUS_EOF_BYTE || (b % SBUS_R7008SB_EOF_COUNTER_MASK) == SBUS_R7008SB_EOF_BYTE) {
/* full frame received */
uint8_t flags = state->received_data[SBUS_FRAME_LENGTH - 3];
if (flags & SBUS_FLAG_FL) {

View File

@ -50,7 +50,14 @@
* 0x08 - failsafe flag,
* 0xf0 - reserved
* 1 byte - 0x00 (end of frame byte)
*
* The R7008SB receiver has four different end of frame bytes, which rotates in order:
* 00000100
* 00010100
* 00100100
* 00110100
*/
#define SBUS_FRAME_LENGTH (1 + 22 + 1 + 1)
#define SBUS_SOF_BYTE 0x0f
#define SBUS_EOF_BYTE 0x00
@ -59,6 +66,9 @@
#define SBUS_FLAG_FL 0x04
#define SBUS_FLAG_FS 0x08
#define SBUS_R7008SB_EOF_COUNTER_MASK 0xCF
#define SBUS_R7008SB_EOF_BYTE 0x04
/*
* S.Bus protocol provides 16 proportional and 2 discrete channels.
* Do not change unless driver code is updated accordingly.