1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

LP-517 gcs: flush when writing to uavtalk log to avoid device full errors

UAVTalk checks that (io->bytesToWrite() < TX_BUFFER_SIZE)
and, since upgrading to Qt 5.8.0, that test fails when writting to log file
Apparently Qt 5.8.0 has increased the file buffer size or made some change to file handling
Flushing after each write works around this issue.
This commit is contained in:
Philippe Renon 2017-05-07 18:13:29 +02:00
parent 8e87f8b793
commit 44869bb934
2 changed files with 55 additions and 2 deletions

View File

@ -1,4 +1,29 @@
/**
******************************************************************************
*
* @file logfile.cpp
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "logfile.h"
#include <QDebug>
#include <QtGlobal>
@ -72,6 +97,10 @@ qint64 LogFile::writeData(const char *data, qint64 dataSize)
m_file.write((char *)&dataSize, sizeof(dataSize));
qint64 written = m_file.write(data, dataSize);
// flush (needed to avoid UAVTalk device full errors)
m_file.flush();
if (written != -1) {
emit bytesWritten(written);
}

View File

@ -1,6 +1,32 @@
/**
******************************************************************************
*
* @file logfile.h
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LOGFILE_H
#define LOGFILE_H
#include "utils_global.h"
#include <QIODevice>
#include <QTime>
#include <QTimer>
@ -8,7 +34,6 @@
#include <QDebug>
#include <QBuffer>
#include <QFile>
#include "utils_global.h"
class QTCREATOR_UTILS_EXPORT LogFile : public QIODevice {
Q_OBJECT
@ -66,7 +91,6 @@ protected:
double m_lastPlayed;
QMutex m_mutex;
int m_timeOffset;
double m_playbackSpeed;