From d7e07781085c2557e7afd5a87ba13170fe03d254 Mon Sep 17 00:00:00 2001 From: James Goppert Date: Tue, 29 Mar 2011 23:54:52 -0400 Subject: [PATCH] Added qserial library. qextserial library is no longer maintained, suggest we move to this library, also greater chance for thread safety, library now builds in cmake, will add Serial2 sources to handle the new qserial, should easily plug into serial interface now. --- .gitmodules | 3 ++ CMakeLists.txt | 74 ++++++++++++++++++++++++++++++++ src/comm/SerialLinkInterface.h | 9 ++-- src/comm/SerialSimulationLink.cc | 2 +- src/comm/SerialSimulationLink.h | 5 +-- thirdParty/qserial | 1 + 6 files changed, 85 insertions(+), 9 deletions(-) create mode 160000 thirdParty/qserial diff --git a/.gitmodules b/.gitmodules index f915dfb1d..813caa62f 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 09af57d32..2526cc922 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 ff16a66b1..38fd9d1e3 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 b769f57db..bc834b8d1 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 35f295200..245c914f7 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 000000000..004e3de55 --- /dev/null +++ b/thirdParty/qserial @@ -0,0 +1 @@ +Subproject commit 004e3de552fe25fee593dfcb03e2ffa82cb0b152 -- 2.22.0