Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close replay log file after replay is finished, then exit #11264

Merged
merged 18 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/modules/replay/replay_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <px4_posix.h>
#include <px4_tasks.h>
#include <px4_time.h>
#include <px4_shutdown.h>

#include <cstring>
#include <float.h>
Expand Down Expand Up @@ -845,7 +846,9 @@ void Replay::run()
PX4_INFO("Replay done (published %u msgs, %.3lf s)", nr_published_messages,
(double)hrt_elapsed_time(&_replay_start_time) / 1.e6);

//TODO: should we close the log file & exit (optionally, by adding a parameter -q) ?
//TODO: add parameter -q?
replay_file.close();
px4_shutdown_request(false, false);
}

onExitMainLoop();
Expand Down
7 changes: 7 additions & 0 deletions src/platforms/common/shutdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ void shutdown_worker(void *arg)

} else {
PX4_WARN("Shutdown NOW. Good Bye.");
#if defined __PX4_POSIX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather implement board_shutdown for SITL, then we don't need this ifdef.
px4_systemreset is incorrect here, as it's supposed to do a reboot.

px4_systemreset(shutdown_args & SHUTDOWN_ARG_TO_BOOTLOADER);
#else
board_shutdown();
#endif
}

pthread_mutex_unlock(&shutdown_mutex); // must NEVER come here
Expand All @@ -205,7 +209,9 @@ void shutdown_worker(void *arg)
int px4_shutdown_request(bool reboot, bool to_bootloader)
{
// fail immediately if the board does not support the requested method
#ifndef __PX4_POSIX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ifdef should not be required if board_shutdown is implemented for SITL

#if defined BOARD_HAS_NO_RESET

if (reboot) {
return -EINVAL;
}
Expand All @@ -217,6 +223,7 @@ int px4_shutdown_request(bool reboot, bool to_bootloader)
return -EINVAL;
}

#endif
#endif

if (shutdown_args & SHUTDOWN_ARG_IN_PROGRESS) {
Expand Down