Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:11

0001 //
0002 // serial_port_base.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
0007 //
0008 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 
0012 #ifndef BOOST_ASIO_SERIAL_PORT_BASE_HPP
0013 #define BOOST_ASIO_SERIAL_PORT_BASE_HPP
0014 
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016 # pragma once
0017 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0018 
0019 #include <boost/asio/detail/config.hpp>
0020 
0021 #if defined(BOOST_ASIO_HAS_SERIAL_PORT) \
0022   || defined(GENERATING_DOCUMENTATION)
0023 
0024 #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
0025 # include <termios.h>
0026 #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
0027 
0028 #include <boost/asio/detail/socket_types.hpp>
0029 #include <boost/system/error_code.hpp>
0030 
0031 #if defined(GENERATING_DOCUMENTATION)
0032 # define BOOST_ASIO_OPTION_STORAGE implementation_defined
0033 #elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
0034 # define BOOST_ASIO_OPTION_STORAGE DCB
0035 #else
0036 # define BOOST_ASIO_OPTION_STORAGE termios
0037 #endif
0038 
0039 #include <boost/asio/detail/push_options.hpp>
0040 
0041 namespace boost {
0042 namespace asio {
0043 
0044 /// The serial_port_base class is used as a base for the basic_serial_port class
0045 /// template so that we have a common place to define the serial port options.
0046 class serial_port_base
0047 {
0048 public:
0049   /// Serial port option to permit changing the baud rate.
0050   /**
0051    * Implements changing the baud rate for a given serial port.
0052    */
0053   class baud_rate
0054   {
0055   public:
0056     explicit baud_rate(unsigned int rate = 0);
0057     unsigned int value() const;
0058     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
0059         BOOST_ASIO_OPTION_STORAGE& storage,
0060         boost::system::error_code& ec) const;
0061     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
0062         const BOOST_ASIO_OPTION_STORAGE& storage,
0063         boost::system::error_code& ec);
0064   private:
0065     unsigned int value_;
0066   };
0067 
0068   /// Serial port option to permit changing the flow control.
0069   /**
0070    * Implements changing the flow control for a given serial port.
0071    */
0072   class flow_control
0073   {
0074   public:
0075     enum type { none, software, hardware };
0076     BOOST_ASIO_DECL explicit flow_control(type t = none);
0077     type value() const;
0078     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
0079         BOOST_ASIO_OPTION_STORAGE& storage,
0080         boost::system::error_code& ec) const;
0081     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
0082         const BOOST_ASIO_OPTION_STORAGE& storage,
0083         boost::system::error_code& ec);
0084   private:
0085     type value_;
0086   };
0087 
0088   /// Serial port option to permit changing the parity.
0089   /**
0090    * Implements changing the parity for a given serial port.
0091    */
0092   class parity
0093   {
0094   public:
0095     enum type { none, odd, even };
0096     BOOST_ASIO_DECL explicit parity(type t = none);
0097     type value() const;
0098     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
0099         BOOST_ASIO_OPTION_STORAGE& storage,
0100         boost::system::error_code& ec) const;
0101     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
0102         const BOOST_ASIO_OPTION_STORAGE& storage,
0103         boost::system::error_code& ec);
0104   private:
0105     type value_;
0106   };
0107 
0108   /// Serial port option to permit changing the number of stop bits.
0109   /**
0110    * Implements changing the number of stop bits for a given serial port.
0111    */
0112   class stop_bits
0113   {
0114   public:
0115     enum type { one, onepointfive, two };
0116     BOOST_ASIO_DECL explicit stop_bits(type t = one);
0117     type value() const;
0118     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
0119         BOOST_ASIO_OPTION_STORAGE& storage,
0120         boost::system::error_code& ec) const;
0121     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
0122         const BOOST_ASIO_OPTION_STORAGE& storage,
0123         boost::system::error_code& ec);
0124   private:
0125     type value_;
0126   };
0127 
0128   /// Serial port option to permit changing the character size.
0129   /**
0130    * Implements changing the character size for a given serial port.
0131    */
0132   class character_size
0133   {
0134   public:
0135     BOOST_ASIO_DECL explicit character_size(unsigned int t = 8);
0136     unsigned int value() const;
0137     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
0138         BOOST_ASIO_OPTION_STORAGE& storage,
0139         boost::system::error_code& ec) const;
0140     BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
0141         const BOOST_ASIO_OPTION_STORAGE& storage,
0142         boost::system::error_code& ec);
0143   private:
0144     unsigned int value_;
0145   };
0146 
0147 protected:
0148   /// Protected destructor to prevent deletion through this type.
0149   ~serial_port_base()
0150   {
0151   }
0152 };
0153 
0154 } // namespace asio
0155 } // namespace boost
0156 
0157 #include <boost/asio/detail/pop_options.hpp>
0158 
0159 #undef BOOST_ASIO_OPTION_STORAGE
0160 
0161 #include <boost/asio/impl/serial_port_base.hpp>
0162 #if defined(BOOST_ASIO_HEADER_ONLY)
0163 # include <boost/asio/impl/serial_port_base.ipp>
0164 #endif // defined(BOOST_ASIO_HEADER_ONLY)
0165 
0166 #endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
0167        //   || defined(GENERATING_DOCUMENTATION)
0168 
0169 #endif // BOOST_ASIO_SERIAL_PORT_BASE_HPP