diff --git a/.gitmodules b/.gitmodules index f915dfb1d90d2b6ee7f743325098cbaf1300decb..813caa62ffee1d22cca538c4f25a14cdb44c2f48 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "thirdParty/mavlink"] path = thirdParty/mavlink url = https://github.com/pixhawk/mavlink.git +[submodule "thirdParty/qserial"] + path = thirdParty/qserial + url = git://gitorious.org/inbiza-labs/qserialport.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 09af57d3294102ddf56a80052181ba8b52ed6ff6..2526cc92252d793dc3ee91b4ef9e9fb9055db904 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ else() endif() find_or_build_from_source(MAVLINK thirdParty/mavlink FOUND_GIT_REPO) +find_or_build_from_source(QSERIAL thirdParty/qserial FOUND_GIT_REPO) # build libraries from source if not found on system if(MAVLINK_BUILD_FROM_SOURCE) @@ -148,6 +149,16 @@ if(MAVLINK_BUILD_FROM_SOURCE) COMMAND touch MAVLINK_BUILD.stamp) endif() +if(QSERIAL_BUILD_FROM_SOURCE) + set(QSERIAL_INCLUDE_DIRS + ${PROJECT_SOURCE_DIR}/thirdParty/qserial/include + ${PROJECT_SOURCE_DIR}/thirdParty/qserial/include/QtSerialPort + ${PROJECT_SOURCE_DIR}/thirdParty/qserial/src + ) + add_custom_command(OUTPUT QSERIAL_BUILD.stamp + COMMAND touch QSERIAL_BUILD.stamp) +endif() + # data directory if(IN_SRC_BUILD) message(STATUS "configuring for in source build") @@ -202,6 +213,11 @@ if (MAVLINK_FOUND) list(APPEND qgroundcontrolIncludes ${MAVLINK_INCLUDE_DIRS}) endif() +message(STATUS "\t\tQSERIAL\t\t${QSERIAL_FOUND}") +if (QSERIAL_FOUND) + list(APPEND qgroundcontrolIncludes ${QSERIAL_INCLUDE_DIRS}) +endif() + message(STATUS "\t\tOpenSceneGraph\t${OPENSCENEGRAPH_FOUND}") if (OPENSCENEGRAPH_FOUND) list(APPEND qgroundcontrolIncludes ${OPENSCENEGRAPH_INCLUDE_DIRS}) @@ -766,6 +782,64 @@ qt4_wrap_cpp(qextserialportMoc ${qextserialportMocSrc}) add_library(qextserialport ${qextserialportMoc} ${qextserialportSrc}) target_link_libraries(qextserialport ${QT_LIBRARIES}) +# qserial library +#---------------------------------------------------------------------------- + +# qserial headers without Q_OBJECT +# r !grep -RL Q_OBJECT thirdParty/qserial/include +set (qserialHdrs + thirdParty/qserial/include/QtSerialPort/qserialport_export.h + thirdParty/qserial/include/QtSerialPort/QSerialPort + thirdParty/qserial/include/QtSerialPort/qportsettings.h + ) +# qserial headers with Q_OBJECT +# r !grep -Rl Q_OBJECT thirdParty/qserial +set (qserialMocSrc + thirdParty/qserial/include/QtSerialPort/qserialport.h + thirdParty/qserial/include/QtSerialPort/qserialportnative.h +) +# qserial src +set (qserialSrc + thirdParty/qserial/src/common/qserialport.cpp + thirdParty/qserial/src/common/qportsettings.cpp +) + +# qserial resources +set(qserialRscSrc + thirdParty/qserial/src/QtSerialPortd_resource.rc + thirdParty/qserial/src/QtSerialPort_resource.rc +) + +# qserial native code +if (WIN32) + list(APPEND qSerialMocSrc + thirdParty/qserial/src/win32/qwincommevtnotifier.h + thirdParty/qserial/src/win32/wincommevtbreaker.h + ) + list(APPEND qSerialSrc + thirdParty/qserial/src/win32/qserialportnative_win32.cpp + thirdParty/qserial/src/win32/commdcbhelper.h + thirdParty/qserial/src/win32/commdcbhelper.cpp + thirdParty/qserial/src/win32/qserialportnative_wince.cpp + thirdParty/qserial/src/win32/wincommevtbreaker.cpp + thirdParty/qserial/src/win32/qwincommevtnotifier.cpp + ) +elseif(UNIX OR APPLE) + list(APPEND qSerialSrc + thirdParty/qserial/src/posix/termioshelper.h + thirdParty/qserial/src/posix/termioshelper.cpp + thirdParty/qserial/src/posix/qserialportnative_posix.cpp + ) +else() + message(FATAL_ERROR "unknown OS") +endif() + +# qserial linking +qt4_wrap_cpp(qserialMoc ${qserialMocSrc}) +qt4_add_resources(qserialRsc ${qserialRscSrc}) +add_library(qserial ${qserialMoc} ${qserialSrc}) +target_link_libraries(qserial ${QT_LIBRARIES}) + # qmapcontrol library #---------------------------------------------------------------------------- diff --git a/src/comm/SerialLinkInterface.h b/src/comm/SerialLinkInterface.h index ff16a66b10d672b0539d9571c2924af0e4bf01ca..38fd9d1e3e070794229e2193feb87b6ef6cd221d 100644 --- a/src/comm/SerialLinkInterface.h +++ b/src/comm/SerialLinkInterface.h @@ -34,7 +34,6 @@ This file is part of the QGROUNDCONTROL project #include #include -#include #include class SerialLinkInterface : public LinkInterface { @@ -43,8 +42,8 @@ class SerialLinkInterface : public LinkInterface { public: virtual QString getPortName() = 0; virtual int getBaudRate() = 0; - virtual int getDataBits() = 0; - virtual int getStopBits() = 0; + virtual int getDataBits() = 0; + virtual int getStopBits() = 0; virtual int getBaudRateType() = 0; virtual int getFlowType() = 0; @@ -60,8 +59,8 @@ public slots: virtual bool setParityType(int parity) = 0; virtual bool setDataBitsType(int dataBits) = 0; virtual bool setStopBitsType(int stopBits) = 0; - virtual void loadSettings() = 0; - virtual void writeSettings() = 0; + virtual void loadSettings() = 0; + virtual void writeSettings() = 0; }; diff --git a/src/comm/SerialSimulationLink.cc b/src/comm/SerialSimulationLink.cc index b769f57db763d43606a5f1f62b93acefb2927acd..bc834b8d1d5f4b1927f44cc174475f8d423bcfc9 100644 --- a/src/comm/SerialSimulationLink.cc +++ b/src/comm/SerialSimulationLink.cc @@ -99,7 +99,7 @@ void SerialSimulationLink::run() } } -void SerialSimulationLink::enableLoopBackMode(SerialLink* loop) +void SerialSimulationLink::enableLoopBackMode(SerialLinkInterface* loop) { // Lock the data readyBufferMutex.lock(); diff --git a/src/comm/SerialSimulationLink.h b/src/comm/SerialSimulationLink.h index 35f29520006f854fefe4c613c0eb58423aef3648..245c914f7083f85ab5e87ced075c76605fe0d180 100644 --- a/src/comm/SerialSimulationLink.h +++ b/src/comm/SerialSimulationLink.h @@ -39,7 +39,6 @@ This file is part of the QGROUNDCONTROL project #include #include #include -#include /** * The serial simulation link class simulates a robot connected to the groundstation. @@ -72,7 +71,7 @@ public: qint64 getBitsSent(); qint64 getBitsReceived(); - void enableLoopBackMode(SerialLink* loop); + void enableLoopBackMode(SerialLinkInterface * loop); QString getPortName(); int getBaudRate(); int getBaudRateType(); @@ -104,7 +103,7 @@ public slots: protected: QTimer* timer; - SerialLink* loopBack; + SerialLinkInterface* loopBack; /** File which contains the input data (simulated robot messages) **/ QFile* simulationFile; /** File where the commands sent by the groundstation are stored **/ diff --git a/thirdParty/qserial b/thirdParty/qserial new file mode 160000 index 0000000000000000000000000000000000000000..004e3de552fe25fee593dfcb03e2ffa82cb0b152 --- /dev/null +++ b/thirdParty/qserial @@ -0,0 +1 @@ +Subproject commit 004e3de552fe25fee593dfcb03e2ffa82cb0b152