diff options
author | px4dev <px4@purgatory.org> | 2012-11-30 21:51:36 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-11-30 21:51:36 -0800 |
commit | 1e6e06595af51fe8449da6bd599126868601ed01 (patch) | |
tree | df2116c40747b2ff7685569782c149c9633fd97b /apps | |
parent | 7f22811afb3078b1f86b2d462d13e0d06e3a5c88 (diff) | |
download | px4-firmware-1e6e06595af51fe8449da6bd599126868601ed01.tar.gz px4-firmware-1e6e06595af51fe8449da6bd599126868601ed01.tar.bz2 px4-firmware-1e6e06595af51fe8449da6bd599126868601ed01.zip |
Avoid processing S.bus channels that cannot be communicated to FMU
Diffstat (limited to 'apps')
-rw-r--r-- | apps/px4io/sbus.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/apps/px4io/sbus.c b/apps/px4io/sbus.c index ed69358e9..39d2c4939 100644 --- a/apps/px4io/sbus.c +++ b/apps/px4io/sbus.c @@ -52,6 +52,7 @@ #include "protocol.h" #define SBUS_FRAME_SIZE 25 +#define SBUS_INPUT_CHANNELS 16 static int sbus_fd = -1; @@ -168,7 +169,7 @@ struct sbus_bit_pick { uint8_t mask; uint8_t lshift; }; -static const struct sbus_bit_pick sbus_decoder[][3] = { +static const struct sbus_bit_pick sbus_decoder[SBUS_INPUT_CHANNELS][3] = { /* 0 */ { { 0, 0, 0xff, 0},{ 1, 0, 0x07, 8},{ 0, 0, 0x00, 0} }, /* 1 */ { { 1, 3, 0x1f, 0},{ 2, 0, 0x3f, 5},{ 0, 0, 0x00, 0} }, /* 2 */ { { 2, 6, 0x03, 0},{ 3, 0, 0xff, 2},{ 4, 0, 0x01, 10} }, @@ -201,11 +202,15 @@ sbus_decode(hrt_abstime frame_time) return; /* use the decoder matrix to extract channel data */ - for (unsigned channel = 0; channel < 16; channel++) { + for (unsigned channel = 0; channel < SBUS_INPUT_CHANNELS; channel++) { + + if (channel >= PX4IO_INPUT_CHANNELS) + break; + unsigned value = 0; for (unsigned pick = 0; pick < 3; pick++) { - struct sbus_bit_pick *decode = &sbus_decoder[channel][pick]; + const struct sbus_bit_pick *decode = &sbus_decoder[channel][pick]; if (decode->mask != 0) { unsigned piece = frame[1 + decode->byte]; |