Browse Source

MAVLink: More robust string operations

sbg
Lorenz Meier 9 years ago
parent
commit
cdeb7df43c
  1. 12
      src/modules/mavlink/mavlink_messages.cpp

12
src/modules/mavlink/mavlink_messages.cpp

@ -378,7 +378,7 @@ private: @@ -378,7 +378,7 @@ private:
unsigned write_err_count = 0;
static const unsigned write_err_threshold = 5;
#ifndef __PX4_QURT
#ifndef __PX4_POSIX_EAGLE
FILE *fp = nullptr;
#endif
@ -387,7 +387,7 @@ protected: @@ -387,7 +387,7 @@ protected:
{}
~MavlinkStreamStatustext() {
#ifndef __PX4_QURT
#ifndef __PX4_POSIX_EAGLE
if (fp) {
fclose(fp);
}
@ -405,10 +405,10 @@ protected: @@ -405,10 +405,10 @@ protected:
mavlink_statustext_t msg;
msg.severity = mavlink_log.severity;
strncpy(msg.text, (const char *)mavlink_log.text, sizeof(msg.text));
msg.text[sizeof(msg.text) - 1] = '\0';
_mavlink->send_message(MAVLINK_MSG_ID_STATUSTEXT, &msg);
// TODO: the logging doesn't work on Snapdragon yet because of file paths.
#ifndef __PX4_POSIX_EAGLE
/* write log messages in first instance to disk */
@ -430,8 +430,8 @@ protected: @@ -430,8 +430,8 @@ protected:
} else if (write_err_count < write_err_threshold) {
/* string to hold the path to the log */
char log_file_name[32] = "";
char log_file_path[70] = "";
char log_file_name[64];
char log_file_path[128];
timespec ts;
px4_clock_gettime(CLOCK_REALTIME, &ts);
@ -450,7 +450,7 @@ protected: @@ -450,7 +450,7 @@ protected:
fputs(msg.text, fp);
fputs("\n", fp);
} else {
PX4_WARN("Failed to open %s errno=%d", log_file_path, errno);
PX4_WARN("Failed to open MAVLink log: %s errno=%d", log_file_path, errno);
}
}
}

Loading…
Cancel
Save