Commit d1d6f8f9 authored by pixhawk's avatar pixhawk

Cleaned up serial port libs, activated mav visualization on map (still...

Cleaned up serial port libs, activated mav visualization on map (still debugging), fixed standalone MAVLink generator
parent 0846707b
......@@ -37,12 +37,12 @@ HEADERS += src/standalone/mavlinkgen/MAVLinkGen.h \
src/comm/MAVLinkXMLParser.h \
src/ui/mavlink/DomItem.h \
src/ui/mavlink/DomModel.h \
src/comm/MAVLinkSyntaxHighlighter.h
src/ui/mavlink/QGCMAVLinkTextEdit.h
SOURCES += src/standalone/mavlinkgen/main.cc \
src/standalone/mavlinkgen/MAVLinkGen.cc \
src/ui/XMLCommProtocolWidget.cc \
src/ui/mavlink/DomItem.cc \
src/ui/mavlink/DomModel.cc \
src/comm/MAVLinkXMLParser.cc \
src/comm/MAVLinkSyntaxHighlighter.cc
src/ui/mavlink/QGCMAVLinkTextEdit.cc
RESOURCES = mavground.qrc
......@@ -29,7 +29,7 @@
# $$BASEDIR/lib/openjaus/libopenJaus/include
message(Qt version $$[QT_VERSION])
message(Using Qt from $QTDIR)
message(Using Qt from $$[QTDIR])
release {
# DEFINES += QT_NO_DEBUG_OUTPUT
......
# -------------------------------------------------
# QGroundControl - Micro Air Vehicle Groundstation
# Please see our website at <http://qgroundcontrol.org>
# Author:
# Lorenz Meier <mavteam@student.ethz.ch>
# (c) 2009-2010 PIXHAWK Team
# This file is part of the mav groundstation project
# Maintainer:
# Lorenz Meier <lm@inf.ethz.ch>
# (c) 2009-2011 QGroundControl Developers
# This file is part of the open groundstation 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
......@@ -23,11 +23,17 @@
# Version from GIT repository is preferred
# include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{
# Include bundled version if necessary
#include(lib/QMapControl/QMapControl.pri)
# include(lib/QMapControl/QMapControl.pri)
include(lib/nmea/nmea.pri)
include(lib/opmapcontrol/opmapcontrol.pri)
# This is a HACK - linking to openpilot repo for now
# OPMapControl is a OpenPilot-independent map library
# provided by the OpenPilot team - thanks, great piece
# of open-source software!
# (We're not reusing any part of the OP GCS, just the map library)
include(../openpilot/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol_external.pri)
# include(lib/opmapcontrol/opmapcontrol.pri)
# message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows")
QT += network \
opengl \
......@@ -57,7 +63,6 @@ exists(user_config.pri) {
message("Adding support for additional MAVLink messages for: " $$MAVLINK_CONF)
message("------------------------------------------------------------------------")
}
INCLUDEPATH += $$BASEDIR/../mavlink/include/common
INCLUDEPATH += $$BASEDIR/../mavlink/include
INCLUDEPATH += $$BASEDIR/thirdParty/mavlink/include/common
......@@ -112,27 +117,19 @@ include(qgroundcontrol.pri)
# Include QWT plotting library
include(src/lib/qwt/qwt.pri)
DEPENDPATH += . \
# lib/QMapControl \
# lib/QMapControl/src \
lib/opmapcontrol \
lib/opmapcontrol/src \
plugins \
thirdParty/qserialport/include \
thirdParty/qserialport/include/QtSerialPort \
thirdParty/qserialport
\ # lib/QMapControl \
# lib/QMapControl/src \
lib/opmapcontrollib/opmapcontrol/srcpluginsthirdParty/qserialport/includethirdParty/qserialport/include/QtSerialPortthirdParty/qserialport
INCLUDEPATH += . \
# lib/QMapControl \
lib/opmapcontrol \
thirdParty/qserialport/include \
thirdParty/qserialport/include/QtSerialPort \
thirdParty/qserialport/src
\ # lib/QMapControl \
lib/opmapcontrolthirdParty/qserialport/includethirdParty/qserialport/include/QtSerialPortthirdParty/qserialport/src
# Include serial port library
#include(src/lib/qextserialport/qextserialport.pri)
# include(src/lib/qextserialport/qextserialport.pri)
# include qserial library
include(thirdParty/qserialport/qgroundcontrol-qserialport.pri)
# ../mavlink/include \
# MAVLink/include \
# mavlink/include
......@@ -151,7 +148,7 @@ FORMS += src/ui/MainWindow.ui \
src/ui/ObjectDetectionView.ui \
src/ui/JoystickWidget.ui \
src/ui/DebugConsole.ui \
# src/ui/MapWidget.ui \
\ \ # src/ui/MapWidget.ui \
src/ui/XMLCommProtocolWidget.ui \
src/ui/HDDisplay.ui \
src/ui/MAVLinkSettingsWidget.ui \
......@@ -183,7 +180,6 @@ FORMS += src/ui/MainWindow.ui \
src/ui/UASControlParameters.ui \
src/ui/mission/QGCMissionDoWidget.ui \
src/ui/mission/QGCMissionConditionWidget.ui
INCLUDEPATH += src \
src/ui \
src/ui/linechart \
......@@ -199,7 +195,6 @@ INCLUDEPATH += src \
src/ui/watchdog \
src/ui/map3D \
src/ui/designer
HEADERS += src/MG.h \
src/QGCCore.h \
src/uas/UASInterface.h \
......@@ -237,7 +232,6 @@ HEADERS += src/MG.h \
src/input/JoystickInput.h \
src/ui/JoystickWidget.h \
src/ui/DebugConsole.h \
# src/ui/MapWidget.h \
src/ui/XMLCommProtocolWidget.h \
src/ui/mavlink/DomItem.h \
src/ui/mavlink/DomModel.h \
......@@ -264,8 +258,6 @@ HEADERS += src/MG.h \
src/ui/QGCPxImuFirmwareUpdate.h \
src/ui/QGCDataPlot2D.h \
src/ui/linechart/IncrementalPlot.h \
# src/ui/map/Waypoint2DIcon.h \
# src/ui/map/MAV2DIcon.h \
src/ui/QGCRemoteControlView.h \
src/ui/RadioCalibration/RadioCalibrationData.h \
src/ui/RadioCalibration/RadioCalibrationWindow.h \
......@@ -298,13 +290,11 @@ HEADERS += src/MG.h \
src/ui/mission/QGCMissionDoWidget.h \
src/ui/mission/QGCMissionConditionWidget.h \
src/uas/QGCUASParamManager.h \
src/ui/QGCMapWidget.h
src/ui/QGCMapWidget.h \
src/ui/mavlink/QGCMAVLinkTextEdit.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|win32-msvc2008: {
HEADERS += src/ui/map3D/QGCGoogleEarthView.h
}
macx|win32-msvc2008::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
contains(DEPENDENCIES_PRESENT, osg) {
message("Including headers for OpenSceneGraph")
......@@ -336,7 +326,6 @@ contains(DEPENDENCIES_PRESENT, libfreenect) {
# Enable only if libfreenect is available
HEADERS += src/input/Freenect.h
}
SOURCES += src/main.cc \
src/QGCCore.cc \
src/uas/UASManager.cc \
......@@ -369,7 +358,7 @@ SOURCES += src/main.cc \
src/input/JoystickInput.cc \
src/ui/JoystickWidget.cc \
src/ui/DebugConsole.cc \
# src/ui/MapWidget.cc \
\ \ # src/ui/MapWidget.cc \
src/ui/XMLCommProtocolWidget.cc \
src/ui/mavlink/DomItem.cc \
src/ui/mavlink/DomModel.cc \
......@@ -396,8 +385,8 @@ SOURCES += src/main.cc \
src/ui/QGCPxImuFirmwareUpdate.cc \
src/ui/QGCDataPlot2D.cc \
src/ui/linechart/IncrementalPlot.cc \
# src/ui/map/Waypoint2DIcon.cc \
# src/ui/map/MAV2DIcon.cc \
\ \ # src/ui/map/Waypoint2DIcon.cc \
# src/ui/map/MAV2DIcon.cc \
src/ui/QGCRemoteControlView.cc \
src/ui/RadioCalibration/RadioCalibrationWindow.cc \
src/ui/RadioCalibration/AirfoilServoCalibrator.cc \
......@@ -429,12 +418,9 @@ SOURCES += src/main.cc \
src/ui/mission/QGCMissionDoWidget.cc \
src/ui/mission/QGCMissionConditionWidget.cc \
src/uas/QGCUASParamManager.cc \
src/ui/QGCMapWidget.cc
macx|win32-msvc2008: {
SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
}
src/ui/QGCMapWidget.cc \
src/ui/mavlink/QGCMAVLinkTextEdit.cc
macx|win32-msvc2008::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
contains(DEPENDENCIES_PRESENT, osg) {
message("Including sources for OpenSceneGraph")
......@@ -452,9 +438,7 @@ contains(DEPENDENCIES_PRESENT, osg) {
src/ui/map3D/Texture.cc \
src/ui/map3D/Imagery.cc \
src/ui/map3D/HUDScaleGeode.cc \
src/ui/map3D/WaypointGroupNode.cc \
src/ui/map3D/WaypointGroupNode.cc
contains(DEPENDENCIES_PRESENT, osgearth) {
message("Including sources for osgEarth")
......@@ -471,7 +455,7 @@ contains(DEPENDENCIES_PRESENT, libfreenect) {
RESOURCES += mavground.qrc
# Include RT-LAB Library
win32:exists(src/lib/opalrt/OpalApi.h):exists(C:/OPAL-RT/RT-LAB7.2.4/Common/bin) {
win32:exists(src/lib/opalrt/OpalApi.h):exists(C:/OPAL-RT/RT-LAB7.2.4/Common/bin) {
message("Building support for Opal-RT")
LIBS += -LC:/OPAL-RT/RT-LAB7.2.4/Common/bin \
-lOpalApi
......@@ -491,6 +475,5 @@ win32:exists(src/lib/opalrt/OpalApi.h):exists(C:/OPAL-RT/RT-LAB7.2.4/Common/bin)
FORMS += src/ui/OpalLinkSettings.ui
DEFINES += OPAL_RT
}
TRANSLATIONS += es-MX.ts \
TRANSLATIONS += es-MX.ts \
en-US.ts
......@@ -149,7 +149,8 @@ bool MAVLinkXMLParser::generate()
connect(&includeParser, SIGNAL(parseState(QString)), this, SIGNAL(parseState(QString)));
// Generate and write
recursion_level++;
includeParser.generate();
// Abort if inclusion fails
if (!includeParser.generate()) return false;
recursion_level--;
mainHeader += "\n#include \"../" + pureIncludeFileName + "/" + pureIncludeFileName + ".h\"\n";
......
#ifndef QGC_CONFIGURATION_H
#define QGC_CONFIGURATION_H
#include "mavlink.h"
#include <QString>
/** @brief Polling interval in ms */
#ifdef MAVLINK_ENABLED_SLUGS
#define SERIAL_POLL_INTERVAL 7
#else
#define SERIAL_POLL_INTERVAL 7
#endif
/** @brief Heartbeat emission rate, in Hertz (times per second) */
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
......
This diff is collapsed.
#ifndef _POSIX_QEXTSERIALPORT_H_
#define _POSIX_QEXTSERIALPORT_H_
#include <stdio.h>
#include <termios.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include "qextserialbase.h"
class Posix_QextSerialPort:public QextSerialBase
{
private:
/*!
* This method is a part of constructor.
*/
void init();
protected:
int fd;
struct termios Posix_CommConfig;
struct termios old_termios;
struct timeval Posix_Timeout;
struct timeval Posix_Copy_Timeout;
virtual qint64 readData(char * data, qint64 maxSize);
virtual qint64 writeData(const char * data, qint64 maxSize);
public:
Posix_QextSerialPort(QextSerialBase::QueryMode mode);
Posix_QextSerialPort(const Posix_QextSerialPort& s);
Posix_QextSerialPort(const QString & name, QextSerialBase::QueryMode mode);
Posix_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode);
Posix_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode);
Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s);
virtual ~Posix_QextSerialPort();
virtual void setBaudRate(BaudRateType);
virtual void setDataBits(DataBitsType);
virtual void setParity(ParityType);
virtual void setStopBits(StopBitsType);
virtual void setFlowControl(FlowType);
virtual void setTimeout(long);
virtual bool open(OpenMode mode);
virtual void close();
virtual void flush();
virtual qint64 size() const;
virtual qint64 bytesAvailable() const;
virtual void ungetChar(char c);
virtual void translateError(ulong error);
virtual void setDtr(bool set=true);
virtual void setRts(bool set=true);
virtual ulong lineStatus();
};
#endif
#include "qextserialbase.h"
/*!
\fn QextSerialBase::QextSerialBase()
Default constructor.
*/
QextSerialBase::QextSerialBase()
: QIODevice()
{
#ifdef _TTY_WIN_
setPortName("COM1");
#elif defined(_TTY_IRIX_)
setPortName("/dev/ttyf1");
#elif defined(_TTY_HPUX_)
setPortName("/dev/tty1p0");
#elif defined(_TTY_SUN_)
setPortName("/dev/ttya");
#elif defined(_TTY_DIGITAL_)
setPortName("/dev/tty01");
#elif defined(_TTY_FREEBSD_)
setPortName("/dev/ttyd1");
#elif defined(_TTY_OPENBSD_)
setPortName("/dev/tty00");
#else
setPortName("/dev/ttyS0");
#endif
construct();
}
/*!
\fn QextSerialBase::QextSerialBase(const QString & name)
Construct a port and assign it to the device specified by the name parameter.
*/
QextSerialBase::QextSerialBase(const QString & name)
: QIODevice()
{
setPortName(name);
construct();
}
/*!
\fn QextSerialBase::~QextSerialBase()
Standard destructor.
*/
QextSerialBase::~QextSerialBase()
{
delete mutex;
}
/*!
\fn void QextSerialBase::construct()
Common constructor function for setting up default port settings.
(115200 Baud, 8N1, Hardware flow control where supported, otherwise no flow control, and 0 ms timeout).
*/
void QextSerialBase::construct()
{
lastErr = E_NO_ERROR;
Settings.BaudRate=BAUD115200;
Settings.DataBits=DATA_8;
Settings.Parity=PAR_NONE;
Settings.StopBits=STOP_1;
Settings.FlowControl=FLOW_HARDWARE;
Settings.Timeout_Millisec=500;
mutex = new QMutex( QMutex::Recursive );
setOpenMode(QIODevice::NotOpen);
}
void QextSerialBase::setQueryMode(QueryMode mechanism)
{
_queryMode = mechanism;
}
/*!
\fn void QextSerialBase::setPortName(const QString & name)
Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".
*/
void QextSerialBase::setPortName(const QString & name)
{
port = name;
}
/*!
\fn QString QextSerialBase::portName() const
Returns the name set by setPortName().
*/
QString QextSerialBase::portName() const
{
return port;
}
/*!
\fn BaudRateType QextSerialBase::baudRate(void) const
Returns the baud rate of the serial port. For a list of possible return values see
the definition of the enum BaudRateType.
*/
BaudRateType QextSerialBase::baudRate(void) const
{
return Settings.BaudRate;
}
/*!
\fn DataBitsType QextSerialBase::dataBits() const
Returns the number of data bits used by the port. For a list of possible values returned by
this function, see the definition of the enum DataBitsType.
*/
DataBitsType QextSerialBase::dataBits() const
{
return Settings.DataBits;
}
/*!
\fn ParityType QextSerialBase::parity() const
Returns the type of parity used by the port. For a list of possible values returned by
this function, see the definition of the enum ParityType.
*/
ParityType QextSerialBase::parity() const
{
return Settings.Parity;
}
/*!
\fn StopBitsType QextSerialBase::stopBits() const
Returns the number of stop bits used by the port. For a list of possible return values, see
the definition of the enum StopBitsType.
*/
StopBitsType QextSerialBase::stopBits() const
{
return Settings.StopBits;
}
/*!
\fn FlowType QextSerialBase::flowControl() const
Returns the type of flow control used by the port. For a list of possible values returned
by this function, see the definition of the enum FlowType.
*/
FlowType QextSerialBase::flowControl() const
{
return Settings.FlowControl;
}
/*!
\fn bool QextSerialBase::isSequential() const
Returns true if device is sequential, otherwise returns false. Serial port is sequential device
so this function always returns true. Check QIODevice::isSequential() documentation for more
information.
*/
bool QextSerialBase::isSequential() const
{
return true;
}
/*!
\fn bool QextSerialBase::atEnd() const
This function will return true if the input buffer is empty (or on error), and false otherwise.
Call QextSerialBase::lastError() for error information.
*/
bool QextSerialBase::atEnd() const
{
if (size()) {
return true;
}
return false;
}
/*!
\fn qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
This function will read a line of buffered input from the port, stopping when either maxSize bytes
have been read, the port has no more data available, or a newline is encountered.
The value returned is the length of the string that was read.
*/
qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
{
qint64 numBytes = bytesAvailable();
char* pData = data;
if (maxSize < 2) //maxSize must be larger than 1
return -1;
/*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/
while (pData<(data+numBytes) && --maxSize) {
readData(pData, 1);
if (*pData++ == '\n') {
break;
}
}
*pData='\0';
/*return size of data read*/
return (pData-data);
}
/*!
\fn ulong QextSerialBase::lastError() const
Returns the code for the last error encountered by the port, or E_NO_ERROR if the last port
operation was successful. Possible error codes are:
\verbatim
Error Explanation
--------------------------- -------------------------------------------------------------
E_NO_ERROR No Error has occured
E_INVALID_FD Invalid file descriptor (port was not opened correctly)
E_NO_MEMORY Unable to allocate memory tables (POSIX)
E_CAUGHT_NON_BLOCKED_SIGNAL Caught a non-blocked signal (POSIX)
E_PORT_TIMEOUT Operation timed out (POSIX)
E_INVALID_DEVICE The file opened by the port is not a character device (POSIX)
E_BREAK_CONDITION The port detected a break condition
E_FRAMING_ERROR The port detected a framing error
(usually caused by incorrect baud rate settings)
E_IO_ERROR There was an I/O error while communicating with the port
E_BUFFER_OVERRUN Character buffer overrun
E_RECEIVE_OVERFLOW Receive buffer overflow
E_RECEIVE_PARITY_ERROR The port detected a parity error in the received data
E_TRANSMIT_OVERFLOW Transmit buffer overflow
E_READ_FAILED General read operation failure
E_WRITE_FAILED General write operation failure
\endverbatim
*/
ulong QextSerialBase::lastError() const
{
return lastErr;
}
#ifndef _QEXTSERIALBASE_H_
#define _QEXTSERIALBASE_H_
#include <QIODevice>
#include <QFile>
#include <QThread>
#include <QMutex>
/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
#ifdef _TTY_NOWARN_
#define _TTY_NOWARN_PORT_
#endif
/*macros for thread support*/
#define LOCK_MUTEX() mutex->lock()
#define UNLOCK_MUTEX() mutex->unlock()
/*macros for warning and debug messages*/
#ifdef _TTY_NOWARN_PORT_
#define TTY_PORTABILITY_WARNING(s)
#else
#define TTY_PORTABILITY_WARNING(s) qWarning(s)
#endif /*_TTY_NOWARN_PORT_*/
#ifdef _TTY_NOWARN_
#define TTY_WARNING(s)
#else
#define TTY_WARNING(s) qWarning(s)
#endif /*_TTY_NOWARN_*/
/*line status constants*/
#define LS_CTS 0x01
#define LS_DSR 0x02
#define LS_DCD 0x04
#define LS_RI 0x08
#define LS_RTS 0x10
#define LS_DTR 0x20
#define LS_ST 0x40
#define LS_SR 0x80
/*error constants*/
#define E_NO_ERROR 0
#define E_INVALID_FD 1
#define E_NO_MEMORY 2
#define E_CAUGHT_NON_BLOCKED_SIGNAL 3
#define E_PORT_TIMEOUT 4
#define E_INVALID_DEVICE 5
#define E_BREAK_CONDITION 6
#define E_FRAMING_ERROR 7
#define E_IO_ERROR 8
#define E_BUFFER_OVERRUN 9
#define E_RECEIVE_OVERFLOW 10
#define E_RECEIVE_PARITY_ERROR 11
#define E_TRANSMIT_OVERFLOW 12
#define E_READ_FAILED 13
#define E_WRITE_FAILED 14
/*!
* Enums for port settings.
*/
enum NamingConvention {
WIN_NAMES,
IRIX_NAMES,
HPUX_NAMES,
SUN_NAMES,
DIGITAL_NAMES,
FREEBSD_NAMES,
OPENBSD_NAMES,
LINUX_NAMES
};
enum BaudRateType {
BAUD50, //POSIX ONLY
BAUD75, //POSIX ONLY
BAUD110,
BAUD134, //POSIX ONLY
BAUD150, //POSIX ONLY
BAUD200, //POSIX ONLY
BAUD300,
BAUD600,
BAUD1200,
BAUD1800, //POSIX ONLY
BAUD2400,
BAUD4800,
BAUD9600,
BAUD14400, //WINDOWS ONLY
BAUD19200,
BAUD38400,
BAUD56000, //WINDOWS ONLY
BAUD57600,
BAUD76800, //POSIX ONLY
BAUD115200,
BAUD128000, // WINDOWS ONLY
BAUD230400, // WINDOWS ONLY
BAUD256000, // WINDOWS ONLY
BAUD460800, // WINDOWS ONLY
BAUD921600 // WINDOWS ONLY
};
enum DataBitsType {
DATA_5,
DATA_6,
DATA_7,
DATA_8
};
enum ParityType {
PAR_NONE,
PAR_ODD,
PAR_EVEN,
PAR_MARK, //WINDOWS ONLY
PAR_SPACE
};
enum StopBitsType {
STOP_1,
STOP_1_5, //WINDOWS ONLY
STOP_2
};
enum FlowType {
FLOW_OFF,
FLOW_HARDWARE,
FLOW_XONXOFF
};
/**
* structure to contain port settings
*/
struct PortSettings {
BaudRateType BaudRate;
DataBitsType DataBits;
ParityType Parity;
StopBitsType StopBits;
FlowType FlowControl;
long Timeout_Millisec;
};
/*!
* \author Stefan Sander
* \author Michal Policht
*
* A common base class for Win_QextSerialBase, Posix_QextSerialBase and QextSerialPort.
*/
class QextSerialBase : public QIODevice
{
Q_OBJECT
public:
enum QueryMode {
Polling,
EventDriven
};
protected:
QMutex* mutex;
QString port;
PortSettings Settings;
ulong lastErr;
QextSerialBase::QueryMode _queryMode;
virtual qint64 readData(char * data, qint64 maxSize)=0;
virtual qint64 writeData(const char * data, qint64 maxSize)=0;
public:
QextSerialBase();
QextSerialBase(const QString & name);
virtual ~QextSerialBase();
virtual void construct();
virtual void setPortName(const QString & name);
virtual QString portName() const;
/**!