aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-10-07 22:46:07 +0200
committerLorenz Meier <lm@inf.ethz.ch>2014-10-07 22:46:07 +0200
commit8c6c08dcb5ce87e613cbf867571f219a60e1b813 (patch)
tree0de1ec6a1d8ae9615da1a71ff718a3df6334d897
parent726b10651aa38f1b542e6f3845da9aaf58af72a2 (diff)
downloadpx4-firmware-8c6c08dcb5ce87e613cbf867571f219a60e1b813.tar.gz
px4-firmware-8c6c08dcb5ce87e613cbf867571f219a60e1b813.tar.bz2
px4-firmware-8c6c08dcb5ce87e613cbf867571f219a60e1b813.zip
Limit channel count effectively
-rw-r--r--src/lib/rc/st24.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/rc/st24.c b/src/lib/rc/st24.c
index 2b2178f97..e8a791b8f 100644
--- a/src/lib/rc/st24.c
+++ b/src/lib/rc/st24.c
@@ -176,7 +176,9 @@ int st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channe
*rssi = d->rssi;
*rx_count = d->packet_count;
- *channel_count = 12;
+
+ /* this can lead to rounding of the strides */
+ *channel_count = (max_chan_count < 12) ? max_chan_count : 12;
unsigned stride_count = (*channel_count * 3) / 2;
unsigned chan_index = 0;
@@ -202,7 +204,9 @@ int st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channe
*rssi = d->rssi;
*rx_count = d->packet_count;
- *channel_count = 24;
+
+ /* this can lead to rounding of the strides */
+ *channel_count = (max_chan_count < 24) ? max_chan_count : 24;
unsigned stride_count = (*channel_count * 3) / 2;
unsigned chan_index = 0;