diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..f8ca022 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,81 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ] + }, + { + "name": "Linux", + "includePath": [ + "/usr/include/c++/6", + "/usr/include/x86_64-linux-gnu/c++/6", + "/usr/include/c++/6/backward", + "/usr/lib/gcc/x86_64-linux-gnu/6/include", + "/usr/local/include", + "/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "${workspaceRoot}", + "${workspaceRoot}/include" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include/c++/6", + "/usr/include/x86_64-linux-gnu/c++/6", + "/usr/include/c++/6/backward", + "/usr/lib/gcc/x86_64-linux-gnu/6/include", + "/usr/local/include", + "/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed", + "/usr/include/x86_64-linux-gnu", + "/usr/include", + "${workspaceRoot}", + "${workspaceRoot}/include" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "Win32", + "includePath": [ + "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 3 +} \ No newline at end of file diff --git a/README.rst b/README.rst index bd285f4..5ce1e48 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ -============================================================== -serial-port-cpp -============================================================== +============== +CppLinuxSerial +============== ---------------------------------- Serial port library written in C++ @@ -9,20 +9,6 @@ Serial port library written in C++ .. image:: https://api.travis-ci.org/gbmhunter/serial-port-cpp.png?branch=master :target: https://travis-ci.org/gbmhunter/serial-port-cpp -- Author: gbmhunter (http://www.cladlab.com) -- Created: 2014/01/07 -- Last Modified: 2014/05/21 -- Version: v1.0.1.0 -- Company: CladLabs -- Project: Free Code Libraries -- Language: C++ -- Compiler: GCC -- uC Model: n/a -- Computer Architecture: n/a -- Operating System: n/a -- Documentation Format: Doxygen -- License: GPLv3 - .. role:: bash(code) :language: bash diff --git a/include/Config.hpp b/include/Config.hpp deleted file mode 100644 index c1a043f..0000000 --- a/include/Config.hpp +++ /dev/null @@ -1,15 +0,0 @@ -//! -//! @file Config.hpp -//! @author Geoffrey Hunter () -//! @created 2014/01/07 -//! @last-modified 2014/01/07 -//! @brief Config file for the ComPort library. -//! @details -//! See README.rst in repo root dir for more info. - - -namespace SerialPort -{ - - -} diff --git a/include/SerialPort.hpp b/include/SerialPort/SerialPort.hpp index 7a035a7..3f3c6c8 100644 --- a/include/SerialPort.hpp +++ b/include/SerialPort/SerialPort.hpp @@ -1,11 +1,11 @@ -//! -//! @file SerialPort.hpp -//! @author Geoffrey Hunter () -//! @created 2014/01/07 -//! @last-modified 2014/05/21 -//! @brief The main serial port class. -//! @details -//! See README.rst in repo root dir for more info. +/// +/// \file SerialPort.hpp +/// \author Geoffrey Hunter () +/// \created 2014-01-07 +/// \last-modified 2017-11-23 +/// \brief The main serial port class. +/// \details +/// See README.rst in repo root dir for more info. // Header guard #ifndef SERIAL_PORT_SERIAL_PORT_H @@ -17,14 +17,13 @@ #include // POSIX terminal control definitions (struct termios) // User headers -#include "lib/SmartPrint/include/Sp.hpp" +namespace mn { namespace SerialPort { - //! @brief Strongly-typed enumeration of baud rates for use with the SerialPort class - enum class BaudRates - { + /// \brief Strongly-typed enumeration of baud rates for use with the SerialPort class + enum class BaudRates { none, b9600, b57600 @@ -88,9 +87,6 @@ namespace SerialPort //! @brief The file descriptor for the open file. This gets written to when Open() is called. int fileDesc; - //! @brief Object for printing debug and error messages with - SmartPrint::Sp* sp; - //! @brief Returns a populated termios structure for the passed in file descriptor. termios GetTermios(); @@ -99,5 +95,6 @@ namespace SerialPort }; } // namespace SerialPort +} // namespace mn #endif // #ifndef SERIAL_PORT_SERIAL_PORT_H diff --git a/src/SerialPort.cpp b/src/SerialPort.cpp index ea6636b..8dd67db 100644 --- a/src/SerialPort.cpp +++ b/src/SerialPort.cpp @@ -1,8 +1,8 @@ //! //! @file SerialPort.cpp //! @author Geoffrey Hunter () -//! @created 2014/01/07 -//! @last-modified 2014/05/21 +//! @created 2014-01-07 +//! @last-modified 2017-11-23 //! @brief The main serial port class. //! @details //! See README.rst in repo root dir for more info. @@ -17,9 +17,7 @@ #include // POSIX terminal control definitions (struct termios) #include // For throwing std::system_error -#include "../include/Config.hpp" -#include "../include/SerialPort.hpp" -#include "lib/SmartPrint/api/SmartPrint.hpp" +#include "SerialPort/SerialPort.hpp" namespace SerialPort { @@ -27,16 +25,7 @@ namespace SerialPort SerialPort::SerialPort() : filePath(std::string()), baudRate(BaudRates::none), - fileDesc(0), - sp( - new SmartPrint::Sp( - "Port", - &std::cout, - &SmartPrint::Colours::yellow, - &std::cout, - &SmartPrint::Colours::yellow, - &std::cerr, - &SmartPrint::Colours::red)) + fileDesc(0) { // Everything setup in initialiser list } @@ -85,10 +74,9 @@ namespace SerialPort void SerialPort::Open() { - this->sp->PrintDebug(SmartPrint::Ss() << "Attempting to open COM port \"" << this->filePath << "\"."); + std::cout << "Attempting to open COM port \"" << this->filePath << "\"." << std::endl; - if(this->filePath.size() == 0) - { + if(this->filePath.size() == 0) { //this->sp->PrintError(SmartPrint::Ss() << "Attempted to open file when file path has not been assigned to."); //return false; @@ -112,7 +100,7 @@ namespace SerialPort throw std::system_error(EFAULT, std::system_category()); } - this->sp->PrintDebug(SmartPrint::Ss() << "COM port opened successfully."); + std::cout << "COM port opened successfully." << std::endl; // If code reaches here, open and config must of been successful @@ -130,7 +118,7 @@ namespace SerialPort void SerialPort::SetEverythingToCommonDefaults() { - this->sp->PrintDebug(SmartPrint::Ss() << "Configuring COM port \"" << this->filePath << "\"."); + std::cout << "Configuring COM port \"" << this->filePath << "\"." << std::endl; //================== CONFIGURE ==================// @@ -313,7 +301,7 @@ namespace SerialPort if(tcgetattr(this->fileDesc, &tty) != 0) { // Error occurred - this->sp->PrintError(SmartPrint::Ss() << "Could not get terminal attributes for \"" << this->filePath << "\" - " << strerror(errno)); + std::cout << "Could not get terminal attributes for \"" << this->filePath << "\" - " << strerror(errno) << std::endl; throw std::system_error(EFAULT, std::system_category()); //return false; } @@ -329,7 +317,7 @@ namespace SerialPort if(tcsetattr(this->fileDesc, TCSANOW, &myTermios) != 0) { // Error occurred - this->sp->PrintError(SmartPrint::Ss() << "Could not apply terminal attributes for \"" << this->filePath << "\" - " << strerror(errno)); + std::cout << "Could not apply terminal attributes for \"" << this->filePath << "\" - " << strerror(errno) << std::endl; throw std::system_error(EFAULT, std::system_category()); }