mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 08:53:34 +08:00
mavlink_messages.cpp: fix coding style: prepend _ to class members
This commit is contained in:
@@ -371,23 +371,20 @@ private:
|
|||||||
MavlinkStreamStatustext(MavlinkStreamStatustext &);
|
MavlinkStreamStatustext(MavlinkStreamStatustext &);
|
||||||
MavlinkStreamStatustext& operator = (const MavlinkStreamStatustext &);
|
MavlinkStreamStatustext& operator = (const MavlinkStreamStatustext &);
|
||||||
|
|
||||||
unsigned write_err_count = 0;
|
unsigned _write_err_count = 0;
|
||||||
static const unsigned write_err_threshold = 5;
|
static const unsigned write_err_threshold = 5;
|
||||||
#ifndef __PX4_POSIX_EAGLE
|
#ifndef __PX4_POSIX_EAGLE
|
||||||
FILE *fp;
|
FILE *_fp = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit MavlinkStreamStatustext(Mavlink *mavlink) : MavlinkStream(mavlink)
|
explicit MavlinkStreamStatustext(Mavlink *mavlink) : MavlinkStream(mavlink)
|
||||||
#ifndef __PX4_POSIX_EAGLE
|
|
||||||
, fp(nullptr)
|
|
||||||
#endif
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~MavlinkStreamStatustext() {
|
~MavlinkStreamStatustext() {
|
||||||
#ifndef __PX4_POSIX_EAGLE
|
#ifndef __PX4_POSIX_EAGLE
|
||||||
if (fp != nullptr) {
|
if (_fp != nullptr) {
|
||||||
fclose(fp);
|
fclose(_fp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -421,27 +418,27 @@ protected:
|
|||||||
strftime(tstamp, sizeof(tstamp) - 1, "%Y_%m_%d_%H_%M_%S", &tt);
|
strftime(tstamp, sizeof(tstamp) - 1, "%Y_%m_%d_%H_%M_%S", &tt);
|
||||||
|
|
||||||
if (_mavlink->get_instance_id() == 0/* && _mavlink->get_logging_enabled()*/) {
|
if (_mavlink->get_instance_id() == 0/* && _mavlink->get_logging_enabled()*/) {
|
||||||
if (fp != nullptr) {
|
if (_fp != nullptr) {
|
||||||
fputs(tstamp, fp);
|
fputs(tstamp, _fp);
|
||||||
fputs(": ", fp);
|
fputs(": ", _fp);
|
||||||
if (EOF == fputs(msg.text, fp)) {
|
if (EOF == fputs(msg.text, _fp)) {
|
||||||
write_err_count++;
|
_write_err_count++;
|
||||||
} else {
|
} else {
|
||||||
write_err_count = 0;
|
_write_err_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write_err_count >= write_err_threshold) {
|
if (_write_err_count >= write_err_threshold) {
|
||||||
(void)fclose(fp);
|
(void)fclose(_fp);
|
||||||
fp = nullptr;
|
_fp = nullptr;
|
||||||
PX4_WARN("mavlink logging disabled");
|
PX4_WARN("mavlink logging disabled");
|
||||||
} else {
|
} else {
|
||||||
(void)fputs("\n", fp);
|
(void)fputs("\n", _fp);
|
||||||
#ifdef __PX4_NUTTX
|
#ifdef __PX4_NUTTX
|
||||||
fsync(fp->fs_filedes);
|
fsync(_fp->fs_filedes);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (write_err_count < write_err_threshold) {
|
} else if (_write_err_count < write_err_threshold) {
|
||||||
/* string to hold the path to the log */
|
/* string to hold the path to the log */
|
||||||
char log_file_path[128];
|
char log_file_path[128];
|
||||||
|
|
||||||
@@ -449,16 +446,16 @@ protected:
|
|||||||
|
|
||||||
/* store the log file in the root directory */
|
/* store the log file in the root directory */
|
||||||
snprintf(log_file_path, sizeof(log_file_path) - 1, PX4_ROOTFSDIR"/fs/microsd/msgs_%s.txt", tstamp);
|
snprintf(log_file_path, sizeof(log_file_path) - 1, PX4_ROOTFSDIR"/fs/microsd/msgs_%s.txt", tstamp);
|
||||||
fp = fopen(log_file_path, "ab");
|
_fp = fopen(log_file_path, "ab");
|
||||||
|
|
||||||
if (fp != nullptr) {
|
if (_fp != nullptr) {
|
||||||
/* write first message */
|
/* write first message */
|
||||||
fputs(tstamp, fp);
|
fputs(tstamp, _fp);
|
||||||
fputs(": ", fp);
|
fputs(": ", _fp);
|
||||||
fputs(msg.text, fp);
|
fputs(msg.text, _fp);
|
||||||
fputs("\n", fp);
|
fputs("\n", _fp);
|
||||||
#ifdef __PX4_NUTTX
|
#ifdef __PX4_NUTTX
|
||||||
fsync(fp->fs_filedes);
|
fsync(_fp->fs_filedes);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
PX4_WARN("Failed to open MAVLink log: %s", log_file_path);
|
PX4_WARN("Failed to open MAVLink log: %s", log_file_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user