px4fmu-v4: Only close down fmu drivers on reset if they weren't running

Signed-off-by: zthorson <zachthorson@gmail.com>
This commit is contained in:
zthorson 2017-02-28 20:13:01 -08:00 committed by Lorenz Meier
parent 63857c6afc
commit a716b105f5
1 changed files with 15 additions and 8 deletions

View File

@ -3273,6 +3273,7 @@ fmu_main(int argc, char *argv[])
{
PortMode new_mode = PORT_MODE_UNSET;
const char *verb = argv[1];
bool fmu_was_running = false;
if (!strcmp(verb, "bind")) {
bind_spektrum();
@ -3302,6 +3303,8 @@ fmu_main(int argc, char *argv[])
errx(0, "FMU driver stopped");
}
fmu_was_running = (g_fmu != nullptr);
if (fmu_start() != OK) {
errx(1, "failed to start the FMU driver");
}
@ -3396,10 +3399,12 @@ fmu_main(int argc, char *argv[])
warnx("resettet default time");
}
// When we are done resetting, we should clean up the fmu drivers
// Failure to do so prevents other devices (HIL sim driver)
// from starting.
fmu_stop();
// When we are done resetting, we should clean up the fmu drivers if they
// weren't active at the beginning of the reset.
// Failure to do so prevents other devices (HIL sim driver) from starting
if (!fmu_was_running) {
fmu_stop();
}
exit(0);
}
@ -3413,10 +3418,12 @@ fmu_main(int argc, char *argv[])
warnx("resettet default time");
}
// When we are done resetting, we should clean up the fmu drivers
// Failure to do so prevents other devices (HIL sim driver)
// from starting.
fmu_stop();
// When we are done resetting, we should clean up the fmu drivers if they
// weren't active at the beginning of the reset.
// Failure to do so prevents other devices (HIL sim driver) from starting
if (!fmu_was_running) {
fmu_stop();
}
exit(0);
}