From 44869bb934538f1d96759a6fd1383e3c367af18c Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 7 May 2017 18:13:29 +0200 Subject: [PATCH] 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. --- ground/gcs/src/libs/utils/logfile.cpp | 29 +++++++++++++++++++++++++++ ground/gcs/src/libs/utils/logfile.h | 28 ++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/ground/gcs/src/libs/utils/logfile.cpp b/ground/gcs/src/libs/utils/logfile.cpp index 520085b73..6764a2e72 100644 --- a/ground/gcs/src/libs/utils/logfile.cpp +++ b/ground/gcs/src/libs/utils/logfile.cpp @@ -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 #include @@ -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); } diff --git a/ground/gcs/src/libs/utils/logfile.h b/ground/gcs/src/libs/utils/logfile.h index 88319109d..012871e49 100644 --- a/ground/gcs/src/libs/utils/logfile.h +++ b/ground/gcs/src/libs/utils/logfile.h @@ -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 #include #include @@ -8,7 +34,6 @@ #include #include #include -#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;