diff --git a/src/lib/rc/dsm.c b/src/lib/rc/dsm.c index e85cb5ba85..018f5c6272 100644 --- a/src/lib/rc/dsm.c +++ b/src/lib/rc/dsm.c @@ -594,7 +594,7 @@ dsm_input(int fd, uint16_t *values, uint16_t *num_values, bool *dsm_11_bit, uint } bool -dsm_parse(uint64_t now, uint8_t *frame, unsigned len, uint16_t *values, +dsm_parse(const uint64_t now, const uint8_t *frame, const unsigned len, uint16_t *values, uint16_t *num_values, bool *dsm_11_bit, unsigned *frame_drops, uint16_t max_channels) { @@ -691,10 +691,7 @@ dsm_parse(uint64_t now, uint8_t *frame, unsigned len, uint16_t *values, } if (decode_ret) { - /* num values should not decrease, only increase */ - if (dsm_chan_count > *num_values) { - *num_values = dsm_chan_count; - } + *num_values = dsm_chan_count; memcpy(&values[0], &dsm_chan_buf[0], dsm_chan_count * sizeof(dsm_chan_buf[0])); #ifdef DSM_DEBUG diff --git a/src/lib/rc/dsm.h b/src/lib/rc/dsm.h index e42897e407..fb9e70f16d 100644 --- a/src/lib/rc/dsm.h +++ b/src/lib/rc/dsm.h @@ -60,7 +60,7 @@ __EXPORT int dsm_config(int dsm_fd); __EXPORT bool dsm_input(int dsm_fd, uint16_t *values, uint16_t *num_values, bool *dsm_11_bit, uint8_t *n_bytes, uint8_t **bytes, unsigned max_values); -__EXPORT bool dsm_parse(uint64_t now, uint8_t *frame, unsigned len, uint16_t *values, +__EXPORT bool dsm_parse(const uint64_t now, const uint8_t *frame, const unsigned len, uint16_t *values, uint16_t *num_values, bool *dsm_11_bit, unsigned *frame_drops, uint16_t max_channels); #ifdef GPIO_SPEKTRUM_PWR_EN diff --git a/src/lib/rc/rc_tests/RCTest.cpp b/src/lib/rc/rc_tests/RCTest.cpp index 5a35f3cc30..216dd14d92 100644 --- a/src/lib/rc/rc_tests/RCTest.cpp +++ b/src/lib/rc/rc_tests/RCTest.cpp @@ -103,7 +103,7 @@ bool RCTest::dsmTest(const char *filepath, unsigned expected_chancount, unsigned &dsm_11_bit, &dsm_frame_drops, max_channels); if (result) { - ut_test(num_values == expected_chancount); + ut_compare("num_values == expected_chancount", num_values, expected_chancount); ut_test(abs((int)chan0 - (int)rc_values[0]) < 30);