PX4 Firmware
PX4 Autopilot Software http://px4.io
subscriber_handler.cpp
Go to the documentation of this file.
1 
2 #include "subscriber_handler.h"
3 
4 #include <px4_platform_common/log.h>
5 
6 namespace events
7 {
8 
10 {
11  if (_battery_status_sub < 0) {
13  }
14 
15  if (_cpuload_sub < 0) {
17  }
18 
19  if (_vehicle_command_sub < 0) {
20  _vehicle_command_sub = orb_subscribe(ORB_ID(vehicle_command));
21  }
22 
23  if (_vehicle_status_sub < 0) {
24  _vehicle_status_sub = orb_subscribe(ORB_ID(vehicle_status));
25  }
26 
27  if (_vehicle_status_flags_sub < 0) {
28  _vehicle_status_flags_sub = orb_subscribe(ORB_ID(vehicle_status_flags));
29  }
30 
31 }
32 
34 {
35  if (_battery_status_sub >= 0) {
38  }
39 
40  if (_cpuload_sub >= 0) {
42  _cpuload_sub = -1;
43  }
44 
45  if (_vehicle_command_sub >= 0) {
48  }
49 
50  if (_vehicle_status_sub >= 0) {
53  }
54 
55  if (_vehicle_status_flags_sub >= 0) {
58  }
59 
60 }
61 
63 {
64  bool updated;
65  _update_bitfield = 0;
67 
68  if (updated) {
70  }
71 
72  updated = false;
73  orb_check(_vehicle_status_sub, &updated);
74 
75  if (updated) {
77  }
78 
79  updated = false;
81 
82  if (updated) {
84  }
85 
86  updated = false;
87  orb_check(_battery_status_sub, &updated);
88 
89  if (updated) {
91  }
92 
93  updated = false;
94  orb_check(_cpuload_sub, &updated);
95 
96  if (updated) {
98  }
99 
100 }
101 
102 } /* namespace events */
int orb_subscribe(const struct orb_metadata *meta)
Definition: uORB.cpp:75
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
int orb_unsubscribe(int handle)
Definition: uORB.cpp:85
int orb_check(int handle, bool *updated)
Definition: uORB.cpp:95
static struct cpuload_s cpuload
Definition: Commander.cpp:151