aboutsummaryrefslogtreecommitdiff
path: root/src/modules/uavcan/uavcan_main.cpp
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2014-11-20 09:05:10 +1100
committerAndrew Tridgell <tridge@samba.org>2014-11-26 08:32:46 +1100
commit2dae1bc542746ed373458b55a8e564607700d17d (patch)
treea63be92817b41d0d361ba29a2dd3226d1ec27f17 /src/modules/uavcan/uavcan_main.cpp
parent7cb613bb264499e56ad2743c75d563117978eddb (diff)
downloadpx4-firmware-2dae1bc542746ed373458b55a8e564607700d17d.tar.gz
px4-firmware-2dae1bc542746ed373458b55a8e564607700d17d.tar.bz2
px4-firmware-2dae1bc542746ed373458b55a8e564607700d17d.zip
uavcan: break the link between poll fd indexes and controls
this linkage was fragile and makes it harder to add new orb subscriptions to the uavcan code
Diffstat (limited to 'src/modules/uavcan/uavcan_main.cpp')
-rw-r--r--src/modules/uavcan/uavcan_main.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/modules/uavcan/uavcan_main.cpp b/src/modules/uavcan/uavcan_main.cpp
index 2c543462e..ccc087920 100644
--- a/src/modules/uavcan/uavcan_main.cpp
+++ b/src/modules/uavcan/uavcan_main.cpp
@@ -333,14 +333,12 @@ int UavcanNode::run()
} else {
// get controls for required topics
bool controls_updated = false;
- unsigned poll_id = 1;
for (unsigned i = 0; i < NUM_ACTUATOR_CONTROL_GROUPS; i++) {
if (_control_subs[i] > 0) {
- if (_poll_fds[poll_id].revents & POLLIN) {
+ if (_poll_fds[_poll_ids[i]].revents & POLLIN) {
controls_updated = true;
orb_copy(_control_topics[i], _control_subs[i], &_controls[i]);
}
- poll_id++;
}
}
@@ -474,6 +472,7 @@ UavcanNode::subscribe()
if (_control_subs[i] > 0) {
_poll_fds[_poll_fds_num].fd = _control_subs[i];
_poll_fds[_poll_fds_num].events = POLLIN;
+ _poll_ids[i] = _poll_fds_num;
_poll_fds_num++;
}
}