Chris@16: // Chris@16: // serial_port_base.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_SERIAL_PORT_BASE_HPP Chris@16: #define BOOST_ASIO_SERIAL_PORT_BASE_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_ASIO_HAS_SERIAL_PORT) \ Chris@16: || defined(GENERATING_DOCUMENTATION) Chris@16: Chris@16: #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__) Chris@16: # include Chris@16: #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__) Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #if defined(GENERATING_DOCUMENTATION) Chris@16: # define BOOST_ASIO_OPTION_STORAGE implementation_defined Chris@16: #elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) Chris@16: # define BOOST_ASIO_OPTION_STORAGE DCB Chris@16: #else Chris@16: # define BOOST_ASIO_OPTION_STORAGE termios Chris@16: #endif Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: Chris@16: /// The serial_port_base class is used as a base for the basic_serial_port class Chris@16: /// template so that we have a common place to define the serial port options. Chris@16: class serial_port_base Chris@16: { Chris@16: public: Chris@16: /// Serial port option to permit changing the baud rate. Chris@16: /** Chris@16: * Implements changing the baud rate for a given serial port. Chris@16: */ Chris@16: class baud_rate Chris@16: { Chris@16: public: Chris@16: explicit baud_rate(unsigned int rate = 0); Chris@16: unsigned int value() const; Chris@16: BOOST_ASIO_DECL boost::system::error_code store( Chris@16: BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec) const; Chris@16: BOOST_ASIO_DECL boost::system::error_code load( Chris@16: const BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec); Chris@16: private: Chris@16: unsigned int value_; Chris@16: }; Chris@16: Chris@16: /// Serial port option to permit changing the flow control. Chris@16: /** Chris@16: * Implements changing the flow control for a given serial port. Chris@16: */ Chris@16: class flow_control Chris@16: { Chris@16: public: Chris@16: enum type { none, software, hardware }; Chris@16: BOOST_ASIO_DECL explicit flow_control(type t = none); Chris@16: type value() const; Chris@16: BOOST_ASIO_DECL boost::system::error_code store( Chris@16: BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec) const; Chris@16: BOOST_ASIO_DECL boost::system::error_code load( Chris@16: const BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec); Chris@16: private: Chris@16: type value_; Chris@16: }; Chris@16: Chris@16: /// Serial port option to permit changing the parity. Chris@16: /** Chris@16: * Implements changing the parity for a given serial port. Chris@16: */ Chris@16: class parity Chris@16: { Chris@16: public: Chris@16: enum type { none, odd, even }; Chris@16: BOOST_ASIO_DECL explicit parity(type t = none); Chris@16: type value() const; Chris@16: BOOST_ASIO_DECL boost::system::error_code store( Chris@16: BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec) const; Chris@16: BOOST_ASIO_DECL boost::system::error_code load( Chris@16: const BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec); Chris@16: private: Chris@16: type value_; Chris@16: }; Chris@16: Chris@16: /// Serial port option to permit changing the number of stop bits. Chris@16: /** Chris@16: * Implements changing the number of stop bits for a given serial port. Chris@16: */ Chris@16: class stop_bits Chris@16: { Chris@16: public: Chris@16: enum type { one, onepointfive, two }; Chris@16: BOOST_ASIO_DECL explicit stop_bits(type t = one); Chris@16: type value() const; Chris@16: BOOST_ASIO_DECL boost::system::error_code store( Chris@16: BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec) const; Chris@16: BOOST_ASIO_DECL boost::system::error_code load( Chris@16: const BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec); Chris@16: private: Chris@16: type value_; Chris@16: }; Chris@16: Chris@16: /// Serial port option to permit changing the character size. Chris@16: /** Chris@16: * Implements changing the character size for a given serial port. Chris@16: */ Chris@16: class character_size Chris@16: { Chris@16: public: Chris@16: BOOST_ASIO_DECL explicit character_size(unsigned int t = 8); Chris@16: unsigned int value() const; Chris@16: BOOST_ASIO_DECL boost::system::error_code store( Chris@16: BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec) const; Chris@16: BOOST_ASIO_DECL boost::system::error_code load( Chris@16: const BOOST_ASIO_OPTION_STORAGE& storage, Chris@16: boost::system::error_code& ec); Chris@16: private: Chris@16: unsigned int value_; Chris@16: }; Chris@16: Chris@16: protected: Chris@16: /// Protected destructor to prevent deletion through this type. Chris@16: ~serial_port_base() Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #undef BOOST_ASIO_OPTION_STORAGE Chris@16: Chris@16: #include Chris@16: #if defined(BOOST_ASIO_HEADER_ONLY) Chris@16: # include Chris@16: #endif // defined(BOOST_ASIO_HEADER_ONLY) Chris@16: Chris@16: #endif // defined(BOOST_ASIO_HAS_SERIAL_PORT) Chris@16: // || defined(GENERATING_DOCUMENTATION) Chris@16: Chris@16: #endif // BOOST_ASIO_SERIAL_PORT_BASE_HPP