12 #ifndef ASIO_BASIC_SERIAL_PORT_HPP 13 #define ASIO_BASIC_SERIAL_PORT_HPP 15 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 21 #if defined(ASIO_HAS_SERIAL_PORT) \ 22 || defined(GENERATING_DOCUMENTATION) 45 template <
typename SerialPortService = serial_port_service>
46 class basic_serial_port
47 :
public basic_io_object<SerialPortService>,
48 public serial_port_base
53 typedef typename SerialPortService::native_handle_type native_type;
56 typedef typename SerialPortService::native_handle_type native_handle_type;
59 typedef basic_serial_port<SerialPortService> lowest_layer_type;
69 : basic_io_object<SerialPortService>(io_service)
86 : basic_io_object<SerialPortService>(io_service)
89 this->get_service().open(this->get_implementation(), device, ec);
105 const std::string& device)
106 : basic_io_object<SerialPortService>(io_service)
109 this->get_service().open(this->get_implementation(), device, ec);
126 const native_handle_type& native_serial_port)
127 : basic_io_object<SerialPortService>(io_service)
130 this->get_service().assign(this->get_implementation(),
131 native_serial_port, ec);
135 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 146 basic_serial_port(basic_serial_port&& other)
147 : basic_io_object<SerialPortService>(
162 basic_serial_port& operator=(basic_serial_port&& other)
164 basic_io_object<SerialPortService>::operator=(
168 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 179 lowest_layer_type& lowest_layer()
193 const lowest_layer_type& lowest_layer()
const 206 void open(
const std::string& device)
209 this->get_service().open(this->get_implementation(), device, ec);
225 return this->get_service().open(this->get_implementation(), device, ec);
236 void assign(
const native_handle_type& native_serial_port)
239 this->get_service().assign(this->get_implementation(),
240 native_serial_port, ec);
255 return this->get_service().assign(this->get_implementation(),
256 native_serial_port, ec);
262 return this->get_service().is_open(this->get_implementation());
276 this->get_service().close(this->get_implementation(), ec);
290 return this->get_service().close(this->get_implementation(), ec);
302 return this->get_service().native_handle(this->get_implementation());
311 native_handle_type native_handle()
313 return this->get_service().native_handle(this->get_implementation());
327 this->get_service().cancel(this->get_implementation(), ec);
341 return this->get_service().cancel(this->get_implementation(), ec);
354 this->get_service().send_break(this->get_implementation(), ec);
367 return this->get_service().send_break(this->get_implementation(), ec);
385 template <
typename SettableSerialPortOption>
386 void set_option(
const SettableSerialPortOption& option)
389 this->get_service().set_option(this->get_implementation(), option, ec);
408 template <
typename SettableSerialPortOption>
412 return this->get_service().set_option(
413 this->get_implementation(), option, ec);
432 template <
typename GettableSerialPortOption>
433 void get_option(GettableSerialPortOption& option)
436 this->get_service().get_option(this->get_implementation(), option, ec);
456 template <
typename GettableSerialPortOption>
460 return this->get_service().get_option(
461 this->get_implementation(), option, ec);
491 template <
typename ConstBufferSequence>
492 std::size_t write_some(
const ConstBufferSequence&
buffers)
495 std::size_t
s = this->get_service().write_some(
496 this->get_implementation(), buffers, ec);
517 template <
typename ConstBufferSequence>
518 std::size_t write_some(
const ConstBufferSequence& buffers,
521 return this->get_service().write_some(
522 this->get_implementation(), buffers, ec);
560 template <
typename ConstBufferSequence,
typename WriteHandler>
563 async_write_some(const ConstBufferSequence& buffers,
570 return this->get_service().async_write_some(this->get_implementation(),
602 template <typename MutableBufferSequence>
603 std::
size_t read_some(const MutableBufferSequence& buffers)
606 std::size_t s = this->get_service().read_some(
607 this->get_implementation(), buffers, ec);
629 template <
typename MutableBufferSequence>
630 std::size_t read_some(
const MutableBufferSequence& buffers,
633 return this->get_service().read_some(
634 this->get_implementation(), buffers, ec);
673 template <
typename MutableBufferSequence,
typename ReadHandler>
676 async_read_some(const MutableBufferSequence& buffers,
683 return this->get_service().async_read_some(this->get_implementation(),
690 #include "asio/detail/pop_options.hpp" 692 #endif // defined(ASIO_HAS_SERIAL_PORT) 695 #endif // ASIO_BASIC_SERIAL_PORT_HPP void throw_error(const asio::error_code &err)
Provides core I/O functionality.
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
const MutableBufferSequence & buffers
#define ASIO_READ_HANDLER_CHECK(handler_type, handler)
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Class to represent an error code value.
ASIO_DECL int close(int d, state_type &state, asio::error_code &ec)
#define ASIO_MOVE_CAST(type)
#define ASIO_WRITE_HANDLER_CHECK(handler_type, handler)
ASIO_DECL int open(const char *path, int flags, asio::error_code &ec)