aboutsummaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-12-21 16:13:04 +0100
committerLorenz Meier <lm@inf.ethz.ch>2013-12-21 16:13:04 +0100
commitb2e527ffa6f24a67903048ea157ee572f59f98a1 (patch)
treea6e50ad53ca2694fe5779de9d16537b6c00bf7e8 /src/drivers
parent3e037d40de2a68b99aa4600f060eab3555f75832 (diff)
downloadpx4-firmware-b2e527ffa6f24a67903048ea157ee572f59f98a1.tar.gz
px4-firmware-b2e527ffa6f24a67903048ea157ee572f59f98a1.tar.bz2
px4-firmware-b2e527ffa6f24a67903048ea157ee572f59f98a1.zip
Counting channel count changes
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/px4io/px4io.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp
index a7f7fce45..b80844c5b 100644
--- a/src/drivers/px4io/px4io.cpp
+++ b/src/drivers/px4io/px4io.cpp
@@ -237,6 +237,7 @@ private:
unsigned _update_interval; ///< Subscription interval limiting send rate
bool _rc_handling_disabled; ///< If set, IO does not evaluate, but only forward the RC values
+ unsigned _rc_chan_count; ///< Internal copy of the last seen number of RC channels
volatile int _task; ///<worker task id
volatile bool _task_should_exit; ///<worker terminate flag
@@ -246,6 +247,7 @@ private:
perf_counter_t _perf_update; ///<local performance counter for status updates
perf_counter_t _perf_write; ///<local performance counter for PWM control writes
+ perf_counter_t _perf_chan_count; ///<local performance counter for channel number changes
/* cached IO state */
uint16_t _status; ///<Various IO status flags
@@ -455,12 +457,14 @@ PX4IO::PX4IO(device::Device *interface) :
_max_transfer(16), /* sensible default */
_update_interval(0),
_rc_handling_disabled(false),
+ _rc_chan_count(0),
_task(-1),
_task_should_exit(false),
_mavlink_fd(-1),
_thread_mavlink_fd(-1),
- _perf_update(perf_alloc(PC_ELAPSED, "px4io update")),
- _perf_write(perf_alloc(PC_ELAPSED, "px4io write")),
+ _perf_update(perf_alloc(PC_ELAPSED, "io update")),
+ _perf_write(perf_alloc(PC_ELAPSED, "io write")),
+ _perf_chan_count(perf_alloc(PC_COUNT, "io rc #")),
_status(0),
_alarms(0),
_t_actuators(-1),
@@ -1325,6 +1329,11 @@ PX4IO::io_get_raw_rc_input(rc_input_values &input_rc)
*/
channel_count = regs[0];
+ if (channel_count != _rc_chan_count)
+ perf_count(_perf_chan_count);
+
+ _rc_chan_count = channel_count;
+
if (channel_count > 9) {
ret = io_reg_get(PX4IO_PAGE_RAW_RC_INPUT, PX4IO_P_RAW_RC_BASE + 9, &regs[prolog + 9], channel_count - 9);