Commit 3e3a129c authored by LM's avatar LM

Minor cleanup, fixed a bug where the serial port would not connect on first...

Minor cleanup, fixed a bug where the serial port would not connect on first application launch on Linux
parent a128df00
......@@ -234,7 +234,6 @@ HEADERS += src/MG.h \
src/comm/LinkInterface.h \
src/comm/SerialLinkInterface.h \
src/comm/SerialLink.h \
src/comm/SerialSimulationLink.h \
src/comm/ProtocolInterface.h \
src/comm/MAVLinkProtocol.h \
src/comm/QGCFlightGearLink.h \
......@@ -365,7 +364,6 @@ SOURCES += src/main.cc \
src/comm/LinkManager.cc \
src/comm/LinkInterface.cpp \
src/comm/SerialLink.cc \
src/comm/SerialSimulationLink.cc \
src/comm/MAVLinkProtocol.cc \
src/comm/QGCFlightGearLink.cc \
src/ui/CommConfigurationWindow.cc \
......
This diff is collapsed.
......@@ -68,6 +68,9 @@ public:
static const int poll_interval = SERIAL_POLL_INTERVAL; ///< Polling interval, defined in configuration.h
/** @brief Get a list of the currently available ports */
QVector<QString>* getCurrentPorts();
bool isConnected();
qint64 bytesAvailable();
......@@ -163,6 +166,7 @@ protected:
quint64 connectionStartTime;
QMutex statisticsMutex;
QMutex dataMutex;
QVector<QString>* ports;
void setName(QString name);
bool hardwareConnect();
......
......@@ -34,6 +34,7 @@ This file is part of the QGROUNDCONTROL project
#include <QObject>
#include <QString>
#include <QVector>
#include <LinkInterface.h>
class SerialLinkInterface : public LinkInterface
......@@ -41,6 +42,7 @@ class SerialLinkInterface : public LinkInterface
Q_OBJECT
public:
virtual QVector<QString>* getCurrentPorts() = 0;
virtual QString getPortName() = 0;
virtual int getBaudRate() = 0;
virtual int getDataBits() = 0;
......
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Brief Description
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _SERIALSIMULATIONLINK_H_
#define _SERIALSIMULATIONLINK_H_
#include <QString>
#include <QByteArray>
#include <QFile>
#include <QTimer>
#include <QTextStream>
#include <QMutex>
#include <SerialLinkInterface.h>
/**
* The serial simulation link class simulates a robot connected to the groundstation.
* It can be either file-based by reading telemetry messages from a file or realtime
* by communicating with a simulation.
*
**/
class SerialSimulationLink : public SerialLinkInterface
{
Q_OBJECT
public:
SerialSimulationLink(QFile* inputFile=NULL, QFile* outputFile=NULL, int sendrate=20);
~SerialSimulationLink();
bool isConnected();
qint64 bytesAvailable();
void run();
/* Extensive statistics for scientific purposes */
qint64 getNominalDataRate();
qint64 getTotalUpstream();
qint64 getShortTermUpstream();
qint64 getCurrentUpstream();
qint64 getMaxUpstream();
qint64 getTotalDownstream();
qint64 getShortTermDownstream();
qint64 getCurrentDownstream();
qint64 getMaxDownstream();
qint64 getBitsSent();
qint64 getBitsReceived();
void enableLoopBackMode(SerialLinkInterface * loop);
QString getPortName();
int getBaudRate();
int getBaudRateType();
int getFlowType();
int getParityType();
int getDataBitsType();
int getStopBitsType();
int getLinkQuality();
bool isFullDuplex();
public slots:
bool setPortName(QString portName);
bool setBaudRateType(int rateIndex);
bool setBaudRate(int rate);
bool setFlowType(int flow);
bool setParityType(int parity);
bool setDataBitsType(int dataBits);
bool setStopBitsType(int stopBits);
void readLine();
void writeBytes(char *bytes, qint64 length);
void readBytes();
bool connect();
bool disconnect();
void setMaximumTimeNoise(int milliseconds);
protected:
QTimer* timer;
SerialLinkInterface* loopBack;
/** File which contains the input data (simulated robot messages) **/
QFile* simulationFile;
/** File where the commands sent by the groundstation are stored **/
QFile* receiveFile;
QTextStream stream;
QTextStream* fileStream;
QTextStream* outStream;
/** Buffer for next line. The next line is read ahead */
QByteArray lineBuffer;
/** Buffer which can be read from connected protocols through readBytes(). **/
QByteArray readyBuffer;
QMutex readyBufferMutex;
bool _isConnected;
quint64 rate;
int maxTimeNoise;
quint64 lastSent;
void addTimeNoise();
signals:
//void connected();
//void disconnected();
//void bytesReady(LinkInterface *link);
};
#endif // _SERIALSIMULATIONLINK_H_
......@@ -12,7 +12,7 @@
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 1.0.0 (Alpha RC16)"
#define QGC_APPLICATION_VERSION "v. 1.0.0 (Alpha RC17)"
namespace QGC
......
This diff is collapsed.
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