diff --git a/CMakeLists.txt b/CMakeLists.txt index 607a2aa..3fd723a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8.3...3.10) -project(serial) +project(serial_cpp) if(APPLE) find_library(IOKIT_LIBRARY IOKit) @@ -7,27 +7,27 @@ if(APPLE) endif() ## Sources -set(serial_SRCS +set(serial_cpp_SRCS src/serial.cc - include/serial/serial.h - include/serial/v8stdint.h + include/serial_cpp/serial.h + include/serial_cpp/v8stdint.h ) if(APPLE) # If OSX - list(APPEND serial_SRCS src/impl/unix.cc) - list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc) + list(APPEND serial_cpp_SRCS src/impl/unix.cc) + list(APPEND serial_cpp_SRCS src/impl/list_ports/list_ports_osx.cc) elseif(UNIX) # If unix - list(APPEND serial_SRCS src/impl/unix.cc) - list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc) + list(APPEND serial_cpp_SRCS src/impl/unix.cc) + list(APPEND serial_cpp_SRCS src/impl/list_ports/list_ports_linux.cc) else() # If windows - list(APPEND serial_SRCS src/impl/win.cc) - list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc) + list(APPEND serial_cpp_SRCS src/impl/win.cc) + list(APPEND serial_cpp_SRCS src/impl/list_ports/list_ports_win.cc) endif() ## Add serial library -add_library(${PROJECT_NAME} ${serial_SRCS}) +add_library(${PROJECT_NAME} ${serial_cpp_SRCS}) if(APPLE) target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY}) elseif(UNIX) @@ -37,9 +37,9 @@ else() endif() ## Uncomment for example -add_executable(serial_example examples/serial_example.cc) -add_dependencies(serial_example ${PROJECT_NAME}) -target_link_libraries(serial_example ${PROJECT_NAME}) +add_executable(serial_cpp_example examples/serial_cpp_example.cc) +add_dependencies(serial_cpp_example ${PROJECT_NAME}) +target_link_libraries(serial_cpp_example ${PROJECT_NAME}) ## Include headers include_directories(include) @@ -52,17 +52,17 @@ install(TARGETS ${PROJECT_NAME} ) ## Install headers -install(FILES include/serial/serial.h include/serial/v8stdint.h +install(FILES include/serial_cpp/serial.h include/serial/v8stdint.h DESTINATION include/serial) ## Install CMake config -install(FILES cmake/serialConfig.cmake - DESTINATION share/serial/cmake) +install(FILES cmake/serial_cppConfig.cmake + DESTINATION share/serial_cpp/cmake) ## Install package.xml install(FILES package.xml - DESTINATION share/serial) + DESTINATION share/serial_cpp) ## Tests include(CTest) diff --git a/README.md b/README.md index c5d8d0b..3e10042 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,54 @@ -# Serial Communication Library - -[![Build Status](https://travis-ci.org/wjwwood/serial.svg?branch=master)](https://travis-ci.org/wjwwood/serial)*(Linux and OS X)* [![Build Status](https://ci.appveyor.com/api/projects/status/github/wjwwood/serial)](https://ci.appveyor.com/project/wjwwood/serial)*(Windows)* +# `serial_cpp` Serial Communication Library This is a cross-platform library for interfacing with rs-232 serial like ports written in C++. It provides a modern C++ interface with a workflow designed to look and feel like PySerial, but with the speed and control provided by C++. -This library is in use in several robotics related projects and can be built and installed to the OS like most unix libraries with make and then sudo make install, but because it is a catkin project it can also be built along side other catkin projects in a catkin workspace. - -Serial is a class that provides the basic interface common to serial libraries (open, close, read, write, etc..) and requires no extra dependencies. It also provides tight control over timeouts and control over handshaking lines. - -### Documentation +Serial is a class that provides the basic interface common to serial libraries (open, close, read, write, etc..) and requires no extra dependencies. It also provides tight control over timeouts and control over handshaking lines. -Website: http://wjwwood.github.io/serial/ +`serial_cpp` started as a friendly fork [`wjwwood/serial`](https://github.com/wjwwood/serial), see https://github.com/wjwwood/serial/issues/312 for more details. -API Documentation: http://wjwwood.github.io/serial/doc/1.1.0/index.html +> [!NOTE] +> Most projects in the [`ami-iit`](https://github.com/ami-iit) use the dash (`-`) as a separator inside names. This repo makes an exception as it is a derivation of a project originally started in the ROS community, where the use of underscore (`_`) is tipically used, and so the original mantainer asked to keep an underscore, see https://github.com/wjwwood/serial/issues/312#issuecomment-2773775993 . ### Dependencies Required: -* [catkin](http://www.ros.org/wiki/catkin) - cmake and Python based buildsystem +* C++ compiler * [cmake](http://www.cmake.org) - buildsystem -* [Python](http://www.python.org) - scripting language - * [empy](http://www.alcyone.com/pyos/empy/) - Python templating library - * [catkin_pkg](http://pypi.python.org/pypi/catkin_pkg/) - Runtime Python library for catkin Optional (for documentation): * [Doxygen](http://www.doxygen.org/) - Documentation generation tool * [graphviz](http://www.graphviz.org/) - Graph visualization software -### Install - -Get the code: - - git clone https://github.com/wjwwood/serial.git +### Usage compiling from source -Build: +First compile the project: - make +~~~bash +git clone https://github.com/ami-iit/serial_cpp.git +cd serial_cpp +cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -S. -DCMAKE_INSTALL_PREFIX= +cmake --build build +cmake --install build +~~~ -Build and run the tests: +### Development commands - make test +`serial_cpp` is a pure C++ project that can be installed on any system, as long as CMake is available. However, we use [`pixi`](https://pixi.sh) to simplify development, to run the tests (the same run in CI) in pixi, run: -Build the documentation: - - make doc - -Install: - - make install +~~~ +git clone https://github.com/ami-iit/serial_cpp.git +pixi run test +~~~ ### License [The MIT License](LICENSE) -### Authors +### Mantainers -William Woodall -John Harrison +* Silvio Traversaro ([@traversaro](https://github.com/traversaro)) -### Contact +### Authors -William Woodall +* William Woodall +* John Harrison diff --git a/doc/serial.dox b/doc/serial.dox index 407fc26..c0effd1 100644 --- a/doc/serial.dox +++ b/doc/serial.dox @@ -12,13 +12,13 @@ Want to use it with ROS(Robot Operating System)? No problem, it compiles as a un Ready to jump in? - Checkout our examples: \ref serial_example.cc -- Look at the main class documentation: \ref serial::Serial +- Look at the main class documentation: \ref serial_cpp::Serial \section features Features - Linux, Mac OS X, and Windows Support - Easy to use interface (modeled after PySerial) - Minimal dependencies (cmake) -- Complete timeout control \ref serial::Serial::setTimeout +- Complete timeout control \ref serial_cpp::Serial::setTimeout - Check and set handshaking lines (CTS, DSR, RI, CD and RTS, DTR) - Block for changes in handshaking lines (Linux and Windows) - Flush I/O separately and block until all writing done @@ -32,7 +32,7 @@ Ready to jump in? \subsection building Compiling -Once you have gathered the dependencies, you need to checkout the software from github.com: +Once you have gathered the dependencies, you need to checkout the software from github.com:
     git clone git://github.com/wjwwood/serial.git
