diff --git a/cmakemodules/DefineExamples.cmake b/cmakemodules/DefineExamples.cmake index 6d12a1d3da..9a5b22ad41 100644 --- a/cmakemodules/DefineExamples.cmake +++ b/cmakemodules/DefineExamples.cmake @@ -55,7 +55,6 @@ IF(BUILD_EXAMPLES) times SocketsTest directoryExplorer - http_tests fileSystemWatcher geometry3D poses @@ -70,6 +69,15 @@ IF(BUILD_EXAMPLES) SET(CMAKE_EXAMPLE_LINK_LIBS ${MRPT_LINKER_LIBS}) GENERATE_CMAKE_FILES_SAMPLES_DIRECTORY() + # === Depending on: mrpt-base, mrpt-comms === + SET(LIST_EXAMPLES_IN_THIS_DIR + http_tests + SerialPort_test + ) + SET(CMAKE_EXAMPLE_DEPS mrpt-base mrpt-comms) + SET(CMAKE_EXAMPLE_LINK_LIBS ${MRPT_LINKER_LIBS}) + GENERATE_CMAKE_FILES_SAMPLES_DIRECTORY() + # === Depending on: mrpt-base, mrpt-gui === # list of examples for each directory: SET(LIST_EXAMPLES_IN_THIS_DIR @@ -238,7 +246,6 @@ IF(BUILD_EXAMPLES) GPS_test sonar_SRF10_test eNoses_test - SerialPort_test FTDI_USB_enumerate_test joystick captureVideoFFmpeg diff --git a/doc/design_of_images/graph_mrpt_libs.dot b/doc/design_of_images/graph_mrpt_libs.dot index f259d3db79..abf4e8bc6e 100644 --- a/doc/design_of_images/graph_mrpt_libs.dot +++ b/doc/design_of_images/graph_mrpt_libs.dot @@ -3,6 +3,7 @@ digraph MRPT_LIBS { node [shape=box,style=filled, fillcolor="#D0D0D0"]; base [label="mrpt-base",URL="group__mrpt__base__grp.html"]; + comms [label="mrpt-comms",URL="group__mrpt__comms__grp.html"]; graphs [label="mrpt-graphs",URL="group__mrpt__graphs__grp.html"]; bayes [label="mrpt-bayes (.h)",URL="group__mrpt__bayes__grp.html"]; opengl [label="mrpt-opengl", URL="group__mrpt__opengl__grp.html"]; @@ -32,6 +33,7 @@ digraph MRPT_LIBS { graphs -> base; tfest -> base; + comms -> base; bayes -> base; @@ -43,6 +45,7 @@ digraph MRPT_LIBS { hwdrivers -> gui; hwdrivers -> maps; + hwdrivers -> comms; topography -> obs; topography -> tfest; diff --git a/doc/design_of_images/graph_mrpt_libs.map b/doc/design_of_images/graph_mrpt_libs.map index e9ff884a32..95cc36c5ad 100644 --- a/doc/design_of_images/graph_mrpt_libs.map +++ b/doc/design_of_images/graph_mrpt_libs.map @@ -1,20 +1,21 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/doc/design_of_images/graph_mrpt_libs.png b/doc/design_of_images/graph_mrpt_libs.png index cee48840d3..4d75909eb5 100644 Binary files a/doc/design_of_images/graph_mrpt_libs.png and b/doc/design_of_images/graph_mrpt_libs.png differ diff --git a/doc/design_of_images/graph_mrpt_libs.svg b/doc/design_of_images/graph_mrpt_libs.svg index e585a5e361..b89980a94a 100644 --- a/doc/design_of_images/graph_mrpt_libs.svg +++ b/doc/design_of_images/graph_mrpt_libs.svg @@ -1,307 +1,325 @@ - - + MRPT_LIBS - + base - -mrpt-base + +mrpt-base + +comms + + +mrpt-comms + + + + +comms->base + + + -graphs - - -mrpt-graphs +graphs + + +mrpt-graphs graphs->base - - + + -bayes - - -mrpt-bayes (.h) +bayes + + +mrpt-bayes (.h) -bayes->base - - +bayes->base + + -opengl - - -mrpt-opengl +opengl + + +mrpt-opengl -opengl->base - - +opengl->base + + -gui - - -mrpt-gui +gui + + +mrpt-gui -gui->opengl - - +gui->opengl + + -obs - - -mrpt-obs +obs + + +mrpt-obs -obs->opengl - - +obs->opengl + + -hwdrivers - - -mrpt-hwdrivers +hwdrivers + + +mrpt-hwdrivers + +hwdrivers->comms + + + -hwdrivers->gui - - +hwdrivers->gui + + -maps - - -mrpt-maps +maps + + +mrpt-maps -hwdrivers->maps - - +hwdrivers->maps + + -topography - - -mrpt-topography +topography + + +mrpt-topography -topography->obs - - +topography->obs + + -tfest - - -mrpt-tfest +tfest + + +mrpt-tfest -topography->tfest - - +topography->tfest + + -maps->graphs - - +maps->graphs + + -maps->obs - - +maps->obs + + -vision - - -mrpt-vision +vision + + +mrpt-vision -vision->obs - - +vision->obs + + tfest->base - - + + -slam - - -mrpt-slam +slam + + +mrpt-slam -slam->graphs - - +slam->graphs + + -slam->bayes - - +slam->bayes + + -slam->maps - - +slam->maps + + -slam->vision - - +slam->vision + + -slam->tfest - - +slam->tfest + + -graphslam - - -mrpt-graphslam +graphslam + + +mrpt-graphslam -graphslam->gui - - +graphslam->gui + + -graphslam->slam - - +graphslam->slam + + -hmtslam - - -mrpt-hmtslam +hmtslam + + +mrpt-hmtslam -hmtslam->slam - - +hmtslam->slam + + -hmtslam->graphslam - - +hmtslam->graphslam + + -nav - - -mrpt-nav +nav + + +mrpt-nav -nav->graphs - - +nav->graphs + + -nav->maps - - +nav->maps + + -kinematics - - -mrpt-kinematics +kinematics + + +mrpt-kinematics -nav->kinematics - - +nav->kinematics + + -detectors - - -mrpt-detectors +detectors + + +mrpt-detectors -detectors->gui - - +detectors->gui + + -detectors->maps - - +detectors->maps + + -detectors->vision - - +detectors->vision + + kinematics->opengl - - + + -pbmap - - -mrpt-pbmap +pbmap + + +mrpt-pbmap pbmap->graphs - - + + diff --git a/doc/doxygen-pages/changeLog_doc.h b/doc/doxygen-pages/changeLog_doc.h index ae0072dc1c..eebeb670bc 100644 --- a/doc/doxygen-pages/changeLog_doc.h +++ b/doc/doxygen-pages/changeLog_doc.h @@ -35,6 +35,8 @@ - Removed deprecated mrpt::nav::THolonomicMethod. - mrpt::nav::CAbstractNavigator: callbacks in mrpt::nav::CRobot2NavInterface are now invoked *after* `navigationStep()` to avoid problems if user code invokes the navigator API to change its state. - Added methods to load/save mrpt::nav::TWaypointSequence to configuration files. + - \ref mrpt_comms_grp [NEW IN MRPT 2.0.0] + - This new module has been created to hold all serial devices & networking classes, with minimal dependencies. - BUG FIXES: - Fix reactive navigator inconsistent state if navigation API is called from within rnav callbacks. - Fix incorrect evaluation of "ASSERT" formulas in mrpt::nav::CMultiObjectiveMotionOptimizerBase @@ -131,7 +133,7 @@ - New colormap: mrpt::utils::hot2rgb() - New function mrpt::system::find_mrpt_shared_dir() - New class mrpt::utils::CDynamicGrid3D<> - - New function mrpt::utils::net::http_request() + - New function mrpt::comms::net::http_request() - New function mrpt::system::now_double() - New function mrpt::utils::getAllRegisteredClassesChildrenOf() - Safer CClassRegistry: detect and warn on attempts to duplicated class registration. @@ -317,7 +319,7 @@ - mrpt::math::CQuaternion<> did not check for unit norm in Release builds. - Fix build errors against OpenCV 3.0.0+ without opencv_contrib modules. - mrpt::hwdrivers::CHokuyoURG now correctly handles opening both USB and Ethernet Hokuyo devices (Closes Github issue #180) - - Fixed mrpt::utils::net::DNS_resolve_async() may SIGSEGV in slow networks. + - Fixed mrpt::comms::net::DNS_resolve_async() may SIGSEGV in slow networks. - mrpt::opengl::CMesh::updateColorsMatrix() did not ignore cells masked out. - Wrong weights used in mrpt::poses::CPosePDFSOG::getMean() - Removed ad-hoc bias addition in range-only predictions in landmarks maps. diff --git a/doc/doxygen-pages/dependency_libftdi.h b/doc/doxygen-pages/dependency_libftdi.h index be76e594ac..63cbc72105 100644 --- a/doc/doxygen-pages/dependency_libftdi.h +++ b/doc/doxygen-pages/dependency_libftdi.h @@ -19,7 +19,7 @@ This optional library is needed for interfacing FTDI USB chips in the FIFO parallel mode. If not present, the following classes will raise exceptions upon usage: -- mrpt::hwdrivers::CInterfaceFTDI +- mrpt::comms::CInterfaceFTDI - All its children classes. */ diff --git a/doc/doxygen-pages/lib_mrpt_comms.h b/doc/doxygen-pages/lib_mrpt_comms.h new file mode 100644 index 0000000000..d1827d85ad --- /dev/null +++ b/doc/doxygen-pages/lib_mrpt_comms.h @@ -0,0 +1,20 @@ +/* +---------------------------------------------------------------------------+ + | Mobile Robot Programming Toolkit (MRPT) | + | http://www.mrpt.org/ | + | | + | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file | + | See: http://www.mrpt.org/Authors - All rights reserved. | + | Released under BSD License. See details in http://www.mrpt.org/License | + +---------------------------------------------------------------------------+ */ + +/** \defgroup mrpt_comms_grp [mrpt-comms] + + Back to list of all libraries | See all modules +
+ +

