Commit 4d23912a authored by Gus Grubba's avatar Gus Grubba

Receiving and writing logs.

Forcing QGC to use Mavlink V2 if vehicle supports it.
parent f91c5bef
...@@ -481,7 +481,7 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes ...@@ -481,7 +481,7 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
_handleCommandAck(message); _handleCommandAck(message);
break; break;
case MAVLINK_MSG_ID_AUTOPILOT_VERSION: case MAVLINK_MSG_ID_AUTOPILOT_VERSION:
_handleAutopilotVersion(message); _handleAutopilotVersion(link, message);
break; break;
case MAVLINK_MSG_ID_WIND_COV: case MAVLINK_MSG_ID_WIND_COV:
_handleWindCov(message); _handleWindCov(message);
...@@ -508,11 +508,17 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes ...@@ -508,11 +508,17 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
_uas->receiveMessage(message); _uas->receiveMessage(message);
} }
void Vehicle::_handleAutopilotVersion(mavlink_message_t& message) void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& message)
{ {
mavlink_autopilot_version_t autopilotVersion; mavlink_autopilot_version_t autopilotVersion;
mavlink_msg_autopilot_version_decode(&message, &autopilotVersion); mavlink_msg_autopilot_version_decode(&message, &autopilotVersion);
bool isMavlink2 = (autopilotVersion.capabilities & MAV_PROTOCOL_CAPABILITY_MAVLINK2) != 0;
if(isMavlink2) {
mavlink_status_t* mavlinkStatus = mavlink_get_channel_status(link->mavlinkChannel());
mavlinkStatus->flags &= ~MAVLINK_STATUS_FLAG_OUT_MAVLINK1;
}
if (autopilotVersion.flight_sw_version != 0) { if (autopilotVersion.flight_sw_version != 0) {
int majorVersion, minorVersion, patchVersion; int majorVersion, minorVersion, patchVersion;
FIRMWARE_VERSION_TYPE versionType; FIRMWARE_VERSION_TYPE versionType;
...@@ -2002,7 +2008,6 @@ Vehicle::_ackMavlinkLogData(uint16_t sequence) ...@@ -2002,7 +2008,6 @@ Vehicle::_ackMavlinkLogData(uint16_t sequence)
void void
Vehicle::_handleMavlinkLoggingData(mavlink_message_t& message) Vehicle::_handleMavlinkLoggingData(mavlink_message_t& message)
{ {
qDebug() << "MAVLINK_MSG_ID_LOGGING_DATA";
mavlink_logging_data_t log; mavlink_logging_data_t log;
mavlink_msg_logging_data_decode(&message, &log); mavlink_msg_logging_data_decode(&message, &log);
emit mavlinkLogData(this, log.target_system, log.target_component, log.sequence, log.length, log.first_message_offset, log.data, false); emit mavlinkLogData(this, log.target_system, log.target_component, log.sequence, log.length, log.first_message_offset, log.data, false);
...@@ -2012,7 +2017,6 @@ Vehicle::_handleMavlinkLoggingData(mavlink_message_t& message) ...@@ -2012,7 +2017,6 @@ Vehicle::_handleMavlinkLoggingData(mavlink_message_t& message)
void void
Vehicle::_handleMavlinkLoggingDataAcked(mavlink_message_t& message) Vehicle::_handleMavlinkLoggingDataAcked(mavlink_message_t& message)
{ {
qDebug() << "MAVLINK_MSG_ID_LOGGING_DATA_ACKED";
mavlink_logging_data_t log; mavlink_logging_data_t log;
mavlink_msg_logging_data_decode(&message, &log); mavlink_msg_logging_data_decode(&message, &log);
_ackMavlinkLogData(log.sequence); _ackMavlinkLogData(log.sequence);
......
...@@ -692,7 +692,7 @@ private: ...@@ -692,7 +692,7 @@ private:
void _handleVibration(mavlink_message_t& message); void _handleVibration(mavlink_message_t& message);
void _handleExtendedSysState(mavlink_message_t& message); void _handleExtendedSysState(mavlink_message_t& message);
void _handleCommandAck(mavlink_message_t& message); void _handleCommandAck(mavlink_message_t& message);
void _handleAutopilotVersion(mavlink_message_t& message); void _handleAutopilotVersion(LinkInterface* link, mavlink_message_t& message);
void _handleHilActuatorControls(mavlink_message_t& message); void _handleHilActuatorControls(mavlink_message_t& message);
void _missionManagerError(int errorCode, const QString& errorMsg); void _missionManagerError(int errorCode, const QString& errorMsg);
void _geoFenceManagerError(int errorCode, const QString& errorMsg); void _geoFenceManagerError(int errorCode, const QString& errorMsg);
......
...@@ -73,7 +73,7 @@ MAVLinkProtocol::MAVLinkProtocol(QGCApplication* app) ...@@ -73,7 +73,7 @@ MAVLinkProtocol::MAVLinkProtocol(QGCApplication* app)
MAVLinkProtocol::~MAVLinkProtocol() MAVLinkProtocol::~MAVLinkProtocol()
{ {
storeSettings(); storeSettings();
#ifndef __mobile__ #ifndef __mobile__
_closeLogFile(); _closeLogFile();
#endif #endif
...@@ -162,7 +162,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -162,7 +162,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
if (!_linkMgr->links()->contains(link)) { if (!_linkMgr->links()->contains(link)) {
return; return;
} }
// receiveMutex.lock(); // receiveMutex.lock();
mavlink_message_t message; mavlink_message_t message;
mavlink_status_t status; mavlink_status_t status;
...@@ -214,6 +214,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -214,6 +214,8 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
{ {
decodedFirstPacket = true; decodedFirstPacket = true;
/*
* Handled in Vehicle.cc now.
mavlink_status_t* mavlinkStatus = mavlink_get_channel_status(mavlinkChannel); mavlink_status_t* mavlinkStatus = mavlink_get_channel_status(mavlinkChannel);
if (!(mavlinkStatus->flags & MAVLINK_STATUS_FLAG_IN_MAVLINK1) && (mavlinkStatus->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1)) { if (!(mavlinkStatus->flags & MAVLINK_STATUS_FLAG_IN_MAVLINK1) && (mavlinkStatus->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1)) {
qDebug() << "switch to mavlink 2.0" << mavlinkStatus << mavlinkChannel << mavlinkStatus->flags; qDebug() << "switch to mavlink 2.0" << mavlinkStatus << mavlinkChannel << mavlinkStatus->flags;
...@@ -222,6 +224,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -222,6 +224,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
qDebug() << "switch to mavlink 1.0" << mavlinkStatus << mavlinkChannel << mavlinkStatus->flags; qDebug() << "switch to mavlink 1.0" << mavlinkStatus << mavlinkChannel << mavlinkStatus->flags;
mavlinkStatus->flags |= MAVLINK_STATUS_FLAG_OUT_MAVLINK1; mavlinkStatus->flags |= MAVLINK_STATUS_FLAG_OUT_MAVLINK1;
} }
*/
if(message.msgid == MAVLINK_MSG_ID_RADIO_STATUS) if(message.msgid == MAVLINK_MSG_ID_RADIO_STATUS)
{ {
...@@ -255,7 +258,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -255,7 +258,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
#ifndef __mobile__ #ifndef __mobile__
// Log data // Log data
if (!_logSuspendError && !_logSuspendReplay && _tempLogFile.isOpen()) { if (!_logSuspendError && !_logSuspendReplay && _tempLogFile.isOpen()) {
uint8_t buf[MAVLINK_MAX_PACKET_LEN+sizeof(quint64)]; uint8_t buf[MAVLINK_MAX_PACKET_LEN+sizeof(quint64)];
...@@ -280,7 +283,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -280,7 +283,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
_stopLogging(); _stopLogging();
_logSuspendError = true; _logSuspendError = true;
} }
// Check for the vehicle arming going by. This is used to trigger log save. // Check for the vehicle arming going by. This is used to trigger log save.
if (!_logPromptForSave && message.msgid == MAVLINK_MSG_ID_HEARTBEAT) { if (!_logPromptForSave && message.msgid == MAVLINK_MSG_ID_HEARTBEAT) {
mavlink_heartbeat_t state; mavlink_heartbeat_t state;
...@@ -412,7 +415,7 @@ bool MAVLinkProtocol::_closeLogFile(void) ...@@ -412,7 +415,7 @@ bool MAVLinkProtocol::_closeLogFile(void)
return true; return true;
} }
} }
return false; return false;
} }
...@@ -458,11 +461,11 @@ void MAVLinkProtocol::_stopLogging(void) ...@@ -458,11 +461,11 @@ void MAVLinkProtocol::_stopLogging(void)
void MAVLinkProtocol::checkForLostLogFiles(void) void MAVLinkProtocol::checkForLostLogFiles(void)
{ {
QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QString filter(QString("*.%1").arg(_logFileExtension)); QString filter(QString("*.%1").arg(_logFileExtension));
QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files); QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files);
qDebug() << "Orphaned log file count" << fileInfoList.count(); qDebug() << "Orphaned log file count" << fileInfoList.count();
foreach(const QFileInfo fileInfo, fileInfoList) { foreach(const QFileInfo fileInfo, fileInfoList) {
qDebug() << "Orphaned log file" << fileInfo.filePath(); qDebug() << "Orphaned log file" << fileInfo.filePath();
if (fileInfo.size() == 0) { if (fileInfo.size() == 0) {
...@@ -488,10 +491,10 @@ void MAVLinkProtocol::suspendLogForReplay(bool suspend) ...@@ -488,10 +491,10 @@ void MAVLinkProtocol::suspendLogForReplay(bool suspend)
void MAVLinkProtocol::deleteTempLogFiles(void) void MAVLinkProtocol::deleteTempLogFiles(void)
{ {
QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QString filter(QString("*.%1").arg(_logFileExtension)); QString filter(QString("*.%1").arg(_logFileExtension));
QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files); QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files);
foreach(const QFileInfo fileInfo, fileInfoList) { foreach(const QFileInfo fileInfo, fileInfoList) {
QFile::remove(fileInfo.filePath()); QFile::remove(fileInfo.filePath());
} }
......
This diff is collapsed.
...@@ -131,6 +131,8 @@ private slots: ...@@ -131,6 +131,8 @@ private slots:
private: private:
bool _sendLog (const QString& logFile); bool _sendLog (const QString& logFile);
bool _processUploadResponse (int http_code, QByteArray &data); bool _processUploadResponse (int http_code, QByteArray &data);
bool _createNewLog ();
int _getFirstSelected ();
private: private:
QString _description; QString _description;
...@@ -144,6 +146,10 @@ private: ...@@ -144,6 +146,10 @@ private:
MavlinkLogFiles* _currentLogfile; MavlinkLogFiles* _currentLogfile;
Vehicle* _vehicle; Vehicle* _vehicle;
bool _logRunning; bool _logRunning;
bool _loggingDisabled;
FILE* _currentSavingFileFd;
QString _currentSavingFileStr;
uint16_t _sequence;
}; };
#endif #endif
...@@ -37,12 +37,10 @@ Rectangle { ...@@ -37,12 +37,10 @@ Rectangle {
var selected = 0 var selected = 0
for(var i = 0; i < QGroundControl.mavlinkLogManager.logFiles.count; i++) { for(var i = 0; i < QGroundControl.mavlinkLogManager.logFiles.count; i++) {
var logFile = QGroundControl.mavlinkLogManager.logFiles.get(i) var logFile = QGroundControl.mavlinkLogManager.logFiles.get(i)
console.log(logFile.selected)
if(logFile.selected) if(logFile.selected)
selected++ selected++
} }
_selectedCount = selected _selectedCount = selected
console.log(_selectedCount)
} }
} }
...@@ -296,26 +294,27 @@ Rectangle { ...@@ -296,26 +294,27 @@ Rectangle {
id: logFilesColumn id: logFilesColumn
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
anchors.centerIn: parent anchors.centerIn: parent
width: ScreenTools.defaultFontPixelWidth * 68
Rectangle { Rectangle {
width: ScreenTools.defaultFontPixelWidth * 52 width: ScreenTools.defaultFontPixelWidth * 64
height: ScreenTools.defaultFontPixelHeight * 10 height: ScreenTools.defaultFontPixelHeight * 10
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
color: qgcPal.windowShade color: qgcPal.window
border.color: qgcPal.text border.color: qgcPal.text
border.width: 0.5 border.width: 0.5
ListView { ListView {
width: ScreenTools.defaultFontPixelWidth * 50 width: ScreenTools.defaultFontPixelWidth * 56
height: ScreenTools.defaultFontPixelHeight * 9 height: ScreenTools.defaultFontPixelHeight * 8.75
anchors.centerIn: parent anchors.centerIn: parent
orientation: ListView.Vertical orientation: ListView.Vertical
model: QGroundControl.mavlinkLogManager.logFiles model: QGroundControl.mavlinkLogManager.logFiles
clip: true
delegate: Rectangle { delegate: Rectangle {
width: ScreenTools.defaultFontPixelWidth * 48 width: ScreenTools.defaultFontPixelWidth * 52
height: ScreenTools.defaultFontPixelHeight * 1.25 height: ScreenTools.defaultFontPixelHeight * 1.25
color: index % 2 == 0 ? qgcPal.window : qgcPal.windowShade color: qgcPal.window
anchors.horizontalCenter: parent.horizontalCenter;
Row { Row {
width: ScreenTools.defaultFontPixelWidth * 46 width: ScreenTools.defaultFontPixelWidth * 50
anchors.centerIn: parent anchors.centerIn: parent
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
QGCCheckBox { QGCCheckBox {
...@@ -327,10 +326,10 @@ Rectangle { ...@@ -327,10 +326,10 @@ Rectangle {
} }
QGCLabel { QGCLabel {
text: object.name text: object.name
width: ScreenTools.defaultFontPixelWidth * 20 width: ScreenTools.defaultFontPixelWidth * 28
} }
QGCLabel { QGCLabel {
text: object.size text: Number(object.size).toLocaleString(Qt.locale(), 'f', 0)
visible: !object.uploading visible: !object.uploading
width: ScreenTools.defaultFontPixelWidth * 20; width: ScreenTools.defaultFontPixelWidth * 20;
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment