From 47fcf97442b8bc40bc1193a7dc70a01fbb1585b8 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 1 Jan 2021 13:56:50 +0100 Subject: [PATCH] DSM: Report frame drops Frame drops were measured but not reported on PX4IO. --- src/lib/rc/dsm.cpp | 11 ++++++++--- src/lib/rc/dsm.h | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/rc/dsm.cpp b/src/lib/rc/dsm.cpp index 95aa4efb46..1856ce90cd 100644 --- a/src/lib/rc/dsm.cpp +++ b/src/lib/rc/dsm.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2012-2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2012-2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -705,10 +705,12 @@ bool dsm_decode(hrt_abstime frame_time, uint16_t *values, uint16_t *num_values, * @param[out] n_butes number of bytes read * @param[out] bytes pointer to the buffer of read bytes * @param[out] rssi value in percent, if supported, or 127 + * @param[out] frame_drops dropped frames (indication of an unstable link) + * @param[in] max_values maximum number of channels the receiver can process * @return true=decoded raw channel values updated, false=no update */ bool dsm_input(int fd, uint16_t *values, uint16_t *num_values, bool *dsm_11_bit, uint8_t *n_bytes, uint8_t **bytes, - int8_t *rssi, unsigned max_values) + int8_t *rssi, unsigned *frame_drops, unsigned max_values) { /* * The S.BUS protocol doesn't provide reliable framing, @@ -848,8 +850,11 @@ bool dsm_parse(const uint64_t now, const uint8_t *frame, const unsigned len, uin memcpy(&values[0], &dsm_chan_buf[0], dsm_chan_count * sizeof(dsm_chan_buf[0])); #ifdef DSM_DEBUG + printf("PACKET ---------\n"); + printf("frame drops: %u, chan #: %u\n", dsm_frame_drops, dsm_chan_count); + for (unsigned i = 0; i < dsm_chan_count; i++) { - printf("dsm_decode: %u: %u\n", i, values[i]); + printf("dsm_decode: #CH %02u: %u\n", i + 1, values[i]); } #endif diff --git a/src/lib/rc/dsm.h b/src/lib/rc/dsm.h index 874a760152..6edcbe2dfc 100644 --- a/src/lib/rc/dsm.h +++ b/src/lib/rc/dsm.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. + * Copyright (c) 2012-2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -70,7 +70,7 @@ __EXPORT void dsm_deinit(void); __EXPORT void dsm_proto_init(void); __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, int8_t *rssi, unsigned max_values); + uint8_t **bytes, int8_t *rssi, unsigned *frame_drops, unsigned max_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, int8_t *rssi_percent, uint16_t max_channels);