aboutsummaryrefslogtreecommitdiff
path: root/apps/sensors/sensors.c
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-08-21 23:44:22 -0700
committerpx4dev <px4@purgatory.org>2012-08-21 23:44:22 -0700
commit88f0080a0ffb299006950c0453eabddb7d17f078 (patch)
treeea769b9b10ba256942ec93d5b42515f1057f7f4f /apps/sensors/sensors.c
parent8c22e2a092a5527e5e4af2a54ecdeac586ffbfa7 (diff)
downloadpx4-firmware-88f0080a0ffb299006950c0453eabddb7d17f078.tar.gz
px4-firmware-88f0080a0ffb299006950c0453eabddb7d17f078.tar.bz2
px4-firmware-88f0080a0ffb299006950c0453eabddb7d17f078.zip
Fix an architectural issue with the ORB that prevented publication from interrupt context.
ORB topic advertisements are now global handles that can be used in any context. It is still possible to open a topic node as a publisher, but it's not the default. As a consequence, the type of the handle returned from orb_advertise has changed; all other API remains the same.
Diffstat (limited to 'apps/sensors/sensors.c')
-rw-r--r--apps/sensors/sensors.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/apps/sensors/sensors.c b/apps/sensors/sensors.c
index ef8ff798f..891167d1c 100644
--- a/apps/sensors/sensors.c
+++ b/apps/sensors/sensors.c
@@ -124,8 +124,8 @@ extern unsigned ppm_decoded_channels;
extern uint64_t ppm_last_valid_decode;
#endif
-/* file handle that will be used for subscribing */
-static int sensor_pub;
+/* ORB topic publishing our results */
+static orb_advert_t sensor_pub;
/**
* Sensor readout and publishing.
@@ -404,7 +404,7 @@ int sensors_thread_main(int argc, char *argv[])
.yaw = 0.0f,
.throttle = 0.0f };
- int manual_control_pub = orb_advertise(ORB_ID(manual_control_setpoint), &manual_control);
+ orb_advert_t manual_control_pub = orb_advertise(ORB_ID(manual_control_setpoint), &manual_control);
if (manual_control_pub < 0) {
fprintf(stderr, "[sensors] ERROR: orb_advertise for topic manual_control_setpoint failed.\n");
@@ -413,7 +413,7 @@ int sensors_thread_main(int argc, char *argv[])
/* advertise the rc topic */
struct rc_channels_s rc;
memset(&rc, 0, sizeof(rc));
- int rc_pub = orb_advertise(ORB_ID(rc_channels), &rc);
+ orb_advert_t rc_pub = orb_advertise(ORB_ID(rc_channels), &rc);
if (rc_pub < 0) {
fprintf(stderr, "[sensors] ERROR: orb_advertise for topic rc_channels failed.\n");
@@ -466,7 +466,6 @@ int sensors_thread_main(int argc, char *argv[])
if (vstatus.flag_hil_enabled && !hil_enabled) {
hil_enabled = true;
publishing = false;
- int ret = close(sensor_pub);
printf("[sensors] Closing sensor pub: %i \n", ret);
/* switching from HIL to non-HIL mode */