aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-03-10 18:47:31 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-03-10 18:47:31 +0100
commit3f3abebf688c97f87fd6d6016aac5d234d76893f (patch)
tree810cdadd55e1215b816e655b82e820215fd5054d /src
parent1c488a95da934817999a0a40ccb87e07bf5e0307 (diff)
downloadpx4-firmware-3f3abebf688c97f87fd6d6016aac5d234d76893f.tar.gz
px4-firmware-3f3abebf688c97f87fd6d6016aac5d234d76893f.tar.bz2
px4-firmware-3f3abebf688c97f87fd6d6016aac5d234d76893f.zip
Add range finder to logging
Diffstat (limited to 'src')
-rw-r--r--src/modules/sdlog2/sdlog2.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c
index 1365d9e70..53f07651f 100644
--- a/src/modules/sdlog2/sdlog2.c
+++ b/src/modules/sdlog2/sdlog2.c
@@ -58,6 +58,8 @@
#include <drivers/drv_hrt.h>
#include <math.h>
+#include <drivers/drv_range_finder.h>
+
#include <uORB/uORB.h>
#include <uORB/topics/vehicle_status.h>
#include <uORB/topics/sensor_combined.h>
@@ -759,6 +761,7 @@ int sdlog2_thread_main(int argc, char *argv[])
struct vehicle_global_velocity_setpoint_s global_vel_sp;
struct battery_status_s battery;
struct telemetry_status_s telemetry;
+ struct range_finder_report range_finder;
} buf;
memset(&buf, 0, sizeof(buf));
@@ -785,6 +788,7 @@ int sdlog2_thread_main(int argc, char *argv[])
int global_vel_sp_sub;
int battery_sub;
int telemetry_sub;
+ int range_finder_sub;
} subs;
/* log message buffer: header + body */
@@ -955,6 +959,12 @@ int sdlog2_thread_main(int argc, char *argv[])
fds[fdsc_count].events = POLLIN;
fdsc_count++;
+ /* --- RANGE FINDER --- */
+ subs.range_finder_sub = orb_subscribe(ORB_ID(sensor_range_finder));
+ fds[fdsc_count].fd = subs.range_finder_sub;
+ fds[fdsc_count].events = POLLIN;
+ fdsc_count++;
+
/* WARNING: If you get the error message below,
* then the number of registered messages (fdsc)
* differs from the number of messages in the above list.
@@ -1370,6 +1380,16 @@ int sdlog2_thread_main(int argc, char *argv[])
LOGBUFFER_WRITE_AND_COUNT(TELE);
}
+ /* --- BOTTOM DISTANCE --- */
+ if (fds[ifds++].revents & POLLIN) {
+ orb_copy(ORB_ID(sensor_range_finder), subs.range_finder_sub, &buf.range_finder);
+ log_msg.msg_type = LOG_DIST_MSG;
+ log_msg.body.log_DIST.bottom = buf.range_finder.distance;
+ log_msg.body.log_DIST.bottom_rate = 0.0f;
+ log_msg.body.log_DIST.flags = (buf.range_finder.valid ? 1 : 0);
+ LOGBUFFER_WRITE_AND_COUNT(DIST);
+ }
+
/* signal the other thread new data, but not yet unlock */
if (logbuffer_count(&lb) > MIN_BYTES_TO_WRITE) {
/* only request write if several packets can be written at once */