diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 4d9be09c4c6484b78375f9ce6038d671c25f2a03..49c1a1a38e57110eae946dc9b8c940e32a830abb 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -57,7 +57,7 @@ MAVLinkProtocol::MAVLinkProtocol(QGCApplication* app) #ifndef __mobile__ , _logSuspendError(false) , _logSuspendReplay(false) - , _logPromptForSave(false) + , _vehicleWasArmed(false) , _tempLogFile(QString("%2.%3").arg(_tempLogFileTemplate).arg(_logFileExtension)) #endif , _linkMgr(NULL) @@ -283,11 +283,11 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) } // Check for the vehicle arming going by. This is used to trigger log save. - if (!_logPromptForSave && message.msgid == MAVLINK_MSG_ID_HEARTBEAT) { + if (!_vehicleWasArmed && message.msgid == MAVLINK_MSG_ID_HEARTBEAT) { mavlink_heartbeat_t state; mavlink_msg_heartbeat_decode(&message, &state); if (state.base_mode & MAV_MODE_FLAG_DECODE_POSITION_SAFETY) { - _logPromptForSave = true; + _vehicleWasArmed = true; } } } @@ -429,11 +429,7 @@ void MAVLinkProtocol::_startLogging(void) return; } - if (_app->promptFlightDataSaveNotArmed()) { - _logPromptForSave = true; - } - - qDebug() << "Temp log" << _tempLogFile.fileName() << _logPromptForSave; + qDebug() << "Temp log" << _tempLogFile.fileName(); _logSuspendError = false; } @@ -444,13 +440,13 @@ void MAVLinkProtocol::_stopLogging(void) { if (_closeLogFile()) { // If the signals are not connected it means we are running a unit test. In that case just delete log files - if (_logPromptForSave && _app->promptFlightDataSave()) { + if ((_vehicleWasArmed || _app->promptFlightDataSaveNotArmed()) && _app->promptFlightDataSave()) { emit saveTempFlightDataLog(_tempLogFile.fileName()); } else { QFile::remove(_tempLogFile.fileName()); } } - _logPromptForSave = false; + _vehicleWasArmed = false; } /// @brief Checks the temp directory for log files which may have been left there. diff --git a/src/comm/MAVLinkProtocol.h b/src/comm/MAVLinkProtocol.h index 4a78d7f990d13eb119f014a7e134bdb052ea0ab4..346de17fef8a61d64ce2f45b8e0d81a2c143526d 100644 --- a/src/comm/MAVLinkProtocol.h +++ b/src/comm/MAVLinkProtocol.h @@ -7,13 +7,6 @@ * ****************************************************************************/ - -/** - * @file - * @brief Definition of class MAVLinkProtocol - * @author Lorenz Meier - */ - #ifndef MAVLINKPROTOCOL_H_ #define MAVLINKPROTOCOL_H_ @@ -179,7 +172,7 @@ private: bool _logSuspendError; ///< true: Logging suspended due to error bool _logSuspendReplay; ///< true: Logging suspended due to replay - bool _logPromptForSave; ///< true: Prompt for log save when appropriate + bool _vehicleWasArmed; ///< true: Vehicle was armed during log sequence QGCTemporaryFile _tempLogFile; ///< File to log to static const char* _tempLogFileTemplate; ///< Template for temporary log file