2 // serial_port_base.hpp
3 // ~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 #ifndef BOOST_ASIO_SERIAL_PORT_BASE_HPP
13 #define BOOST_ASIO_SERIAL_PORT_BASE_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/asio/detail/config.hpp>
21 #if defined(BOOST_ASIO_HAS_SERIAL_PORT) \
22 || defined(GENERATING_DOCUMENTATION)
24 #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
26 #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
28 #include <boost/asio/detail/socket_types.hpp>
29 #include <boost/system/error_code.hpp>
31 #if defined(GENERATING_DOCUMENTATION)
32 # define BOOST_ASIO_OPTION_STORAGE implementation_defined
33 #elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
34 # define BOOST_ASIO_OPTION_STORAGE DCB
36 # define BOOST_ASIO_OPTION_STORAGE termios
39 #include <boost/asio/detail/push_options.hpp>
44 /// The serial_port_base class is used as a base for the basic_serial_port class
45 /// template so that we have a common place to define the serial port options.
46 class serial_port_base
49 /// Serial port option to permit changing the baud rate.
51 * Implements changing the baud rate for a given serial port.
56 explicit baud_rate(unsigned int rate = 0);
57 unsigned int value() const;
58 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
59 BOOST_ASIO_OPTION_STORAGE& storage,
60 boost::system::error_code& ec) const;
61 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
62 const BOOST_ASIO_OPTION_STORAGE& storage,
63 boost::system::error_code& ec);
68 /// Serial port option to permit changing the flow control.
70 * Implements changing the flow control for a given serial port.
75 enum type { none, software, hardware };
76 BOOST_ASIO_DECL explicit flow_control(type t = none);
78 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
79 BOOST_ASIO_OPTION_STORAGE& storage,
80 boost::system::error_code& ec) const;
81 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
82 const BOOST_ASIO_OPTION_STORAGE& storage,
83 boost::system::error_code& ec);
88 /// Serial port option to permit changing the parity.
90 * Implements changing the parity for a given serial port.
95 enum type { none, odd, even };
96 BOOST_ASIO_DECL explicit parity(type t = none);
98 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
99 BOOST_ASIO_OPTION_STORAGE& storage,
100 boost::system::error_code& ec) const;
101 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
102 const BOOST_ASIO_OPTION_STORAGE& storage,
103 boost::system::error_code& ec);
108 /// Serial port option to permit changing the number of stop bits.
110 * Implements changing the number of stop bits for a given serial port.
115 enum type { one, onepointfive, two };
116 BOOST_ASIO_DECL explicit stop_bits(type t = one);
118 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
119 BOOST_ASIO_OPTION_STORAGE& storage,
120 boost::system::error_code& ec) const;
121 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
122 const BOOST_ASIO_OPTION_STORAGE& storage,
123 boost::system::error_code& ec);
128 /// Serial port option to permit changing the character size.
130 * Implements changing the character size for a given serial port.
135 BOOST_ASIO_DECL explicit character_size(unsigned int t = 8);
136 unsigned int value() const;
137 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID store(
138 BOOST_ASIO_OPTION_STORAGE& storage,
139 boost::system::error_code& ec) const;
140 BOOST_ASIO_DECL BOOST_ASIO_SYNC_OP_VOID load(
141 const BOOST_ASIO_OPTION_STORAGE& storage,
142 boost::system::error_code& ec);
148 /// Protected destructor to prevent deletion through this type.
157 #include <boost/asio/detail/pop_options.hpp>
159 #undef BOOST_ASIO_OPTION_STORAGE
161 #include <boost/asio/impl/serial_port_base.hpp>
162 #if defined(BOOST_ASIO_HEADER_ONLY)
163 # include <boost/asio/impl/serial_port_base.ipp>
164 #endif // defined(BOOST_ASIO_HEADER_ONLY)
166 #endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
167 // || defined(GENERATING_DOCUMENTATION)
169 #endif // BOOST_ASIO_SERIAL_PORT_BASE_HPP