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