forked from Archive/PX4-Autopilot
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
This commit is contained in:
parent
7cb613bb26
commit
2dae1bc542
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,4 +127,7 @@ private:
|
|||
orb_id_t _control_topics[NUM_ACTUATOR_CONTROL_GROUPS_UAVCAN] = {};
|
||||
pollfd _poll_fds[NUM_ACTUATOR_CONTROL_GROUPS_UAVCAN + 1] = {}; ///< +1 for /dev/uavcan/busevent
|
||||
unsigned _poll_fds_num = 0;
|
||||
|
||||
// index into _poll_fds for each _control_subs handle
|
||||
uint8_t _poll_ids[NUM_ACTUATOR_CONTROL_GROUPS_UAVCAN];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue