aboutsummaryrefslogtreecommitdiff
path: root/src/modules/mavlink
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-10-17 09:39:50 +0200
committerLorenz Meier <lm@inf.ethz.ch>2014-10-17 09:39:50 +0200
commita1ea16f7947bedb258ebc198cde52e5976ed0fdd (patch)
treeaadf93722ba152e7325f13caacc85a058928da98 /src/modules/mavlink
parentf500ad4699da9b56ecfd0e413532119577df837d (diff)
downloadpx4-firmware-a1ea16f7947bedb258ebc198cde52e5976ed0fdd.tar.gz
px4-firmware-a1ea16f7947bedb258ebc198cde52e5976ed0fdd.tar.bz2
px4-firmware-a1ea16f7947bedb258ebc198cde52e5976ed0fdd.zip
Log text messages only in first instance
Diffstat (limited to 'src/modules/mavlink')
-rw-r--r--src/modules/mavlink/mavlink_messages.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/modules/mavlink/mavlink_messages.cpp b/src/modules/mavlink/mavlink_messages.cpp
index a4ed14914..cccb698bf 100644
--- a/src/modules/mavlink/mavlink_messages.cpp
+++ b/src/modules/mavlink/mavlink_messages.cpp
@@ -367,26 +367,29 @@ protected:
_mavlink->send_message(MAVLINK_MSG_ID_STATUSTEXT, &msg);
- if (fp) {
- fputs(msg.text, fp);
- fputs("\n", fp);
- fsync(fileno(fp));
- } else {
- /* string to hold the path to the log */
- char log_file_name[32] = "";
- char log_file_path[64] = "";
-
- timespec ts;
- clock_gettime(CLOCK_REALTIME, &ts);
- /* use GPS time for log file naming, e.g. /fs/microsd/2014-01-19/19_37_52.bin */
- time_t gps_time_sec = ts.tv_sec + (ts.tv_nsec / 1e9);
- struct tm t;
- gmtime_r(&gps_time_sec, &t);
-
- // XXX we do not want to interfere here with the SD log app
- strftime(log_file_name, sizeof(log_file_name), "msgs_%Y_%m_%d_%H_%M_%S.txt", &t);
- snprintf(log_file_path, sizeof(log_file_path), "/fs/microsd/%s", log_file_name);
- fp = fopen(log_file_path, "ab");
+ /* write log messages in first instance to disk */
+ if (_mavlink->get_instance_id() == 0) {
+ if (fp) {
+ fputs(msg.text, fp);
+ fputs("\n", fp);
+ fsync(fileno(fp));
+ } else {
+ /* string to hold the path to the log */
+ char log_file_name[32] = "";
+ char log_file_path[64] = "";
+
+ timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ /* use GPS time for log file naming, e.g. /fs/microsd/2014-01-19/19_37_52.bin */
+ time_t gps_time_sec = ts.tv_sec + (ts.tv_nsec / 1e9);
+ struct tm t;
+ gmtime_r(&gps_time_sec, &t);
+
+ // XXX we do not want to interfere here with the SD log app
+ strftime(log_file_name, sizeof(log_file_name), "msgs_%Y_%m_%d_%H_%M_%S.txt", &t);
+ snprintf(log_file_path, sizeof(log_file_path), "/fs/microsd/%s", log_file_name);
+ fp = fopen(log_file_path, "ab");
+ }
}
}
}