/** * @file * * @author Max Lammers * @author Mamadou Babaei * * Callback implementation taken from Klemen Peganc version of SenseComm. * * @section LICENSE * * Copyright (c) 2020 - 2025 SenseGlove * * @section DESCRIPTION * * Serial Communication interface. Based on a 'SGCONNECT_SERIAL_MODE' variable * defined in the CMakeLists.txt file, a different method of interfacing is * used. */ #pragma once #ifndef BOOST_DATE_TIME_NO_LIB #define BOOST_DATE_TIME_NO_LIB #endif #ifndef BOOST_REGEX_NO_LIB #define BOOST_REGEX_NO_LIB #endif #include #include #include /* if a read-thread is desired. */ #include /* if a read-thread is desired. */ #include #include #include #include #include #include "Connection.hpp" #include "Platform.hpp" #include "PortInfo.hpp" /* Do not forward declare this, or else we'll encounter LINK2019 build error on MSVC */ namespace SGConnect { class SerialConnection; }// namespace SGConnect class SGConnect::SerialConnection : public SGConnect::Connection { public: /// Default BAUD rate to communicate with Sense Glove Devices. static int32_t GetBaudRate(); /// Default data bit rate to communicate with Sense Glove Devices. static int32_t GetDataBitRate(); private: struct Impl; std::unique_ptr Pimpl; public: SerialConnection(); explicit SerialConnection(const PortInfo& intendedPort); virtual ~SerialConnection(); public: virtual bool IsConnected() override; virtual int32_t Connect(bool bWithReadThread) override; virtual int32_t Disconnect(EExitCode exitCode) override; /// Send a command string through this connection to the Device. virtual int32_t SendToDevice(const std::string& command, bool bHapticCommand) override; /// Access the last received sensor data packet from this device. SG_NODISCARD virtual const std::string& GetLastData() const override; /// Access the last received command from this device. SG_NODISCARD virtual const std::string& GetLastCommand() const override; /// Reset the last received Sensor Data virtual void ResetData() override; /// Reset the last received command. virtual void ResetComamnd() override; };