From d14d31df14079851e5cf87bf1b9f77306197b18e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 15 Jun 2018 23:48:44 +0200 Subject: [PATCH] PX4IO: Initialize all channels to zero This sets all channels to zero, including unused channels. Any consumer of the data using the channel count will not see a difference, but this is helpful to avoid confusion in log analysis. --- src/drivers/px4io/px4io.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index c75a7d995e..4dd757a7ce 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -1814,6 +1814,11 @@ PX4IO::io_get_raw_rc_input(rc_input_values &input_rc) input_rc.values[i] = regs[prolog + i]; } + /* zero the remaining fields */ + for (unsigned i = channel_count; i < (sizeof(input_rc.values) / sizeof(input_rc.values[0])); i++) { + input_rc.values[i] = 0; + } + /* get RSSI from input channel */ if (_rssi_pwm_chan > 0 && _rssi_pwm_chan <= input_rc_s::RC_INPUT_MAX_CHANNELS && _rssi_pwm_max - _rssi_pwm_min != 0) { int rssi = ((input_rc.values[_rssi_pwm_chan - 1] - _rssi_pwm_min) * 100) /