Library mrpt-comms

+
+ +This module includes classes related to serial ports/devices and networking (TCP, DNS,...) utilities. + +*/ diff --git a/doc/doxygen-pages/porting_mrpt2.h b/doc/doxygen-pages/porting_mrpt2.h index 3119b56fea..1969e4fa91 100644 --- a/doc/doxygen-pages/porting_mrpt2.h +++ b/doc/doxygen-pages/porting_mrpt2.h @@ -55,6 +55,7 @@ * - `mrpt::system::sleep(5);` --> `std::this_thread::sleep_for(5ms);` * - `mrpt::synch::CSemaphore sem; sem.waitForSignal(timeout); sem.release();` --> `std::promise sem; auto fut = sem.get_future(); fut.wait_for(...); sem.set_value();` * - `mrpt::utils::CObject::duplicate()` has been removed, use the equivalent (redundant) `mrpt::utils::CObject::clone()`. +* - CSerialPort, `mrpt::utils::net`, sockets: have been moved to its own new module \ref mrpt_comms_grp under namespace `mrpt::comms`. * * **Optional changes** * - Use the `Foo::ConstPtr` smart pointers when possible instead of its non-const counterpart. diff --git a/libs/base/include/mrpt/utils.h b/libs/base/include/mrpt/utils.h index 85d41a2c5f..adf7e57c70 100644 --- a/libs/base/include/mrpt/utils.h +++ b/libs/base/include/mrpt/utils.h @@ -33,10 +33,6 @@ #include #include -// TCP sockets: -#include -#include - #include #include #include @@ -63,7 +59,6 @@ #include #include #include -#include #include #include #include diff --git a/libs/base/include/mrpt/utils/CMessage.h b/libs/base/include/mrpt/utils/CMessage.h index ce44ff6858..dff625c510 100644 --- a/libs/base/include/mrpt/utils/CMessage.h +++ b/libs/base/include/mrpt/utils/CMessage.h @@ -24,7 +24,7 @@ namespace utils * Apart from arbitrary data, specific methods are provided for easing the * serialization of MRPT's "CSerializable" objects. * This class is also used for passing data to hardware interfaces (see - * mrpt::hwdrivers::CSerialPort) + * mrpt::comms::CSerialPort) * \sa CClientTCPSocket * \ingroup mrpt_base_grp */ diff --git a/libs/comms/CMakeLists.txt b/libs/comms/CMakeLists.txt new file mode 100644 index 0000000000..3132c0050f --- /dev/null +++ b/libs/comms/CMakeLists.txt @@ -0,0 +1,10 @@ +#--------------------------------------------- +# Macro declared in "DeclareMRPTLib.cmake": +#--------------------------------------------- +define_mrpt_lib( + # Lib name + comms + # Dependencies + mrpt-base + ) + diff --git a/libs/comms/include/mrpt/comms.h b/libs/comms/include/mrpt/comms.h new file mode 100644 index 0000000000..bb1a29a518 --- /dev/null +++ b/libs/comms/include/mrpt/comms.h @@ -0,0 +1,16 @@ +/* +------------------------------------------------------------------------+ + | Mobile Robot Programming Toolkit (MRPT) | + | http://www.mrpt.org/ | + | | + | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file | + | See: http://www.mrpt.org/Authors - All rights reserved. | + | Released under BSD License. See details in http://www.mrpt.org/License | + +------------------------------------------------------------------------+ */ + +#pragma once + +#include +#include +#include +#include +#include \ No newline at end of file diff --git a/libs/base/include/mrpt/utils/CClientTCPSocket.h b/libs/comms/include/mrpt/comms/CClientTCPSocket.h similarity index 93% rename from libs/base/include/mrpt/utils/CClientTCPSocket.h rename to libs/comms/include/mrpt/comms/CClientTCPSocket.h index 06839e49fa..c75f3f9571 100644 --- a/libs/base/include/mrpt/utils/CClientTCPSocket.h +++ b/libs/comms/include/mrpt/comms/CClientTCPSocket.h @@ -6,24 +6,21 @@ | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#ifndef CClientTCPSocket_H -#define CClientTCPSocket_H +#pragma once #include #include #include -#include #include +#include namespace mrpt { -namespace utils +namespace utils { class CMessage; } +/** Serial and networking devices and utilities */ +namespace comms { class CServerTCPSocket; -class CMessage; - -/** \defgroup network_grp Networking, sockets, DNS - * \ingroup mrpt_base_grp */ /** A TCP socket that can be connected to a TCP server, implementing MRPT's * CStream interface for passing objects as well as generic read/write methods. @@ -32,9 +29,9 @@ class CMessage; * Note that for convenience, DNS lookup is performed with a timeout * (default=3000ms), which can be changed by the static member * CClientTCPSocket::DNS_LOOKUP_TIMEOUT_MS - * \ingroup network_grp + * \ingroup mrpt_comms_grp */ -class BASE_IMPEXP CClientTCPSocket : public CStream +class COMMS_IMPEXP CClientTCPSocket : public mrpt::utils::CStream { friend class CServerTCPSocket; @@ -77,10 +74,7 @@ class BASE_IMPEXP CClientTCPSocket : public CStream size_t Write(const void* Buffer, size_t Count) override; /** Returns a description of the last Sockets error */ - std::string getLastErrorStr() - { - return mrpt::utils::net::getLastSocketErrorStr(); - } + std::string getLastErrorStr(); public: /** Default constructor \sa connect */ @@ -179,7 +173,8 @@ class BASE_IMPEXP CClientTCPSocket : public CStream * socket in each write operation. * \return Returns false on any error, or true if everything goes fine. */ - bool sendMessage(const CMessage& outMsg, const int timeout_ms = -1); + bool sendMessage(const mrpt::utils::CMessage& outMsg, + const int timeout_ms = -1); /** Waits for an incoming message through the TCP stream. * \param inMsg The received message is placed here. @@ -191,7 +186,7 @@ class BASE_IMPEXP CClientTCPSocket : public CStream * goes fine. */ bool receiveMessage( - CMessage& inMsg, const unsigned int timeoutStart_ms = 100, + mrpt::utils::CMessage& inMsg, const unsigned int timeoutStart_ms = 100, const unsigned int timeoutBetween_ms = 1000); /** Return the number of bytes already in the receive queue (they can be @@ -221,4 +216,3 @@ class BASE_IMPEXP CClientTCPSocket : public CStream } // End of namespace } // end of namespace -#endif diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CInterfaceFTDI.h b/libs/comms/include/mrpt/comms/CInterfaceFTDI.h similarity index 93% rename from libs/hwdrivers/include/mrpt/hwdrivers/CInterfaceFTDI.h rename to libs/comms/include/mrpt/comms/CInterfaceFTDI.h index adb599582a..497ccd9a9c 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CInterfaceFTDI.h +++ b/libs/comms/include/mrpt/comms/CInterfaceFTDI.h @@ -6,26 +6,24 @@ | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ - -#ifndef CInterfaceFTDI_H -#define CInterfaceFTDI_H +#pragma once #include #include #include -#include +#include #include namespace mrpt { -namespace hwdrivers +namespace comms { /** A list of FTDI devices and their descriptors. * \sa CInterfaceFTDI::ListAllDevices - * \ingroup mrpt_hwdrivers_grp + * \ingroup mrpt_comms_grp */ -struct HWDRIVERS_IMPEXP TFTDIDevice +struct COMMS_IMPEXP TFTDIDevice { std::string ftdi_manufacturer; std::string ftdi_description; @@ -43,7 +41,7 @@ struct HWDRIVERS_IMPEXP TFTDIDevice }; /** Print out all the information of a FTDI device in textual form. */ -std::ostream HWDRIVERS_IMPEXP& operator<<( +std::ostream COMMS_IMPEXP& operator<<( std::ostream& o, const TFTDIDevice& d); /** Used in CInterfaceFTDI::ListAllDevices */ @@ -61,9 +59,7 @@ typedef std::deque TFTDIDeviceList; * If there is any error during the communications (or loading the Windows *DLL), a std::exception will be raised. * - * To write bulk data, use CStream::ReadBuffer and CStream::WriteBuffer. See - *also the derived classes for - * higher level communication: CInterfaceFTDIMessages + * To write bulk data, use CStream::ReadBuffer and CStream::WriteBuffer. * * Warning: Avoid defining an object of this class in a global scope if you want *to catch all potential @@ -75,10 +71,10 @@ typedef std::deque TFTDIDeviceList; *serial numbers. JLBC * - 15/APR/2008: Implemented for Linux using libftdi. JLBC * - * \sa CInterfaceFTDIMessages, CStream - * \ingroup mrpt_hwdrivers_grp + * \sa CStream + * \ingroup mrpt_comms_grp */ -class HWDRIVERS_IMPEXP CInterfaceFTDI : public utils::CStream +class COMMS_IMPEXP CInterfaceFTDI : public utils::CStream { public: /** Constructor, which loads driver interface (the DLL under Windows). @@ -257,6 +253,4 @@ class HWDRIVERS_IMPEXP CInterfaceFTDI : public utils::CStream }; // end of class } // end of namespace -} // end of namespace - -#endif +} // end of namespace \ No newline at end of file diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CSerialPort.h b/libs/comms/include/mrpt/comms/CSerialPort.h similarity index 97% rename from libs/hwdrivers/include/mrpt/hwdrivers/CSerialPort.h rename to libs/comms/include/mrpt/comms/CSerialPort.h index 0792380b55..8c9cc0106b 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CSerialPort.h +++ b/libs/comms/include/mrpt/comms/CSerialPort.h @@ -6,18 +6,16 @@ | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ - -#ifndef CSERIALPORT_H -#define CSERIALPORT_H +#pragma once #include #include #include -#include +#include namespace mrpt { -namespace hwdrivers +namespace comms { /** A communications serial port built as an implementation of a utils::CStream. * On communication errors (eg. the given port number does not exist, @@ -42,11 +40,12 @@ namespace hwdrivers * - 1/DEC/2005: (JLBC) First version * - 20/DEC/2006: (JLBC) Integration into the MRPT framework * - 12/DEC/2007: (JLBC) Added support for Linux. + * - 22/AUG/2017: (JLBC) Moved to new module mrpt-comms * * \todo Add the internal buffer to the Windows implementation also - * \ingroup mrpt_hwdrivers_grp + * \ingroup mrpt_comms_grp */ -class HWDRIVERS_IMPEXP CSerialPort : public mrpt::utils::CStream +class COMMS_IMPEXP CSerialPort : public mrpt::utils::CStream { friend class PosixSignalDispatcherImpl; @@ -235,5 +234,3 @@ class HWDRIVERS_IMPEXP CSerialPort : public mrpt::utils::CStream } // end of namespace } // end of namespace - -#endif diff --git a/libs/base/include/mrpt/utils/CServerTCPSocket.h b/libs/comms/include/mrpt/comms/CServerTCPSocket.h similarity index 90% rename from libs/base/include/mrpt/utils/CServerTCPSocket.h rename to libs/comms/include/mrpt/comms/CServerTCPSocket.h index 3a51eebfa2..1b41bc9c65 100644 --- a/libs/base/include/mrpt/utils/CServerTCPSocket.h +++ b/libs/comms/include/mrpt/comms/CServerTCPSocket.h @@ -6,25 +6,24 @@ | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#ifndef CServerTCPSocket_H -#define CServerTCPSocket_H +#pragma once #include #include -#include #include +#include namespace mrpt { -namespace utils +namespace comms { class CClientTCPSocket; /** A TCP socket that can be wait for client connections to enter. * Unless otherwise noticed, operations are blocking. - * \ingroup network_grp + * \ingroup mrpt_comms_grp */ -class BASE_IMPEXP CServerTCPSocket : public utils::COutputLogger +class COMMS_IMPEXP CServerTCPSocket : public utils::COutputLogger { public: /** Constructor that creates the socket, performs binding, and start @@ -70,10 +69,7 @@ class BASE_IMPEXP CServerTCPSocket : public utils::COutputLogger m_serverSock; /** Returns a description of the last Sockets error */ - std::string getLastErrorStr() - { - return mrpt::utils::net::getLastSocketErrorStr(); - } + std::string getLastErrorStr(); /** Common code called from the platform-dependant constructor */ void setupSocket( @@ -85,4 +81,3 @@ class BASE_IMPEXP CServerTCPSocket : public utils::COutputLogger } // End of namespace } // End of namespace -#endif // file diff --git a/libs/comms/include/mrpt/comms/link_pragmas.h b/libs/comms/include/mrpt/comms/link_pragmas.h new file mode 100644 index 0000000000..0324e88c55 --- /dev/null +++ b/libs/comms/include/mrpt/comms/link_pragmas.h @@ -0,0 +1,43 @@ +/* +------------------------------------------------------------------------+ + | Mobile Robot Programming Toolkit (MRPT) | + | http://www.mrpt.org/ | + | | + | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file | + | See: http://www.mrpt.org/Authors - All rights reserved. | + | Released under BSD License. See details in http://www.mrpt.org/License | + +------------------------------------------------------------------------+ */ + +#pragma once + +#include + +// ** Important! ** +// In each mrpt library, search and replace: +// MRPT_XXX_EXPORT, MRPT_XXX_IMPORT +// COMMS_IMPEXP, mrpt_xxx_EXPORTS + +/* The macros below for DLL import/export are required for Windows only. + Mostly all the definitions in this file are copied or at least topod + on the file wx/dlimpexp.h, written by Vadim Zeitlin and published + under the wxWindows licence. +*/ +#if defined(MRPT_OS_WINDOWS) +#define MRPT_COMMS_EXPORT __declspec(dllexport) +#define MRPT_COMMS_IMPORT __declspec(dllimport) +#else +#define MRPT_COMMS_EXPORT +#define MRPT_COMMS_IMPORT +#endif + +/* Macros that map to export declaration when building the DLL, to import + declaration if using it or to nothing at all if we are not compiling as DLL + */ +#if defined(MRPT_BUILT_AS_DLL) +#if defined(mrpt_comms_EXPORTS) /* Building the DLL */ +#define COMMS_IMPEXP MRPT_COMMS_EXPORT +#else /* Using the DLL */ +#define COMMS_IMPEXP MRPT_COMMS_IMPORT +#endif +#else /* not making nor using DLL */ +#define COMMS_IMPEXP +#endif diff --git a/libs/base/include/mrpt/utils/net_utils.h b/libs/comms/include/mrpt/comms/net_utils.h similarity index 93% rename from libs/base/include/mrpt/utils/net_utils.h rename to libs/comms/include/mrpt/comms/net_utils.h index 00e17f9c7b..3b56e89487 100644 --- a/libs/base/include/mrpt/utils/net_utils.h +++ b/libs/comms/include/mrpt/comms/net_utils.h @@ -6,24 +6,24 @@ | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#ifndef MRPT_NET_UTILS_H -#define MRPT_NET_UTILS_H +#pragma once #include #include #include +#include namespace mrpt { -namespace utils +namespace comms { /** A set of useful routines for networking. (in #include - * ) - * \ingroup network_grp + * ) + * \ingroup mrpt_comms_grp */ namespace net { -/** \addtogroup network_grp +/** \addtogroup mrpt_comms_grp * @{ */ using std::string; @@ -58,7 +58,7 @@ enum ERRORCODE_HTTP * \return The error or success code. * \sa mrpt::utils::vectorToBinaryFile */ -ERRORCODE_HTTP BASE_IMPEXP http_get( +ERRORCODE_HTTP COMMS_IMPEXP http_get( const string& url, vector_byte& out_content, string& out_errormsg, int port = 80, const string& auth_user = string(), const string& auth_pass = string(), int* out_http_responsecode = nullptr, @@ -85,7 +85,7 @@ ERRORCODE_HTTP BASE_IMPEXP http_get( * \return The error or success code. * \sa mrpt::utils::vectorToBinaryFile */ -ERRORCODE_HTTP BASE_IMPEXP http_get( +ERRORCODE_HTTP COMMS_IMPEXP http_get( const string& url, string& out_content, string& out_errormsg, int port = 80, const string& auth_user = string(), const string& auth_pass = string(), int* out_http_responsecode = nullptr, @@ -94,7 +94,7 @@ ERRORCODE_HTTP BASE_IMPEXP http_get( int timeout_ms = 1000); /** Generic function for HTTP GET & POST methods. \sa http_get */ -ERRORCODE_HTTP BASE_IMPEXP http_request( +ERRORCODE_HTTP COMMS_IMPEXP http_request( const string& http_method, const string& http_send_content, const string& url, vector_byte& out_content, string& out_errormsg, int port = 80, const string& auth_user = string(), @@ -110,12 +110,12 @@ ERRORCODE_HTTP BASE_IMPEXP http_request( * * \return true on success, false on timeout or other error. */ -bool BASE_IMPEXP DNS_resolve_async( +bool COMMS_IMPEXP DNS_resolve_async( const std::string& server_name, std::string& out_ip, const unsigned int timeout_ms = 3000); /** Returns a description of the last Sockets error */ -std::string BASE_IMPEXP getLastSocketErrorStr(); +std::string COMMS_IMPEXP getLastSocketErrorStr(); /** @brief Ping an IP address * @@ -131,7 +131,7 @@ std::string BASE_IMPEXP getLastSocketErrorStr(); * } * */ -bool BASE_IMPEXP Ping( +bool COMMS_IMPEXP Ping( const std::string& address, const int& max_attempts, std::string* output_str = NULL); @@ -140,5 +140,3 @@ bool BASE_IMPEXP Ping( } // End of namespace } // End of namespace } // end of namespace - -#endif diff --git a/libs/base/src/utils/CClientTCPSocket.cpp b/libs/comms/src/CClientTCPSocket.cpp similarity index 98% rename from libs/base/src/utils/CClientTCPSocket.cpp rename to libs/comms/src/CClientTCPSocket.cpp index 6468369e84..9e75e97e42 100644 --- a/libs/base/src/utils/CClientTCPSocket.cpp +++ b/libs/comms/src/CClientTCPSocket.cpp @@ -7,11 +7,11 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "base-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers -#include +#include #include -#include +#include #include #include @@ -39,6 +39,7 @@ #endif using namespace mrpt::utils; +using namespace mrpt::comms; using namespace mrpt::system; using namespace mrpt; using namespace std; @@ -624,3 +625,9 @@ int CClientTCPSocket::getSOSendBufffer() return value; } + +std::string CClientTCPSocket::getLastErrorStr() +{ + return mrpt::comms::net::getLastSocketErrorStr(); +} + diff --git a/libs/hwdrivers/src/CInterfaceFTDI_LIN.cpp b/libs/comms/src/CInterfaceFTDI_LIN.cpp similarity index 98% rename from libs/hwdrivers/src/CInterfaceFTDI_LIN.cpp rename to libs/comms/src/CInterfaceFTDI_LIN.cpp index 1a011c8d59..81f4d9610a 100644 --- a/libs/hwdrivers/src/CInterfaceFTDI_LIN.cpp +++ b/libs/comms/src/CInterfaceFTDI_LIN.cpp @@ -26,11 +26,11 @@ using namespace mrpt::utils; #endif #endif -#include +#include #include -using namespace mrpt::hwdrivers; +using namespace mrpt::comms; using namespace std; /*------------------------------------------------------------- @@ -498,7 +498,7 @@ void CInterfaceFTDI::SetTimeouts( /*------------------------------------------------------------- OpenByDescription -------------------------------------------------------------*/ -std::ostream& mrpt::hwdrivers::operator<<(std::ostream& o, const TFTDIDevice& d) +std::ostream& mrpt::comms::operator<<(std::ostream& o, const TFTDIDevice& d) { o << "Manufacturer : " << d.ftdi_manufacturer << endl << "Description : " << d.ftdi_description << endl diff --git a/libs/hwdrivers/src/CInterfaceFTDI_WIN.cpp b/libs/comms/src/CInterfaceFTDI_WIN.cpp similarity index 97% rename from libs/hwdrivers/src/CInterfaceFTDI_WIN.cpp rename to libs/comms/src/CInterfaceFTDI_WIN.cpp index a4edb529ca..d9b4a2cd2a 100644 --- a/libs/hwdrivers/src/CInterfaceFTDI_WIN.cpp +++ b/libs/comms/src/CInterfaceFTDI_WIN.cpp @@ -7,7 +7,7 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "hwdrivers-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers #ifdef MRPT_OS_WINDOWS @@ -16,7 +16,7 @@ START OF FTD2XX.H ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===========================================================================*/ -namespace hwdrivers +namespace comms { // The following ifdef block is the standard way of creating macros which make // exporting @@ -131,7 +131,7 @@ typedef void (*PFT_EVENT_HANDLER)(unsigned long, unsigned long); #define FT_DEFAULT_RX_TIMEOUT 300 #define FT_DEFAULT_TX_TIMEOUT 300 -} // end namespace hwdrivers +} // end namespace comms /*=========================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END OF FTD2XX.H @@ -140,11 +140,11 @@ typedef void (*PFT_EVENT_HANDLER)(unsigned long, unsigned long); #include -#include +#include using namespace mrpt; using namespace mrpt::utils; -using namespace mrpt::hwdrivers; +using namespace mrpt::comms; using namespace std; /*------------------------------------------------------------- @@ -466,7 +466,7 @@ void CInterfaceFTDI::OpenByDescription(const std::string& description) /*------------------------------------------------------------- OpenByDescription -------------------------------------------------------------*/ -std::ostream& mrpt::hwdrivers::operator<<(std::ostream& o, const TFTDIDevice& d) +std::ostream& mrpt::comms::operator<<(std::ostream& o, const TFTDIDevice& d) { o << "Manufacturer : " << d.ftdi_manufacturer << endl << "Description : " << d.ftdi_description << endl diff --git a/libs/hwdrivers/src/CInterfaceFTDI_common.cpp b/libs/comms/src/CInterfaceFTDI_common.cpp similarity index 95% rename from libs/hwdrivers/src/CInterfaceFTDI_common.cpp rename to libs/comms/src/CInterfaceFTDI_common.cpp index 075e5d6ece..0732d99a78 100644 --- a/libs/hwdrivers/src/CInterfaceFTDI_common.cpp +++ b/libs/comms/src/CInterfaceFTDI_common.cpp @@ -7,12 +7,13 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "hwdrivers-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers -#include +#include +#include // min() using namespace mrpt; -using namespace mrpt::hwdrivers; +using namespace mrpt::comms; /*------------------------------------------------------------- Read diff --git a/libs/hwdrivers/src/CSerialPort.cpp b/libs/comms/src/CSerialPort.cpp similarity index 99% rename from libs/hwdrivers/src/CSerialPort.cpp rename to libs/comms/src/CSerialPort.cpp index 479f88dace..b3d440577b 100644 --- a/libs/hwdrivers/src/CSerialPort.cpp +++ b/libs/comms/src/CSerialPort.cpp @@ -7,9 +7,9 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "hwdrivers-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers -#include +#include #include #include @@ -44,8 +44,8 @@ #include using namespace mrpt; +using namespace mrpt::comms; using namespace mrpt::utils; -using namespace mrpt::hwdrivers; using namespace std; using namespace std::literals; diff --git a/libs/base/src/utils/CServerTCPSocket_LIN.cpp b/libs/comms/src/CServerTCPSocket_LIN.cpp similarity index 91% rename from libs/base/src/utils/CServerTCPSocket_LIN.cpp rename to libs/comms/src/CServerTCPSocket_LIN.cpp index 15af98ed4f..0811885c04 100644 --- a/libs/base/src/utils/CServerTCPSocket_LIN.cpp +++ b/libs/comms/src/CServerTCPSocket_LIN.cpp @@ -7,14 +7,14 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "base-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers #include #if defined(MRPT_OS_LINUX) || defined(MRPT_OS_APPLE) -#include -#include +#include +#include #include // Platform specific headers: @@ -32,6 +32,7 @@ using namespace mrpt; using namespace mrpt::utils; +using namespace mrpt::comms; /*--------------------------------------------------------------- Constructor diff --git a/libs/base/src/utils/CServerTCPSocket_WIN.cpp b/libs/comms/src/CServerTCPSocket_WIN.cpp similarity index 92% rename from libs/base/src/utils/CServerTCPSocket_WIN.cpp rename to libs/comms/src/CServerTCPSocket_WIN.cpp index fa72d0589b..444c6053af 100644 --- a/libs/base/src/utils/CServerTCPSocket_WIN.cpp +++ b/libs/comms/src/CServerTCPSocket_WIN.cpp @@ -7,7 +7,7 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "base-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers #include @@ -18,11 +18,12 @@ #pragma comment(lib, "WS2_32.LIB") #endif -#include -#include +#include +#include #include using namespace mrpt::utils; +using namespace mrpt::comms; /*--------------------------------------------------------------- Constructor diff --git a/libs/base/src/utils/CServerTCPSocket_common.cpp b/libs/comms/src/CServerTCPSocket_common.cpp similarity index 93% rename from libs/base/src/utils/CServerTCPSocket_common.cpp rename to libs/comms/src/CServerTCPSocket_common.cpp index 9cc25f6dcd..319829c08c 100644 --- a/libs/base/src/utils/CServerTCPSocket_common.cpp +++ b/libs/comms/src/CServerTCPSocket_common.cpp @@ -7,13 +7,14 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "base-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers -#include -#include +#include +#include +#include #include #include // stderr -using namespace mrpt::utils; +using namespace mrpt::comms; #if defined(MRPT_OS_LINUX) || defined(MRPT_OS_APPLE) #define INVALID_SOCKET (-1) @@ -34,9 +35,11 @@ using namespace mrpt::utils; typedef int socklen_t; #endif -/*--------------------------------------------------------------- - setupSocket - ---------------------------------------------------------------*/ +std::string CServerTCPSocket::getLastErrorStr() +{ + return mrpt::comms::net::getLastSocketErrorStr(); +} + void CServerTCPSocket::setupSocket( unsigned short listenPort, const std::string& IPaddress, int maxConnectionsWaiting) diff --git a/libs/comms/src/comms-precomp.cpp b/libs/comms/src/comms-precomp.cpp new file mode 100644 index 0000000000..0d3f8c4831 --- /dev/null +++ b/libs/comms/src/comms-precomp.cpp @@ -0,0 +1,10 @@ +/* +------------------------------------------------------------------------+ + | Mobile Robot Programming Toolkit (MRPT) | + | http://www.mrpt.org/ | + | | + | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file | + | See: http://www.mrpt.org/Authors - All rights reserved. | + | Released under BSD License. See details in http://www.mrpt.org/License | + +------------------------------------------------------------------------+ */ + +#include "comms-precomp.h" // Precompiled headers diff --git a/libs/comms/src/comms-precomp.h b/libs/comms/src/comms-precomp.h new file mode 100644 index 0000000000..bd0bdfea04 --- /dev/null +++ b/libs/comms/src/comms-precomp.h @@ -0,0 +1,17 @@ +/* +------------------------------------------------------------------------+ + | Mobile Robot Programming Toolkit (MRPT) | + | http://www.mrpt.org/ | + | | + | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file | + | See: http://www.mrpt.org/Authors - All rights reserved. | + | Released under BSD License. See details in http://www.mrpt.org/License | + +------------------------------------------------------------------------+ */ + +#pragma once + +#include +#if MRPT_ENABLE_PRECOMPILED_HDRS + +#include + +#endif diff --git a/libs/base/src/utils/net_utils.cpp b/libs/comms/src/net_utils.cpp similarity index 96% rename from libs/base/src/utils/net_utils.cpp rename to libs/comms/src/net_utils.cpp index e1fdb64589..53184333d8 100644 --- a/libs/base/src/utils/net_utils.cpp +++ b/libs/comms/src/net_utils.cpp @@ -7,11 +7,11 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include "base-precomp.h" // Precompiled headers +#include "comms-precomp.h" // Precompiled headers -#include -#include -#include +#include +#include +#include #include #include @@ -40,13 +40,14 @@ using namespace mrpt; using namespace mrpt::system; using namespace mrpt::utils; -using namespace mrpt::utils::net; +using namespace mrpt::comms; +using namespace mrpt::comms::net; using namespace std; /*--------------------------------------------------------------- http_get ---------------------------------------------------------------*/ -ERRORCODE_HTTP BASE_IMPEXP mrpt::utils::net::http_get( +ERRORCODE_HTTP COMMS_IMPEXP mrpt::comms::net::http_get( const string& url, string& out_content, string& out_errormsg, int port, const string& auth_user, const string& auth_pass, int* out_http_responsecode, mrpt::utils::TParameters* extra_headers, @@ -63,7 +64,7 @@ ERRORCODE_HTTP BASE_IMPEXP mrpt::utils::net::http_get( return ret; } -ERRORCODE_HTTP BASE_IMPEXP mrpt::utils::net::http_request( +ERRORCODE_HTTP COMMS_IMPEXP mrpt::comms::net::http_request( const string& http_method, const string& http_send_content, const string& url, vector_byte& out_content, string& out_errormsg, int port, const string& auth_user, const string& auth_pass, @@ -379,7 +380,7 @@ ERRORCODE_HTTP BASE_IMPEXP mrpt::utils::net::http_request( /*--------------------------------------------------------------- http_get ---------------------------------------------------------------*/ -ERRORCODE_HTTP BASE_IMPEXP mrpt::utils::net::http_get( +ERRORCODE_HTTP COMMS_IMPEXP mrpt::comms::net::http_get( const string& url, vector_byte& out_content, string& out_errormsg, int port, const string& auth_user, const string& auth_pass, int* out_http_responsecode, mrpt::utils::TParameters* extra_headers, @@ -471,7 +472,7 @@ bool net::DNS_resolve_async( } /** Returns a description of the last Sockets error */ -std::string mrpt::utils::net::getLastSocketErrorStr() +std::string mrpt::comms::net::getLastSocketErrorStr() { #ifdef MRPT_OS_WINDOWS const int errnum = WSAGetLastError(); @@ -490,7 +491,7 @@ std::string mrpt::utils::net::getLastSocketErrorStr() } MRPT_TODO("Modify ping to run on Windows + Test this"); -bool mrpt::utils::net::Ping( +bool mrpt::comms::net::Ping( const std::string& address, const int& max_attempts, std::string* output_str /*=NULL*/) { diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CInterfaceFTDIMessages.h b/libs/comms/src/registerAllClasses.cpp similarity index 61% rename from libs/hwdrivers/include/mrpt/hwdrivers/CInterfaceFTDIMessages.h rename to libs/comms/src/registerAllClasses.cpp index 66887646cb..f14ca136de 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CInterfaceFTDIMessages.h +++ b/libs/comms/src/registerAllClasses.cpp @@ -7,22 +7,17 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#ifndef CInterfaceFTDIMessages_H -#define CInterfaceFTDIMessages_H +#include "comms-precomp.h" +#include -#include -#include +#include -namespace mrpt -{ -namespace hwdrivers -{ -/** Since MRPT 0.9.1 this class has no extra functionality, since the methods - * for sending/receiving messages are not in CStream. - */ -typedef CInterfaceFTDI CInterfaceFTDIMessages; - -} // end of namespace -} // end of namespace +using namespace mrpt::comms; +using namespace mrpt::utils; +MRPT_INITIALIZER(registerAllClasses_mrpt_comms) +{ +#if !defined(DISABLE_MRPT_AUTO_CLASS_REGISTRATION) +// registerClass( CLASS_ID( XXXX ) ); #endif +} diff --git a/libs/hwdrivers/CMakeLists.txt b/libs/hwdrivers/CMakeLists.txt index bede44dce2..ffe2b139a8 100644 --- a/libs/hwdrivers/CMakeLists.txt +++ b/libs/hwdrivers/CMakeLists.txt @@ -152,6 +152,7 @@ define_mrpt_lib( hwdrivers # Dependencies mrpt-base + mrpt-comms # serial ports, etc. mrpt-maps # used to laser preview, etc. mrpt-obs mrpt-gui # used to camera preview, etc. diff --git a/libs/hwdrivers/include/mrpt/hwdrivers.h b/libs/hwdrivers/include/mrpt/hwdrivers.h index 4ae1664b05..0792a98f87 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers.h @@ -34,11 +34,9 @@ MRPT_WARNING( #include #include #include -#include #include #include #include -#include #include #include #include diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/C2DRangeFinderAbstract.h b/libs/hwdrivers/include/mrpt/hwdrivers/C2DRangeFinderAbstract.h index d07ea6e664..47bef7e278 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/C2DRangeFinderAbstract.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/C2DRangeFinderAbstract.h @@ -38,7 +38,7 @@ namespace hwdrivers * points want to be ignored (see * C2DRangeFinderAbstract::loadExclusionAreas). * - * \sa hwdrivers::CSerialPort + * \sa comms::CSerialPort * \ingroup mrpt_hwdrivers_grp */ class HWDRIVERS_IMPEXP C2DRangeFinderAbstract @@ -123,7 +123,7 @@ class HWDRIVERS_IMPEXP C2DRangeFinderAbstract /** Binds the object to a given I/O channel. * The stream object must not be deleted before the destruction of this * class. - * \sa hwdrivers::CSerialPort + * \sa comms::CSerialPort */ void bindIO(mrpt::utils::CStream* streamIO); diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CBoardENoses.h b/libs/hwdrivers/include/mrpt/hwdrivers/CBoardENoses.h index a86c9a4778..0aef22c4ce 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CBoardENoses.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CBoardENoses.h @@ -10,8 +10,8 @@ #ifndef CBoardENoses_H #define CBoardENoses_H -#include -#include +#include +#include #include #include @@ -74,9 +74,9 @@ class HWDRIVERS_IMPEXP CBoardENoses : public mrpt::hwdrivers::CGenericSensor // Only one of these two streams will be !=nullptr and open for each // specific eNose board! /** FTDI comms pipe (when not in serial port mode) */ - std::unique_ptr m_stream_FTDI; + std::unique_ptr m_stream_FTDI; /** Serial port comms */ - std::unique_ptr m_stream_SERIAL; + std::unique_ptr m_stream_SERIAL; /** The 3D pose of the master + N slave eNoses on the robot (meters & * radians) */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CBoardSonars.h b/libs/hwdrivers/include/mrpt/hwdrivers/CBoardSonars.h index 7797c040ea..f2dbf78d20 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CBoardSonars.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CBoardSonars.h @@ -9,7 +9,7 @@ #ifndef CBoardSonars_H #define CBoardSonars_H -#include +#include #include #include #include @@ -53,7 +53,7 @@ namespace hwdrivers * * \ingroup mrpt_hwdrivers_grp */ -class HWDRIVERS_IMPEXP CBoardSonars : public hwdrivers::CInterfaceFTDIMessages, +class HWDRIVERS_IMPEXP CBoardSonars : public mrpt::comms::CInterfaceFTDI, public CGenericSensor { DEFINE_GENERIC_SENSOR(CBoardSonars) diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CCANBusReader.h b/libs/hwdrivers/include/mrpt/hwdrivers/CCANBusReader.h index 989a6a5da9..2d7598e680 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CCANBusReader.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CCANBusReader.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace mrpt { @@ -97,7 +97,7 @@ class HWDRIVERS_IMPEXP CCANBusReader : public mrpt::utils::COutputLogger, std::string m_com_port; /** Will be !=nullptr only if I created it, so I must destroy it at the end. */ - CSerialPort* m_mySerialPort; + mrpt::comms::CSerialPort* m_mySerialPort; /** Baudrate: 9600, 38400, 500000 */ int m_com_baudRate; /** Default = 1 */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CEnoseModular.h b/libs/hwdrivers/include/mrpt/hwdrivers/CEnoseModular.h index 7bdfb93666..7cdafd67b5 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CEnoseModular.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CEnoseModular.h @@ -10,8 +10,8 @@ #ifndef CEnoseModular_H #define CEnoseModular_H -#include -#include +#include +#include #include #include #include @@ -73,9 +73,9 @@ class HWDRIVERS_IMPEXP CEnoseModular : public mrpt::hwdrivers::CGenericSensor // Only one of these two streams will be !=nullptr and open for each // specific eNose board! /** FTDI comms pipe (when not in serial port mode) */ - std::unique_ptr m_stream_FTDI; + std::unique_ptr m_stream_FTDI; /** Serial port comms */ - std::unique_ptr m_stream_SERIAL; + std::unique_ptr m_stream_SERIAL; /** The 3D pose of the master + N slave eNoses on the robot (meters & * radians) */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CGPSInterface.h b/libs/hwdrivers/include/mrpt/hwdrivers/CGPSInterface.h index 80d93f64d9..2d21772d29 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CGPSInterface.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CGPSInterface.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CGillAnemometer.h b/libs/hwdrivers/include/mrpt/hwdrivers/CGillAnemometer.h index c9dba1d479..71366c9ed4 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CGillAnemometer.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CGillAnemometer.h @@ -10,7 +10,7 @@ #define CGillAnemometer_H #include -#include +#include #include #include @@ -39,7 +39,7 @@ class HWDRIVERS_IMPEXP CGillAnemometer : public mrpt::hwdrivers::CGenericSensor /** COM port */ - CSerialPort COM; + mrpt::comms::CSerialPort COM; /** Poses */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CGyroKVHDSP3000.h b/libs/hwdrivers/include/mrpt/hwdrivers/CGyroKVHDSP3000.h index 37ad4e5fda..a6b0eb4de9 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CGyroKVHDSP3000.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CGyroKVHDSP3000.h @@ -11,7 +11,7 @@ #define CGyroKVHDSP3000_H #include -#include +#include #include #include @@ -75,7 +75,7 @@ class HWDRIVERS_IMPEXP CGyroKVHDSP3000 : public hwdrivers::CGenericSensor protected: /** This serial port will be attempted to be opened automatically when this * class is first used to request data from the device. - * \sa hwdrivers::CSerialPort + * \sa comms::CSerialPort */ int m_COMbauds; std::string m_com_port; @@ -84,10 +84,10 @@ class HWDRIVERS_IMPEXP CGyroKVHDSP3000 : public hwdrivers::CGenericSensor /** Search the port where the sensor is located and connect to it */ - bool searchPortAndConnect(); + //bool searchPortAndConnect(); /** The serial port connection */ - CSerialPort* m_serialPort; + mrpt::comms::CSerialPort* m_serialPort; GYRO_MODE m_mode; bool m_firstInteration; diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CIMUIntersense.h b/libs/hwdrivers/include/mrpt/hwdrivers/CIMUIntersense.h index 440df9e149..6013692919 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CIMUIntersense.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CIMUIntersense.h @@ -11,7 +11,7 @@ #define CIMUIntersense_H #include -#include +#include #include namespace mrpt diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CIMUXSens.h b/libs/hwdrivers/include/mrpt/hwdrivers/CIMUXSens.h index 7d5d2b5100..031f897352 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CIMUXSens.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CIMUXSens.h @@ -11,7 +11,7 @@ #define CIMUXSens_H #include -#include +#include #include @@ -59,7 +59,7 @@ class HWDRIVERS_IMPEXP CIMUXSens : public hwdrivers::CGenericSensor protected: /** This serial port will be attempted to be opened automatically when this * class is first used to request data from the device. - * \sa hwdrivers::CSerialPort + * \sa comms::CSerialPort */ int m_COMbauds; std::string m_com_port; @@ -72,8 +72,6 @@ class HWDRIVERS_IMPEXP CIMUXSens : public hwdrivers::CGenericSensor */ bool searchPortAndConnect(); - // CSerialPort m_serial_port; //!< The serial port connection - void* /*xsens::Cmt3 */ m_cmt3_ptr; void* /*CmtDeviceId */ m_deviceId_ptr; /** Timeout counter (for internal use only) */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CIbeoLuxETH.h b/libs/hwdrivers/include/mrpt/hwdrivers/CIbeoLuxETH.h index 50ff604245..bf69470098 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CIbeoLuxETH.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CIbeoLuxETH.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include @@ -78,7 +78,7 @@ class HWDRIVERS_IMPEXP CIbeoLuxETH : public mrpt::hwdrivers::CGenericSensor private: std::string m_ip; unsigned int m_port; - mrpt::utils::CClientTCPSocket m_client; + mrpt::comms::CClientTCPSocket m_client; unsigned int m_scanFrequency; // in hertz double m_angleResolution; // in degrees double m_startAngle; // degrees diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CImpinjRFID.h b/libs/hwdrivers/include/mrpt/hwdrivers/CImpinjRFID.h index ad98b6d481..82d2dc5612 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CImpinjRFID.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CImpinjRFID.h @@ -13,8 +13,8 @@ #include #include -#include -#include +#include +#include namespace mrpt { @@ -52,11 +52,11 @@ class HWDRIVERS_IMPEXP CImpinjRFID : public mrpt::hwdrivers::CGenericSensor /** Server socket (listens for the incoming connection) */ - mrpt::utils::CServerTCPSocket* server; + mrpt::comms::CServerTCPSocket* server; /** Client socket (handles the connection to the client) */ - mrpt::utils::CClientTCPSocket* client; + mrpt::comms::CClientTCPSocket* client; /** Driver executable path */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CLMS100eth.h b/libs/hwdrivers/include/mrpt/hwdrivers/CLMS100eth.h index 0ddc8ebfe8..f4c0c5e675 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CLMS100eth.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CLMS100eth.h @@ -11,7 +11,7 @@ #define CLMS100ETH_H #include -#include +#include namespace mrpt { @@ -128,7 +128,7 @@ class HWDRIVERS_IMPEXP CLMS100Eth : public C2DRangeFinderAbstract private: std::string m_ip; unsigned int m_port; - mrpt::utils::CClientTCPSocket m_client; + mrpt::comms::CClientTCPSocket m_client; bool m_turnedOn; std::string m_cmd; bool m_connected; diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CNTRIPEmitter.h b/libs/hwdrivers/include/mrpt/hwdrivers/CNTRIPEmitter.h index ef3f2445c3..18aaf7d97a 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CNTRIPEmitter.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CNTRIPEmitter.h @@ -10,7 +10,7 @@ #define CNTRIPEmitter_H #include -#include +#include #include #include #include @@ -71,7 +71,7 @@ class HWDRIVERS_IMPEXP CNTRIPEmitter : public CGenericSensor /** The NTRIP comms object. */ CNTRIPClient m_client; /** The output serial port. */ - CSerialPort m_out_COM; + mrpt::comms::CSerialPort m_out_COM; /** If set to non-empty, the serial port will be attempted to be opened * automatically when this class is first used to request data from the diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CPtuBase.h b/libs/hwdrivers/include/mrpt/hwdrivers/CPtuBase.h index b1acf9ea7c..eb2460d2c8 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CPtuBase.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CPtuBase.h @@ -10,7 +10,7 @@ #ifndef CPtuBase_H #define CPtuBase_H -#include +#include namespace mrpt { @@ -28,7 +28,7 @@ class HWDRIVERS_IMPEXP CPtuBase double tiltResolution, panResolution; protected: - CSerialPort serPort; + mrpt::comms::CSerialPort serPort; /**************************** Methods ***********************/ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CPtuDPerception.h b/libs/hwdrivers/include/mrpt/hwdrivers/CPtuDPerception.h index 79f1d4f1d6..e3c10a6e50 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CPtuDPerception.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CPtuDPerception.h @@ -10,7 +10,7 @@ #ifndef CPtuDPerception_H #define CPtuDPerception_H -#include +#include #include namespace mrpt diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CRaePID.h b/libs/hwdrivers/include/mrpt/hwdrivers/CRaePID.h index b83e7549b2..9d101fa562 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CRaePID.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CRaePID.h @@ -10,7 +10,7 @@ #define CRaePID_H #include -#include +#include #include #include @@ -40,7 +40,7 @@ class HWDRIVERS_IMPEXP CRaePID : public mrpt::hwdrivers::CGenericSensor /** COM port */ - CSerialPort COM; + mrpt::comms::CSerialPort COM; /** Poses */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CRoboticHeadInterface.h b/libs/hwdrivers/include/mrpt/hwdrivers/CRoboticHeadInterface.h index 2a584884e5..227756c6b5 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CRoboticHeadInterface.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CRoboticHeadInterface.h @@ -10,8 +10,7 @@ #ifndef CRoboticHeadInterface_H #define CRoboticHeadInterface_H -#include -#include +#include #include #include #include @@ -49,13 +48,13 @@ namespace hwdrivers class HWDRIVERS_IMPEXP CRoboticHeadInterface : public mrpt::utils::COutputLogger { private: - CInterfaceFTDIMessages m_usbConnection; + mrpt::comms::CInterfaceFTDI m_usbConnection; utils::CMessage msg; std::string m_serialNumber; std::vector gain; int head_yaw, head_pitch; - bool checkControllerIsConnected(); + //bool checkControllerIsConnected(); protected: /** Loads specific configuration for the device from a given source of diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CServoeNeck.h b/libs/hwdrivers/include/mrpt/hwdrivers/CServoeNeck.h index 1946dda7c4..e9a4096662 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CServoeNeck.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CServoeNeck.h @@ -12,7 +12,7 @@ #include #include -#include +#include namespace mrpt { @@ -20,7 +20,7 @@ namespace hwdrivers { /** A USB-interface for a custom "robotic neck" designed at MAPIR lab. * \ingroup mrpt_hwdrivers_grp */ -class HWDRIVERS_IMPEXP CServoeNeck : public hwdrivers::CInterfaceFTDIMessages +class HWDRIVERS_IMPEXP CServoeNeck : public mrpt::comms::CInterfaceFTDI { public: CServoeNeck(); diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserSerial.h b/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserSerial.h index 836d6bea52..0ca97c3ca5 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserSerial.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserSerial.h @@ -10,7 +10,7 @@ #define CSickLaserSerial_H #include -#include +#include #include namespace mrpt @@ -119,7 +119,7 @@ class HWDRIVERS_IMPEXP CSickLaserSerial : public C2DRangeFinderAbstract std::string m_com_port; /** Will be !=nullptr only if I created it, so I must destroy it at the end. */ - CSerialPort* m_mySerialPort; + mrpt::comms::CSerialPort* m_mySerialPort; /** Baudrate: 9600, 38400, 500000 */ int m_com_baudRate; /** Default = 1 */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserUSB.h b/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserUSB.h index b562c30709..43c4ca730c 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserUSB.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CSickLaserUSB.h @@ -10,7 +10,7 @@ #define CSickLaserUSB_H #include -#include +#include namespace mrpt { @@ -67,7 +67,7 @@ class HWDRIVERS_IMPEXP CSickLaserUSB : public C2DRangeFinderAbstract DEFINE_GENERIC_SENSOR(CSickLaserUSB) private: - CInterfaceFTDI* m_usbConnection; + mrpt::comms::CInterfaceFTDI* m_usbConnection; std::string m_serialNumber; /** Time of the first data packet, for synchronization purposes. */ diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CSkeletonTracker.h b/libs/hwdrivers/include/mrpt/hwdrivers/CSkeletonTracker.h index ba22edb640..a5afaba796 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CSkeletonTracker.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CSkeletonTracker.h @@ -11,7 +11,7 @@ #define CSkeletonTracker_H #include -#include +#include #include #include #include diff --git a/libs/hwdrivers/include/mrpt/hwdrivers/CTuMicos.h b/libs/hwdrivers/include/mrpt/hwdrivers/CTuMicos.h index b55ee86fab..77f61e88e3 100644 --- a/libs/hwdrivers/include/mrpt/hwdrivers/CTuMicos.h +++ b/libs/hwdrivers/include/mrpt/hwdrivers/CTuMicos.h @@ -10,7 +10,7 @@ #ifndef CTuMicos_H #define CTuMicos_H -#include +#include #include #include diff --git a/libs/hwdrivers/src/CBoardENoses.cpp b/libs/hwdrivers/src/CBoardENoses.cpp index a1f72163a2..0831258d46 100644 --- a/libs/hwdrivers/src/CBoardENoses.cpp +++ b/libs/hwdrivers/src/CBoardENoses.cpp @@ -129,9 +129,9 @@ CStream* CBoardENoses::checkConnectionAndConnect() if (!m_stream_FTDI && !m_stream_SERIAL) { if (!m_COM_port.empty()) - m_stream_SERIAL.reset(new CSerialPort); + m_stream_SERIAL.reset(new mrpt::comms::CSerialPort); else - m_stream_FTDI.reset(new CInterfaceFTDI); + m_stream_FTDI.reset(new mrpt::comms::CInterfaceFTDI); } if (m_stream_FTDI) diff --git a/libs/hwdrivers/src/CBoardSonars.cpp b/libs/hwdrivers/src/CBoardSonars.cpp index 3040df5828..cb471cd6ca 100644 --- a/libs/hwdrivers/src/CBoardSonars.cpp +++ b/libs/hwdrivers/src/CBoardSonars.cpp @@ -10,6 +10,7 @@ #include "hwdrivers-precomp.h" // Precompiled headers #include +#include #include #include diff --git a/libs/hwdrivers/src/CCANBusReader.cpp b/libs/hwdrivers/src/CCANBusReader.cpp index 229ab3ccbe..a81ee3df57 100644 --- a/libs/hwdrivers/src/CCANBusReader.cpp +++ b/libs/hwdrivers/src/CCANBusReader.cpp @@ -206,7 +206,7 @@ bool CCANBusReader::tryToOpenComms(std::string* err_msg) if (!m_com_port.empty()) { // cout << "Creating port" << endl; - m_mySerialPort = new CSerialPort(); // Create the port myself: + m_mySerialPort = new mrpt::comms::CSerialPort(); // Create the port myself: } else throw std::logic_error( @@ -217,7 +217,6 @@ bool CCANBusReader::tryToOpenComms(std::string* err_msg) // We assure now we have a stream... try to open it, if it's not done // yet. bool just_open = false; - // CSerialPort* COM = dynamic_cast(m_stream); if (m_mySerialPort != nullptr) { if (!m_mySerialPort->isOpen()) @@ -385,9 +384,6 @@ bool CCANBusReader::waitContinuousSampleFrame( uint8_t& out_src_address, uint8_t& out_data_length, uint16_t& out_pgn, vector& out_data, vector& out_raw_frame) { - // CSerialPort* COM = dynamic_cast(m_stream); - // ASSERTMSG_(COM!=nullptr,"No I/O channel bound to this object"); - size_t nRead, nBytesToRead; size_t nFrameBytes = 0; size_t lengthField; @@ -508,7 +504,6 @@ bool CCANBusReader::setupSerialComms() m_com_baudRate == 9600 || m_com_baudRate == 38400 || m_com_baudRate == 57600 || m_com_baudRate == 500000); - // CSerialPort* COM = dynamic_cast(m_stream); if (m_mySerialPort == nullptr) return true; int detected_rate = 0; @@ -596,9 +591,6 @@ bool CCANBusReader::queryVersion(bool printOutVersion) // Returns false if timeout bool CCANBusReader::waitACK(uint16_t timeout_ms) { - // CSerialPort* COM = dynamic_cast(m_stream); - // ASSERT_(COM); - uint8_t b = 0; CTicTac tictac; tictac.Tic(); @@ -626,9 +618,6 @@ bool CCANBusReader::waitACK(uint16_t timeout_ms) bool CCANBusReader::waitForVersion(uint16_t timeout, bool printOutVersion) { - // CSerialPort* COM = dynamic_cast(m_stream); - // ASSERT_(COM); - uint8_t b; unsigned int nBytes = 0; @@ -680,9 +669,6 @@ bool CCANBusReader::waitForVersion(uint16_t timeout, bool printOutVersion) // Returns false if timeout bool CCANBusReader::waitIncomingFrame(uint16_t timeout) { - // CSerialPort* COM = dynamic_cast(m_stream); - // ASSERT_(COM); - uint8_t b; unsigned int nBytes = 0; @@ -741,9 +727,6 @@ bool CCANBusReader::sendCommandToCANReader( uint8_t cmd_full[1024]; ASSERT_(sizeof(cmd_full) > cmd_len); - // CSerialPort* COM = dynamic_cast(m_stream); - // ASSERT_(COM); - // command is just plain text so no frame header nor CRC is needed memcpy(cmd_full, cmd, cmd_len); cmd_full[cmd_len] = 0x0D; // [CR] at the end diff --git a/libs/hwdrivers/src/CEnoseModular.cpp b/libs/hwdrivers/src/CEnoseModular.cpp index 680c3f2589..0506457b3b 100644 --- a/libs/hwdrivers/src/CEnoseModular.cpp +++ b/libs/hwdrivers/src/CEnoseModular.cpp @@ -67,9 +67,9 @@ CStream* CEnoseModular::checkConnectionAndConnect() if (!m_stream_FTDI && !m_stream_SERIAL) { if (!m_COM_port.empty()) - m_stream_SERIAL.reset(new CSerialPort); + m_stream_SERIAL.reset(new mrpt::comms::CSerialPort); else - m_stream_FTDI.reset(new CInterfaceFTDI); + m_stream_FTDI.reset(new mrpt::comms::CInterfaceFTDI); } if (m_stream_FTDI) diff --git a/libs/hwdrivers/src/CGPSInterface.cpp b/libs/hwdrivers/src/CGPSInterface.cpp index 4fdd20575f..06d24a2dc2 100644 --- a/libs/hwdrivers/src/CGPSInterface.cpp +++ b/libs/hwdrivers/src/CGPSInterface.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -22,6 +22,7 @@ using namespace mrpt::hwdrivers; using namespace mrpt::obs; using namespace mrpt::system; using namespace mrpt::utils; +using namespace mrpt::comms; using namespace std; IMPLEMENTS_GENERIC_SENSOR(CGPSInterface, mrpt::hwdrivers) @@ -229,7 +230,7 @@ void CGPSInterface::setSerialPortName(const std::string& COM_port) if (m_data_stream) { std::lock_guard lock(*m_data_stream_cs); - CSerialPort* serial = dynamic_cast(m_data_stream); + auto serial = dynamic_cast(m_data_stream); if (serial && serial->isOpen()) THROW_EXCEPTION( "Cannot change serial port name when it is already open") @@ -251,11 +252,11 @@ bool CGPSInterface::tryToOpenTheCOM() // If this is the first use of the COM port, create it: if (!m_data_stream) { - m_data_stream = new CSerialPort(); + m_data_stream = new mrpt::comms::CSerialPort(); m_data_stream_is_external = false; } - CSerialPort* serial = dynamic_cast(m_data_stream); + auto serial = dynamic_cast(m_data_stream); if (serial) { std::lock_guard lock(*m_data_stream_cs); diff --git a/libs/hwdrivers/src/CGyroKVHDSP3000.cpp b/libs/hwdrivers/src/CGyroKVHDSP3000.cpp index 9a56e49f58..d267dc71f8 100644 --- a/libs/hwdrivers/src/CGyroKVHDSP3000.cpp +++ b/libs/hwdrivers/src/CGyroKVHDSP3000.cpp @@ -17,6 +17,7 @@ IMPLEMENTS_GENERIC_SENSOR(CGyroKVHDSP3000, mrpt::hwdrivers) using namespace mrpt::utils; +using namespace mrpt::comms; using namespace mrpt::obs; using namespace mrpt::hwdrivers; using namespace std; diff --git a/libs/hwdrivers/src/CHokuyoURG.cpp b/libs/hwdrivers/src/CHokuyoURG.cpp index 3d4dcd1d63..b675fb1d05 100644 --- a/libs/hwdrivers/src/CHokuyoURG.cpp +++ b/libs/hwdrivers/src/CHokuyoURG.cpp @@ -10,8 +10,8 @@ #include "hwdrivers-precomp.h" // Precompiled headers #include -#include -#include +#include +#include #include #include // in library mrpt-maps #include @@ -21,6 +21,7 @@ IMPLEMENTS_GENERIC_SENSOR(CHokuyoURG, mrpt::hwdrivers) using namespace mrpt::utils; using namespace mrpt::obs; using namespace mrpt::hwdrivers; +using namespace mrpt::comms; using namespace mrpt::system; using namespace mrpt::opengl; using namespace std; diff --git a/libs/hwdrivers/src/CImpinjRFID.cpp b/libs/hwdrivers/src/CImpinjRFID.cpp index 8d50d0e2ed..d5719709f6 100644 --- a/libs/hwdrivers/src/CImpinjRFID.cpp +++ b/libs/hwdrivers/src/CImpinjRFID.cpp @@ -105,9 +105,10 @@ void CImpinjRFID::loadConfig_sensorSpecific( void CImpinjRFID::connect() { if (!connected) - + { // Start the server - server = new mrpt::utils::CServerTCPSocket(port); + server = new mrpt::comms::CServerTCPSocket(port); + } client = server->accept(); diff --git a/libs/hwdrivers/src/CNTRIPClient.cpp b/libs/hwdrivers/src/CNTRIPClient.cpp index e9c148a0dc..3ccdabead2 100644 --- a/libs/hwdrivers/src/CNTRIPClient.cpp +++ b/libs/hwdrivers/src/CNTRIPClient.cpp @@ -10,8 +10,8 @@ #include "hwdrivers-precomp.h" // Precompiled headers #include -#include -#include +#include +#include #include #include @@ -19,6 +19,7 @@ using namespace mrpt; using namespace mrpt::utils; +using namespace mrpt::comms; using namespace mrpt::system; using namespace mrpt::hwdrivers; using namespace mrpt::math; @@ -59,7 +60,6 @@ void CNTRIPClient::close() m_upload_data.clear(); if (!m_thread_do_process) return; m_thread_do_process = false; - MRPT_TODO("Is this a race condition if we are not checking for timeout?"); m_sem_sock_closed.get_future().wait_for(500ms); } diff --git a/libs/hwdrivers/src/CRoboPeakLidar.cpp b/libs/hwdrivers/src/CRoboPeakLidar.cpp index b3aa8489ac..860785c4b5 100644 --- a/libs/hwdrivers/src/CRoboPeakLidar.cpp +++ b/libs/hwdrivers/src/CRoboPeakLidar.cpp @@ -10,8 +10,8 @@ #include "hwdrivers-precomp.h" // Precompiled headers #include -#include -#include +#include +#include #include IMPLEMENTS_GENERIC_SENSOR(CRoboPeakLidar, mrpt::hwdrivers) diff --git a/libs/hwdrivers/src/CRovio.cpp b/libs/hwdrivers/src/CRovio.cpp index 614491e72b..5c01186203 100644 --- a/libs/hwdrivers/src/CRovio.cpp +++ b/libs/hwdrivers/src/CRovio.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -20,7 +20,7 @@ using namespace mrpt::utils; using namespace mrpt::obs; using namespace mrpt::hwdrivers; -using namespace mrpt::utils::net; +using namespace mrpt::comms::net; using namespace std; CRovio::TOptions::TOptions() diff --git a/libs/hwdrivers/src/CServoeNeck.cpp b/libs/hwdrivers/src/CServoeNeck.cpp index 4be3afec6a..0f88d888a3 100644 --- a/libs/hwdrivers/src/CServoeNeck.cpp +++ b/libs/hwdrivers/src/CServoeNeck.cpp @@ -9,14 +9,14 @@ #include "hwdrivers-precomp.h" // Precompiled headers -#include +#include #include +#include #include -// const double MAX_VALUE = 10000; // ICR value in the ATMEGA16 - using namespace mrpt::utils; +using namespace mrpt::comms; using namespace mrpt::hwdrivers; using namespace mrpt::math; using namespace std::literals; diff --git a/libs/hwdrivers/src/CSickLaserSerial.cpp b/libs/hwdrivers/src/CSickLaserSerial.cpp index f7376c4e67..4283762e0f 100644 --- a/libs/hwdrivers/src/CSickLaserSerial.cpp +++ b/libs/hwdrivers/src/CSickLaserSerial.cpp @@ -29,6 +29,7 @@ IMPLEMENTS_GENERIC_SENSOR(CSickLaserSerial, mrpt::hwdrivers) using namespace std; using namespace mrpt; using namespace mrpt::utils; +using namespace mrpt::comms; using namespace mrpt::obs; using namespace mrpt::poses; using namespace mrpt::hwdrivers; diff --git a/libs/hwdrivers/src/CSickLaserUSB.cpp b/libs/hwdrivers/src/CSickLaserUSB.cpp index 30206e740c..42213dcad1 100644 --- a/libs/hwdrivers/src/CSickLaserUSB.cpp +++ b/libs/hwdrivers/src/CSickLaserUSB.cpp @@ -24,6 +24,7 @@ IMPLEMENTS_GENERIC_SENSOR(CSickLaserUSB, mrpt::hwdrivers) using namespace std; using namespace mrpt; using namespace mrpt::utils; +using namespace mrpt::comms; using namespace mrpt::obs; using namespace mrpt::hwdrivers; using namespace mrpt::poses; diff --git a/libs/hwdrivers/src/CVelodyneScanner.cpp b/libs/hwdrivers/src/CVelodyneScanner.cpp index 8cbed9c0cd..841f178d41 100644 --- a/libs/hwdrivers/src/CVelodyneScanner.cpp +++ b/libs/hwdrivers/src/CVelodyneScanner.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include // for reverseBytesInPlace() @@ -439,7 +439,7 @@ void CVelodyneScanner::initialize() THROW_EXCEPTION( format( "Error creating UDP socket:\n%s", - mrpt::utils::net::getLastSocketErrorStr().c_str())); + mrpt::comms::net::getLastSocketErrorStr().c_str())); struct sockaddr_in bindAddr; memset(&bindAddr, 0, sizeof(bindAddr)); @@ -450,7 +450,7 @@ void CVelodyneScanner::initialize() if (int(INVALID_SOCKET) == ::bind( m_hDataSock, (struct sockaddr*)(&bindAddr), sizeof(sockaddr))) - THROW_EXCEPTION(mrpt::utils::net::getLastSocketErrorStr()); + THROW_EXCEPTION(mrpt::comms::net::getLastSocketErrorStr()); #ifdef MRPT_OS_WINDOWS unsigned long non_block_mode = 1; @@ -473,7 +473,7 @@ void CVelodyneScanner::initialize() THROW_EXCEPTION( format( "Error creating UDP socket:\n%s", - mrpt::utils::net::getLastSocketErrorStr().c_str())); + mrpt::comms::net::getLastSocketErrorStr().c_str())); bindAddr.sin_port = htons(VELODYNE_POSITION_UDP_PORT); @@ -481,7 +481,7 @@ void CVelodyneScanner::initialize() m_hPositionSock, (struct sockaddr*)(&bindAddr), sizeof(sockaddr))) - THROW_EXCEPTION(mrpt::utils::net::getLastSocketErrorStr()); + THROW_EXCEPTION(mrpt::comms::net::getLastSocketErrorStr()); #ifdef MRPT_OS_WINDOWS if (ioctlsocket(m_hPositionSock, FIONBIO, &non_block_mode)) @@ -855,7 +855,7 @@ mrpt::system::TTimeStamp CVelodyneScanner::internal_receive_UDP_packet( THROW_EXCEPTION( format( "Error in UDP poll():\n%s", - mrpt::utils::net::getLastSocketErrorStr().c_str())); + mrpt::comms::net::getLastSocketErrorStr().c_str())); } if (retval == 0) // poll() timeout? { @@ -1099,7 +1099,7 @@ bool CVelodyneScanner::internal_send_http_post(const std::string& post_data) ASSERTMSG_( !m_device_ip.empty(), "A device IP address must be specified first!"); - using namespace mrpt::utils::net; + using namespace mrpt::comms::net; vector_byte post_out; string post_err_str; @@ -1118,7 +1118,7 @@ bool CVelodyneScanner::internal_send_http_post(const std::string& post_data) post_err_str, 80 /* port */, string(), string(), // user,pass &http_rep_code, &extra_headers, &out_headers); - return mrpt::utils::net::erOk == ret && + return mrpt::comms::net::erOk == ret && (http_rep_code == 200 || http_rep_code == 204); // OK codes MRPT_END; diff --git a/packaging/debian/control.in b/packaging/debian/control.in index 6d4f73a8a5..2ac4d54ac7 100644 --- a/packaging/debian/control.in +++ b/packaging/debian/control.in @@ -183,6 +183,22 @@ Description: Mobile Robot Programming Toolkit - graphslam library . More about MRPT libraries in: http://www.mrpt.org/Libraries +Package: libmrpt-comms@MRPT_VER_MM@ +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, + libmrpt-base@MRPT_VER_MM@ +Multi-Arch: same +Description: Mobile Robot Programming Toolkit - comms library + The Mobile Robot Programming Toolkit (MRPT) is an extensive, cross-platform, + and open source C++ library aimed to help robotics researchers to design and + implement algorithms in the fields of Simultaneous Localization and Mapping + (SLAM, Graph-SLAM, Bundle Adjustment), computer vision, and motion planning + (obstacle avoidance). + . + This package includes the mrpt-comms library. + . + More about MRPT libraries in: http://www.mrpt.org/Libraries Package: libmrpt-vision@MRPT_VER_MM@ Section: libs @@ -370,6 +386,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, libeigen3-dev, libmrpt-topography@MRPT_VER_MM@ (= ${binary:Version}), libmrpt-vision@MRPT_VER_MM@ (= ${binary:Version}), libmrpt-graphs@MRPT_VER_MM@ (= ${binary:Version}), + libmrpt-comms@MRPT_VER_MM@ (= ${binary:Version}), libsuitesparse-dev, liboctomap-dev Description: Mobile Robot Programming Toolkit - Development headers diff --git a/samples/FTDI_USB_enumerate_test/test.cpp b/samples/FTDI_USB_enumerate_test/test.cpp index 539179f7e4..a58aa9609d 100644 --- a/samples/FTDI_USB_enumerate_test/test.cpp +++ b/samples/FTDI_USB_enumerate_test/test.cpp @@ -7,7 +7,7 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include +#include #include #include diff --git a/samples/HOKUYO_laser_test/test.cpp b/samples/HOKUYO_laser_test/test.cpp index 6efc8709f4..fee6aabb7a 100644 --- a/samples/HOKUYO_laser_test/test.cpp +++ b/samples/HOKUYO_laser_test/test.cpp @@ -8,7 +8,7 @@ +------------------------------------------------------------------------+ */ #include -#include +#include #include #include #include diff --git a/samples/SICK_laser_test/test.cpp b/samples/SICK_laser_test/test.cpp index d549e85793..61965030e4 100644 --- a/samples/SICK_laser_test/test.cpp +++ b/samples/SICK_laser_test/test.cpp @@ -8,7 +8,7 @@ +------------------------------------------------------------------------+ */ #include -#include +#include #include #include #include diff --git a/samples/SerialPort_test/test.cpp b/samples/SerialPort_test/test.cpp index 6bb0b18781..c97a7a1bed 100644 --- a/samples/SerialPort_test/test.cpp +++ b/samples/SerialPort_test/test.cpp @@ -7,7 +7,7 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include +#include #include using namespace mrpt::hwdrivers; diff --git a/samples/http_tests/test.cpp b/samples/http_tests/test.cpp index 1db102f37f..78f322092b 100644 --- a/samples/http_tests/test.cpp +++ b/samples/http_tests/test.cpp @@ -7,12 +7,12 @@ | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ -#include +#include #include using namespace mrpt; -using namespace mrpt::utils; -using namespace mrpt::utils::net; +using namespace mrpt::comms; +using namespace mrpt::comms::net; using namespace std; string url = "http://www.google.es/";