diff --git a/examples/serial_example.cc b/examples/serial_cpp_example.cc
similarity index 91%
rename from examples/serial_example.cc
rename to examples/serial_cpp_example.cc
index a829635..28f1273 100644
--- a/examples/serial_example.cc
+++ b/examples/serial_cpp_example.cc
@@ -27,7 +27,7 @@
 #include 
 #endif
 
-#include "serial/serial.h"
+#include 
 
 using std::string;
 using std::exception;
@@ -46,13 +46,13 @@ void my_sleep(unsigned long milliseconds) {
 
 void enumerate_ports()
 {
-	vector devices_found = serial::list_ports();
+	vector devices_found = serial_cpp::list_ports();
 
-	vector::iterator iter = devices_found.begin();
+	vector::iterator iter = devices_found.begin();
 
 	while( iter != devices_found.end() )
 	{
-		serial::PortInfo device = *iter++;
+		serial_cpp::PortInfo device = *iter++;
 
 		printf( "(%s, %s, %s)\n", device.port.c_str(), device.description.c_str(),
      device.hardware_id.c_str() );
@@ -93,7 +93,7 @@ int run(int argc, char **argv)
 #endif
 
   // port, baudrate, timeout in milliseconds
-  serial::Serial my_serial(port, baud, serial::Timeout::simpleTimeout(1000));
+  serial_cpp::Serial my_serial(port, baud, serial_cpp::Timeout::simpleTimeout(1000));
 
   cout << "Is the serial port open?";
   if(my_serial.isOpen())
@@ -125,7 +125,7 @@ int run(int argc, char **argv)
   }
 
   // Test the timeout at 250ms
-  my_serial.setTimeout(serial::Timeout::max(), 250, 0, 250, 0);
+  my_serial.setTimeout(serial_cpp::Timeout::max(), 250, 0, 250, 0);
   count = 0;
   cout << "Timeout == 250ms, asking for 1 more byte than written." << endl;
   while (count < 10) {
diff --git a/include/serial/impl/unix.h b/include/serial_cpp/impl/unix.h
similarity index 95%
rename from include/serial/impl/unix.h
rename to include/serial_cpp/impl/unix.h
index 0fb38f2..5a33575 100644
--- a/include/serial/impl/unix.h
+++ b/include/serial_cpp/impl/unix.h
@@ -40,22 +40,22 @@
 #ifndef SERIAL_IMPL_UNIX_H
 #define SERIAL_IMPL_UNIX_H
 
-#include "serial/serial.h"
+#include "serial_cpp/serial.h"
 
 #include 
 
-namespace serial {
+namespace serial_cpp {
 
 using std::size_t;
 using std::string;
 using std::invalid_argument;
 
-using serial::SerialException;
-using serial::IOException;
+using serial_cpp::SerialException;
+using serial_cpp::IOException;
 
 class MillisecondTimer {
 public:
-  MillisecondTimer(const uint32_t millis);         
+  MillisecondTimer(const uint32_t millis);
   int64_t remaining();
 
 private:
@@ -63,7 +63,7 @@ class MillisecondTimer {
   timespec expiry;
 };
 
-class serial::Serial::SerialImpl {
+class serial_cpp::Serial::SerialImpl {
 public:
   SerialImpl (const string &port,
               unsigned long baudrate,
diff --git a/include/serial/impl/win.h b/include/serial_cpp/impl/win.h
similarity index 95%
rename from include/serial/impl/win.h
rename to include/serial_cpp/impl/win.h
index 2c0c6cd..6d2ca04 100644
--- a/include/serial/impl/win.h
+++ b/include/serial_cpp/impl/win.h
@@ -39,20 +39,20 @@
 #ifndef SERIAL_IMPL_WINDOWS_H
 #define SERIAL_IMPL_WINDOWS_H
 
-#include "serial/serial.h"
+#include "serial_cpp/serial.h"
 
 #include "windows.h"
 
-namespace serial {
+namespace serial_cpp {
 
 using std::string;
 using std::wstring;
 using std::invalid_argument;
 
-using serial::SerialException;
-using serial::IOException;
+using serial_cpp::SerialException;
+using serial_cpp::IOException;
 
-class serial::Serial::SerialImpl {
+class serial_cpp::Serial::SerialImpl {
 public:
   SerialImpl (const string &port,
               unsigned long baudrate,
diff --git a/include/serial/serial.h b/include/serial_cpp/serial.h
similarity index 92%
rename from include/serial/serial.h
rename to include/serial_cpp/serial.h
index a165785..8363972 100644
--- a/include/serial/serial.h
+++ b/include/serial_cpp/serial.h
@@ -33,8 +33,8 @@
  * This provides a cross platform interface for interacting with Serial Ports.
  */
 
-#ifndef SERIAL_H
-#define SERIAL_H
+#ifndef SERIAL_CPP_SERIAL_H
+#define SERIAL_CPP_SERIAL_H
 
 #include 
 #include 
@@ -43,12 +43,12 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \
 __LINE__, (message) )
 
-namespace serial {
+namespace serial_cpp {
 
 /*!
  * Enumeration defines the possible bytesizes for the serial port.
@@ -148,7 +148,7 @@ class Serial {
 public:
   /*!
    * Creates a Serial object and opens the port if a port is specified,
-   * otherwise it remains closed until serial::Serial::open is called.
+   * otherwise it remains closed until serial_cpp::Serial::open is called.
    *
    * \param port A std::string containing the address of the serial port,
    *        which would be something like 'COM1' on Windows and '/dev/ttyS0'
@@ -156,8 +156,8 @@ class Serial {
    *
    * \param baudrate An unsigned 32-bit integer that represents the baudrate
    *
-   * \param timeout A serial::Timeout struct that defines the timeout
-   * conditions for the serial port. \see serial::Timeout
+   * \param timeout A serial_cpp::Timeout struct that defines the timeout
+   * conditions for the serial port. \see serial_cpp::Timeout
    *
    * \param bytesize Size of each byte in the serial transmission of data,
    * default is eightbits, possible values are: fivebits, sixbits, sevenbits,
@@ -173,8 +173,8 @@ class Serial {
    * flowcontrol_none, possible values are: flowcontrol_none,
    * flowcontrol_software, flowcontrol_hardware
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::IOException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::IOException
    * \throw std::invalid_argument
    */
   Serial (const std::string &port = "",
@@ -198,8 +198,8 @@ class Serial {
    * \see Serial::Serial
    *
    * \throw std::invalid_argument
-   * \throw serial::SerialException
-   * \throw serial::IOException
+   * \throw serial_cpp::SerialException
+   * \throw serial_cpp::IOException
    */
   void
   open ();
@@ -258,8 +258,8 @@ class Serial {
    * \return A size_t representing the number of bytes read as a result of the
    *         call to read.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
    */
   size_t
   read (uint8_t *buffer, size_t size);
@@ -272,8 +272,8 @@ class Serial {
    * \return A size_t representing the number of bytes read as a result of the
    *         call to read.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
    */
   size_t
   read (std::vector &buffer, size_t size = 1);
@@ -286,8 +286,8 @@ class Serial {
    * \return A size_t representing the number of bytes read as a result of the
    *         call to read.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
    */
   size_t
   read (std::string &buffer, size_t size = 1);
@@ -299,8 +299,8 @@ class Serial {
    *
    * \return A std::string containing the data read from the port.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
    */
   std::string
   read (size_t size = 1);
@@ -315,8 +315,8 @@ class Serial {
    *
    * \return A size_t representing the number of bytes read.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
    */
   size_t
   readline (std::string &buffer, size_t size = 65536, std::string eol = "\n");
@@ -330,8 +330,8 @@ class Serial {
    *
    * \return A std::string containing the line.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
    */
   std::string
   readline (size_t size = 65536, std::string eol = "\n");
@@ -347,8 +347,8 @@ class Serial {
    *
    * \return A vector containing the lines.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
    */
   std::vector
   readlines (size_t size = 65536, std::string eol = "\n");
@@ -364,9 +364,9 @@ class Serial {
    * \return A size_t representing the number of bytes actually written to
    * the serial port.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
-   * \throw serial::IOException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
+   * \throw serial_cpp::IOException
    */
   size_t
   write (const uint8_t *data, size_t size);
@@ -379,9 +379,9 @@ class Serial {
    * \return A size_t representing the number of bytes actually written to
    * the serial port.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
-   * \throw serial::IOException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
+   * \throw serial_cpp::IOException
    */
   size_t
   write (const std::vector &data);
@@ -394,9 +394,9 @@ class Serial {
    * \return A size_t representing the number of bytes actually written to
    * the serial port.
    *
-   * \throw serial::PortNotOpenedException
-   * \throw serial::SerialException
-   * \throw serial::IOException
+   * \throw serial_cpp::PortNotOpenedException
+   * \throw serial_cpp::SerialException
+   * \throw serial_cpp::IOException
    */
   size_t
   write (const std::string &data);
@@ -425,13 +425,13 @@ class Serial {
    *
    * There are two timeout conditions described here:
    *  * The inter byte timeout:
-   *    * The inter_byte_timeout component of serial::Timeout defines the
+   *    * The inter_byte_timeout component of serial_cpp::Timeout defines the
    *      maximum amount of time, in milliseconds, between receiving bytes on
    *      the serial port that can pass before a timeout occurs.  Setting this
    *      to zero will prevent inter byte timeouts from occurring.
    *  * Total time timeout:
    *    * The constant and multiplier component of this timeout condition,
-   *      for both read and write, are defined in serial::Timeout.  This
+   *      for both read and write, are defined in serial_cpp::Timeout.  This
    *      timeout occurs if the total time since the read or write call was
    *      made exceeds the specified time in milliseconds.
    *    * The limit is defined by multiplying the multiplier component by the
@@ -439,7 +439,7 @@ class Serial {
    *      component.  In this way if you want a read call, for example, to
    *      timeout after exactly one second regardless of the number of bytes
    *      you asked for then set the read_timeout_constant component of
-   *      serial::Timeout to 1000 and the read_timeout_multiplier to zero.
+   *      serial_cpp::Timeout to 1000 and the read_timeout_multiplier to zero.
    *      This timeout condition can be used in conjunction with the inter
    *      byte timeout condition with out any problems, timeout will simply
    *      occur when one of the two timeout conditions is met.  This allows
@@ -452,10 +452,10 @@ class Serial {
    *
    * A timeout of 0 enables non-blocking mode.
    *
-   * \param timeout A serial::Timeout struct containing the inter byte
+   * \param timeout A serial_cpp::Timeout struct containing the inter byte
    * timeout, and the read and write timeout constants and multipliers.
    *
-   * \see serial::Timeout
+   * \see serial_cpp::Timeout
    */
   void
   setTimeout (Timeout &timeout);
@@ -763,9 +763,9 @@ struct PortInfo {
 /* Lists the serial ports available on the system
  *
  * Returns a vector of available serial ports, each represented
- * by a serial::PortInfo data structure:
+ * by a serial_cpp::PortInfo data structure:
  *
- * \return vector of serial::PortInfo.
+ * \return vector of serial_cpp::PortInfo.
  */
 std::vector
 list_ports();
diff --git a/include/serial_cpp/serial_compat.h b/include/serial_cpp/serial_compat.h
new file mode 100644
index 0000000..f397d91
--- /dev/null
+++ b/include/serial_cpp/serial_compat.h
@@ -0,0 +1,61 @@
+/*!
+ * \file serial/serial.h
+ *
+ * \section LICENSE
+ *
+ * The MIT License
+ *
+ * Copyright (c) Fondazione Istituto Italiano di Tecnologia
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * \section DESCRIPTION
+ *
+ * This file can be included to provide drop-in compatibility with the wjwwood/serial
+ * library on which serial_cpp is based.
+ */
+
+#ifndef SERIAL_CPP_SERIAL_COMPAT_H
+#define SERIAL_CPP_SERIAL_COMPAT_H
+
+#include 
+
+namespace serial {
+
+typedef serial_cpp::Serial Serial;
+typedef serial_cpp::SerialException SerialException;
+typedef serial_cpp::IOException IOException;
+typedef serial_cpp::PortNotOpenedException PortNotOpenedException;
+typedef serial_cpp::Timeout Timeout;
+typedef serial_cpp::PortInfo PortInfo;
+typedef serial_cpp::bytesize_t bytesize_t;
+typedef serial_cpp::parity_t parity_t;
+typedef serial_cpp::stopbits_t stopbits_t;
+typedef serial_cpp::flowcontrol_t flowcontrol_t;
+
+inline std::vector list_ports()
+{
+    return serial_cpp::list_ports();
+}
+
+}
+
+#endif
+
+
diff --git a/include/serial/v8stdint.h b/include/serial_cpp/v8stdint.h
similarity index 100%
rename from include/serial/v8stdint.h
rename to include/serial_cpp/v8stdint.h
diff --git a/package.xml b/package.xml
index a63b88a..0d9d2c5 100644
--- a/package.xml
+++ b/package.xml
@@ -1,20 +1,20 @@
 
 
-  serial
-  1.2.1
+  serial_cpp
+  1.3.0
   
-    Serial is a cross-platform, simple to use library for using serial ports on computers.
+    serial_cpp is a cross-platform, simple to use library for using serial ports on computers.
     This library provides a C++, object oriented interface for interacting with RS-232
     like devices on Linux and Windows.
   
 
-  William Woodall
+  William Woodall
 
   MIT
 
   http://wjwwood.github.com/serial/
-  https://github.com/wjwwood/serial
-  https://github.com/wjwwood/serial/issues
+  https://github.com/ami-iit/serial_cpp
+  https://github.com/ami-iit/serial_cpp/issues
 
   William Woodall
   John Harrison
diff --git a/src/impl/list_ports/list_ports_linux.cc b/src/impl/list_ports/list_ports_linux.cc
index db2afb2..0749f83 100644
--- a/src/impl/list_ports/list_ports_linux.cc
+++ b/src/impl/list_ports/list_ports_linux.cc
@@ -22,9 +22,9 @@
 #include 
 #include 
 
-#include "serial/serial.h"
+#include "serial_cpp/serial.h"
 
-using serial::PortInfo;
+using serial_cpp::PortInfo;
 using std::istringstream;
 using std::ifstream;
 using std::getline;
@@ -295,7 +295,7 @@ usb_sysfs_hw_string(const string& sysfs_path)
 }
 
 vector
-serial::list_ports()
+serial_cpp::list_ports()
 {
     vector results;
 
diff --git a/src/impl/list_ports/list_ports_osx.cc b/src/impl/list_ports/list_ports_osx.cc
index 333c55c..ddc87b4 100644
--- a/src/impl/list_ports/list_ports_osx.cc
+++ b/src/impl/list_ports/list_ports_osx.cc
@@ -12,9 +12,9 @@
 #include 
 #include 
 
-#include "serial/serial.h"
+#include "serial_cpp/serial.h"
 
-using serial::PortInfo;
+using serial_cpp::PortInfo;
 using std::string;
 using std::vector;
 
@@ -208,7 +208,7 @@ string rtrim(const string& str)
 }
 
 vector
-serial::list_ports(void)
+serial_cpp::list_ports(void)
 {
     vector devices_found;
     CFMutableDictionaryRef classes_to_match;
diff --git a/src/impl/list_ports/list_ports_win.cc b/src/impl/list_ports/list_ports_win.cc
index 7da40c4..419e33e 100644
--- a/src/impl/list_ports/list_ports_win.cc
+++ b/src/impl/list_ports/list_ports_win.cc
@@ -7,7 +7,7 @@
  * http://opensource.org/licenses/MIT
  */
 
-#include "serial/serial.h"
+#include "serial_cpp/serial.h"
 #include 
 #include 
 #include 
@@ -15,7 +15,7 @@
 #include 
 #include 
 
-using serial::PortInfo;
+using serial_cpp::PortInfo;
 using std::vector;
 using std::string;
 
@@ -33,7 +33,7 @@ std::string utf8_encode(const std::wstring &wstr)
 }
 
 vector
-serial::list_ports()
+serial_cpp::list_ports()
 {
 	vector devices_found;
 
diff --git a/src/impl/unix.cc b/src/impl/unix.cc
index a40b0fa..fc3936d 100755
--- a/src/impl/unix.cc
+++ b/src/impl/unix.cc
@@ -32,7 +32,7 @@
 #include 
 #endif
 
-#include "serial/impl/unix.h"
+#include "serial_cpp/impl/unix.h"
 
 #ifndef TIOCINQ
 #ifdef FIONREAD
@@ -49,11 +49,11 @@
 using std::string;
 using std::stringstream;
 using std::invalid_argument;
-using serial::MillisecondTimer;
-using serial::Serial;
-using serial::SerialException;
-using serial::PortNotOpenedException;
-using serial::IOException;
+using serial_cpp::MillisecondTimer;
+using serial_cpp::Serial;
+using serial_cpp::SerialException;
+using serial_cpp::PortNotOpenedException;
+using serial_cpp::IOException;
 
 
 MillisecondTimer::MillisecondTimer (const uint32_t millis)
@@ -666,7 +666,7 @@ Serial::SerialImpl::write (const uint8_t *data, size_t length)
         ssize_t bytes_written_now =
           ::write (fd_, data + bytes_written, length - bytes_written);
 
-        // even though pselect returned readiness the call might still be 
+        // even though pselect returned readiness the call might still be
         // interrupted. In that case simply retry.
         if (bytes_written_now == -1 && errno == EINTR) {
           continue;
@@ -725,12 +725,12 @@ Serial::SerialImpl::getPort () const
 }
 
 void
-Serial::SerialImpl::setTimeout (serial::Timeout &timeout)
+Serial::SerialImpl::setTimeout (serial_cpp::Timeout &timeout)
 {
   timeout_ = timeout;
 }
 
-serial::Timeout
+serial_cpp::Timeout
 Serial::SerialImpl::getTimeout () const
 {
   return timeout_;
@@ -751,56 +751,56 @@ Serial::SerialImpl::getBaudrate () const
 }
 
 void
-Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize)
+Serial::SerialImpl::setBytesize (serial_cpp::bytesize_t bytesize)
 {
   bytesize_ = bytesize;
   if (is_open_)
     reconfigurePort ();
 }
 
-serial::bytesize_t
+serial_cpp::bytesize_t
 Serial::SerialImpl::getBytesize () const
 {
   return bytesize_;
 }
 
 void
-Serial::SerialImpl::setParity (serial::parity_t parity)
+Serial::SerialImpl::setParity (serial_cpp::parity_t parity)
 {
   parity_ = parity;
   if (is_open_)
     reconfigurePort ();
 }
 
-serial::parity_t
+serial_cpp::parity_t
 Serial::SerialImpl::getParity () const
 {
   return parity_;
 }
 
 void
-Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits)
+Serial::SerialImpl::setStopbits (serial_cpp::stopbits_t stopbits)
 {
   stopbits_ = stopbits;
   if (is_open_)
     reconfigurePort ();
 }
 
-serial::stopbits_t
+serial_cpp::stopbits_t
 Serial::SerialImpl::getStopbits () const
 {
   return stopbits_;
 }
 
 void
-Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol)
+Serial::SerialImpl::setFlowcontrol (serial_cpp::flowcontrol_t flowcontrol)
 {
   flowcontrol_ = flowcontrol;
   if (is_open_)
     reconfigurePort ();
 }
 
-serial::flowcontrol_t
+serial_cpp::flowcontrol_t
 Serial::SerialImpl::getFlowcontrol () const
 {
   return flowcontrol_;
diff --git a/src/impl/win.cc b/src/impl/win.cc
index 889e06f..79fd4de 100644
--- a/src/impl/win.cc
+++ b/src/impl/win.cc
@@ -4,21 +4,21 @@
 
 #include 
 
-#include "serial/impl/win.h"
+#include "serial_cpp/impl/win.h"
 
 using std::string;
 using std::wstring;
 using std::stringstream;
 using std::invalid_argument;
-using serial::Serial;
-using serial::Timeout;
-using serial::bytesize_t;
-using serial::parity_t;
-using serial::stopbits_t;
-using serial::flowcontrol_t;
-using serial::SerialException;
-using serial::PortNotOpenedException;
-using serial::IOException;
+using serial_cpp::Serial;
+using serial_cpp::Timeout;
+using serial_cpp::bytesize_t;
+using serial_cpp::parity_t;
+using serial_cpp::stopbits_t;
+using serial_cpp::flowcontrol_t;
+using serial_cpp::SerialException;
+using serial_cpp::PortNotOpenedException;
+using serial_cpp::IOException;
 
 inline wstring
 _prefix_port_if_needed(const wstring &input)
@@ -370,7 +370,7 @@ Serial::SerialImpl::getPort () const
 }
 
 void
-Serial::SerialImpl::setTimeout (serial::Timeout &timeout)
+Serial::SerialImpl::setTimeout (serial_cpp::Timeout &timeout)
 {
   timeout_ = timeout;
   if (is_open_) {
@@ -378,7 +378,7 @@ Serial::SerialImpl::setTimeout (serial::Timeout &timeout)
   }
 }
 
-serial::Timeout
+serial_cpp::Timeout
 Serial::SerialImpl::getTimeout () const
 {
   return timeout_;
@@ -400,7 +400,7 @@ Serial::SerialImpl::getBaudrate () const
 }
 
 void
-Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize)
+Serial::SerialImpl::setBytesize (serial_cpp::bytesize_t bytesize)
 {
   bytesize_ = bytesize;
   if (is_open_) {
@@ -408,14 +408,14 @@ Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize)
   }
 }
 
-serial::bytesize_t
+serial_cpp::bytesize_t
 Serial::SerialImpl::getBytesize () const
 {
   return bytesize_;
 }
 
 void
-Serial::SerialImpl::setParity (serial::parity_t parity)
+Serial::SerialImpl::setParity (serial_cpp::parity_t parity)
 {
   parity_ = parity;
   if (is_open_) {
@@ -423,14 +423,14 @@ Serial::SerialImpl::setParity (serial::parity_t parity)
   }
 }
 
-serial::parity_t
+serial_cpp::parity_t
 Serial::SerialImpl::getParity () const
 {
   return parity_;
 }
 
 void
-Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits)
+Serial::SerialImpl::setStopbits (serial_cpp::stopbits_t stopbits)
 {
   stopbits_ = stopbits;
   if (is_open_) {
@@ -438,14 +438,14 @@ Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits)
   }
 }
 
-serial::stopbits_t
+serial_cpp::stopbits_t
 Serial::SerialImpl::getStopbits () const
 {
   return stopbits_;
 }
 
 void
-Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol)
+Serial::SerialImpl::setFlowcontrol (serial_cpp::flowcontrol_t flowcontrol)
 {
   flowcontrol_ = flowcontrol;
   if (is_open_) {
@@ -453,7 +453,7 @@ Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol)
   }
 }
 
-serial::flowcontrol_t
+serial_cpp::flowcontrol_t
 Serial::SerialImpl::getFlowcontrol () const
 {
   return flowcontrol_;
diff --git a/src/serial.cc b/src/serial.cc
index a9e6f84..9226899 100755
--- a/src/serial.cc
+++ b/src/serial.cc
@@ -9,12 +9,12 @@
 # define alloca __builtin_alloca
 #endif
 
-#include "serial/serial.h"
+#include "serial_cpp/serial.h"
 
 #ifdef _WIN32
-#include "serial/impl/win.h"
+#include "serial_cpp/impl/win.h"
 #else
-#include "serial/impl/unix.h"
+#include "serial_cpp/impl/unix.h"
 #endif
 
 using std::invalid_argument;
@@ -24,13 +24,13 @@ using std::vector;
 using std::size_t;
 using std::string;
 
-using serial::Serial;
-using serial::SerialException;
-using serial::IOException;
-using serial::bytesize_t;
-using serial::parity_t;
-using serial::stopbits_t;
-using serial::flowcontrol_t;
+using serial_cpp::Serial;
+using serial_cpp::SerialException;
+using serial_cpp::IOException;
+using serial_cpp::bytesize_t;
+using serial_cpp::parity_t;
+using serial_cpp::stopbits_t;
+using serial_cpp::flowcontrol_t;
 
 class Serial::ScopedReadLock {
 public:
@@ -63,7 +63,7 @@ class Serial::ScopedWriteLock {
   SerialImpl *pimpl_;
 };
 
-Serial::Serial (const string &port, uint32_t baudrate, serial::Timeout timeout,
+Serial::Serial (const string &port, uint32_t baudrate, serial_cpp::Timeout timeout,
                 bytesize_t bytesize, parity_t parity, stopbits_t stopbits,
                 flowcontrol_t flowcontrol)
  : pimpl_(new SerialImpl (port, baudrate, bytesize, parity,
@@ -104,7 +104,7 @@ Serial::available ()
 bool
 Serial::waitReadable ()
 {
-  serial::Timeout timeout(pimpl_->getTimeout ());
+  serial_cpp::Timeout timeout(pimpl_->getTimeout ());
   return pimpl_->waitReadable(timeout.read_timeout_constant);
 }
 
@@ -297,12 +297,12 @@ Serial::getPort () const
 }
 
 void
-Serial::setTimeout (serial::Timeout &timeout)
+Serial::setTimeout (serial_cpp::Timeout &timeout)
 {
   pimpl_->setTimeout (timeout);
 }
 
-serial::Timeout
+serial_cpp::Timeout
 Serial::getTimeout () const {
   return pimpl_->getTimeout ();
 }
diff --git a/tests/unit/unix_timer_tests.cc b/tests/unit/unix_timer_tests.cc
index 5bbd1ed..69c693c 100644
--- a/tests/unit/unix_timer_tests.cc
+++ b/tests/unit/unix_timer_tests.cc
@@ -1,10 +1,10 @@
 #include "gtest/gtest.h"
-#include "serial/impl/unix.h"
+#include "serial_cpp/impl/unix.h"
 
 #include 
 #include 
 
-using serial::MillisecondTimer;
+using serial_cpp::MillisecondTimer;
 
 namespace {
 
diff --git a/tests/unix_serial_tests.cc b/tests/unix_serial_tests.cc
index c34868a..950b8a5 100644
--- a/tests/unix_serial_tests.cc
+++ b/tests/unix_serial_tests.cc
@@ -25,7 +25,7 @@ void loop()
 // #define private public
 // #define protected public
 
-#include "serial/serial.h"
+#include "serial_cpp/serial.h"
 
 #if defined(__linux__)
 #include 
@@ -33,7 +33,7 @@ void loop()
 #include 
 #endif
 
-using namespace serial;
+using namespace serial_cpp;
 
 using std::string;