/Src/Dependencies/Boost/boost/asio/basic_serial_port.hpp

http://hadesmem.googlecode.com/ · C++ Header · 693 lines · 225 code · 47 blank · 421 comment · 3 complexity · 2549024ca57ded88472dcda126bef4fc MD5 · raw file

  1. //
  2. // basic_serial_port.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
  7. //
  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)
  10. //
  11. #ifndef BOOST_ASIO_BASIC_SERIAL_PORT_HPP
  12. #define BOOST_ASIO_BASIC_SERIAL_PORT_HPP
  13. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  14. # pragma once
  15. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  16. #include <boost/asio/detail/config.hpp>
  17. #if defined(BOOST_ASIO_HAS_SERIAL_PORT) \
  18. || defined(GENERATING_DOCUMENTATION)
  19. #include <string>
  20. #include <boost/asio/basic_io_object.hpp>
  21. #include <boost/asio/detail/handler_type_requirements.hpp>
  22. #include <boost/asio/detail/throw_error.hpp>
  23. #include <boost/asio/error.hpp>
  24. #include <boost/asio/serial_port_base.hpp>
  25. #include <boost/asio/serial_port_service.hpp>
  26. #include <boost/asio/detail/push_options.hpp>
  27. namespace boost {
  28. namespace asio {
  29. /// Provides serial port functionality.
  30. /**
  31. * The basic_serial_port class template provides functionality that is common
  32. * to all serial ports.
  33. *
  34. * @par Thread Safety
  35. * @e Distinct @e objects: Safe.@n
  36. * @e Shared @e objects: Unsafe.
  37. */
  38. template <typename SerialPortService = serial_port_service>
  39. class basic_serial_port
  40. : public basic_io_object<SerialPortService>,
  41. public serial_port_base
  42. {
  43. public:
  44. /// (Deprecated: Use native_handle_type.) The native representation of a
  45. /// serial port.
  46. typedef typename SerialPortService::native_handle_type native_type;
  47. /// The native representation of a serial port.
  48. typedef typename SerialPortService::native_handle_type native_handle_type;
  49. /// A basic_serial_port is always the lowest layer.
  50. typedef basic_serial_port<SerialPortService> lowest_layer_type;
  51. /// Construct a basic_serial_port without opening it.
  52. /**
  53. * This constructor creates a serial port without opening it.
  54. *
  55. * @param io_service The io_service object that the serial port will use to
  56. * dispatch handlers for any asynchronous operations performed on the port.
  57. */
  58. explicit basic_serial_port(boost::asio::io_service& io_service)
  59. : basic_io_object<SerialPortService>(io_service)
  60. {
  61. }
  62. /// Construct and open a basic_serial_port.
  63. /**
  64. * This constructor creates and opens a serial port for the specified device
  65. * name.
  66. *
  67. * @param io_service The io_service object that the serial port will use to
  68. * dispatch handlers for any asynchronous operations performed on the port.
  69. *
  70. * @param device The platform-specific device name for this serial
  71. * port.
  72. */
  73. explicit basic_serial_port(boost::asio::io_service& io_service,
  74. const char* device)
  75. : basic_io_object<SerialPortService>(io_service)
  76. {
  77. boost::system::error_code ec;
  78. this->get_service().open(this->get_implementation(), device, ec);
  79. boost::asio::detail::throw_error(ec, "open");
  80. }
  81. /// Construct and open a basic_serial_port.
  82. /**
  83. * This constructor creates and opens a serial port for the specified device
  84. * name.
  85. *
  86. * @param io_service The io_service object that the serial port will use to
  87. * dispatch handlers for any asynchronous operations performed on the port.
  88. *
  89. * @param device The platform-specific device name for this serial
  90. * port.
  91. */
  92. explicit basic_serial_port(boost::asio::io_service& io_service,
  93. const std::string& device)
  94. : basic_io_object<SerialPortService>(io_service)
  95. {
  96. boost::system::error_code ec;
  97. this->get_service().open(this->get_implementation(), device, ec);
  98. boost::asio::detail::throw_error(ec, "open");
  99. }
  100. /// Construct a basic_serial_port on an existing native serial port.
  101. /**
  102. * This constructor creates a serial port object to hold an existing native
  103. * serial port.
  104. *
  105. * @param io_service The io_service object that the serial port will use to
  106. * dispatch handlers for any asynchronous operations performed on the port.
  107. *
  108. * @param native_serial_port A native serial port.
  109. *
  110. * @throws boost::system::system_error Thrown on failure.
  111. */
  112. basic_serial_port(boost::asio::io_service& io_service,
  113. const native_handle_type& native_serial_port)
  114. : basic_io_object<SerialPortService>(io_service)
  115. {
  116. boost::system::error_code ec;
  117. this->get_service().assign(this->get_implementation(),
  118. native_serial_port, ec);
  119. boost::asio::detail::throw_error(ec, "assign");
  120. }
  121. #if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  122. /// Move-construct a basic_serial_port from another.
  123. /**
  124. * This constructor moves a serial port from one object to another.
  125. *
  126. * @param other The other basic_serial_port object from which the move will
  127. * occur.
  128. *
  129. * @note Following the move, the moved-from object is in the same state as if
  130. * constructed using the @c basic_serial_port(io_service&) constructor.
  131. */
  132. basic_serial_port(basic_serial_port&& other)
  133. : basic_io_object<SerialPortService>(
  134. BOOST_ASIO_MOVE_CAST(basic_serial_port)(other))
  135. {
  136. }
  137. /// Move-assign a basic_serial_port from another.
  138. /**
  139. * This assignment operator moves a serial port from one object to another.
  140. *
  141. * @param other The other basic_serial_port object from which the move will
  142. * occur.
  143. *
  144. * @note Following the move, the moved-from object is in the same state as if
  145. * constructed using the @c basic_serial_port(io_service&) constructor.
  146. */
  147. basic_serial_port& operator=(basic_serial_port&& other)
  148. {
  149. basic_io_object<SerialPortService>::operator=(
  150. BOOST_ASIO_MOVE_CAST(basic_serial_port)(other));
  151. return *this;
  152. }
  153. #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  154. /// Get a reference to the lowest layer.
  155. /**
  156. * This function returns a reference to the lowest layer in a stack of
  157. * layers. Since a basic_serial_port cannot contain any further layers, it
  158. * simply returns a reference to itself.
  159. *
  160. * @return A reference to the lowest layer in the stack of layers. Ownership
  161. * is not transferred to the caller.
  162. */
  163. lowest_layer_type& lowest_layer()
  164. {
  165. return *this;
  166. }
  167. /// Get a const reference to the lowest layer.
  168. /**
  169. * This function returns a const reference to the lowest layer in a stack of
  170. * layers. Since a basic_serial_port cannot contain any further layers, it
  171. * simply returns a reference to itself.
  172. *
  173. * @return A const reference to the lowest layer in the stack of layers.
  174. * Ownership is not transferred to the caller.
  175. */
  176. const lowest_layer_type& lowest_layer() const
  177. {
  178. return *this;
  179. }
  180. /// Open the serial port using the specified device name.
  181. /**
  182. * This function opens the serial port for the specified device name.
  183. *
  184. * @param device The platform-specific device name.
  185. *
  186. * @throws boost::system::system_error Thrown on failure.
  187. */
  188. void open(const std::string& device)
  189. {
  190. boost::system::error_code ec;
  191. this->get_service().open(this->get_implementation(), device, ec);
  192. boost::asio::detail::throw_error(ec, "open");
  193. }
  194. /// Open the serial port using the specified device name.
  195. /**
  196. * This function opens the serial port using the given platform-specific
  197. * device name.
  198. *
  199. * @param device The platform-specific device name.
  200. *
  201. * @param ec Set the indicate what error occurred, if any.
  202. */
  203. boost::system::error_code open(const std::string& device,
  204. boost::system::error_code& ec)
  205. {
  206. return this->get_service().open(this->get_implementation(), device, ec);
  207. }
  208. /// Assign an existing native serial port to the serial port.
  209. /*
  210. * This function opens the serial port to hold an existing native serial port.
  211. *
  212. * @param native_serial_port A native serial port.
  213. *
  214. * @throws boost::system::system_error Thrown on failure.
  215. */
  216. void assign(const native_handle_type& native_serial_port)
  217. {
  218. boost::system::error_code ec;
  219. this->get_service().assign(this->get_implementation(),
  220. native_serial_port, ec);
  221. boost::asio::detail::throw_error(ec, "assign");
  222. }
  223. /// Assign an existing native serial port to the serial port.
  224. /*
  225. * This function opens the serial port to hold an existing native serial port.
  226. *
  227. * @param native_serial_port A native serial port.
  228. *
  229. * @param ec Set to indicate what error occurred, if any.
  230. */
  231. boost::system::error_code assign(const native_handle_type& native_serial_port,
  232. boost::system::error_code& ec)
  233. {
  234. return this->get_service().assign(this->get_implementation(),
  235. native_serial_port, ec);
  236. }
  237. /// Determine whether the serial port is open.
  238. bool is_open() const
  239. {
  240. return this->get_service().is_open(this->get_implementation());
  241. }
  242. /// Close the serial port.
  243. /**
  244. * This function is used to close the serial port. Any asynchronous read or
  245. * write operations will be cancelled immediately, and will complete with the
  246. * boost::asio::error::operation_aborted error.
  247. *
  248. * @throws boost::system::system_error Thrown on failure.
  249. */
  250. void close()
  251. {
  252. boost::system::error_code ec;
  253. this->get_service().close(this->get_implementation(), ec);
  254. boost::asio::detail::throw_error(ec, "close");
  255. }
  256. /// Close the serial port.
  257. /**
  258. * This function is used to close the serial port. Any asynchronous read or
  259. * write operations will be cancelled immediately, and will complete with the
  260. * boost::asio::error::operation_aborted error.
  261. *
  262. * @param ec Set to indicate what error occurred, if any.
  263. */
  264. boost::system::error_code close(boost::system::error_code& ec)
  265. {
  266. return this->get_service().close(this->get_implementation(), ec);
  267. }
  268. /// (Deprecated: Use native_handle().) Get the native serial port
  269. /// representation.
  270. /**
  271. * This function may be used to obtain the underlying representation of the
  272. * serial port. This is intended to allow access to native serial port
  273. * functionality that is not otherwise provided.
  274. */
  275. native_type native()
  276. {
  277. return this->get_service().native_handle(this->get_implementation());
  278. }
  279. /// Get the native serial port representation.
  280. /**
  281. * This function may be used to obtain the underlying representation of the
  282. * serial port. This is intended to allow access to native serial port
  283. * functionality that is not otherwise provided.
  284. */
  285. native_handle_type native_handle()
  286. {
  287. return this->get_service().native_handle(this->get_implementation());
  288. }
  289. /// Cancel all asynchronous operations associated with the serial port.
  290. /**
  291. * This function causes all outstanding asynchronous read or write operations
  292. * to finish immediately, and the handlers for cancelled operations will be
  293. * passed the boost::asio::error::operation_aborted error.
  294. *
  295. * @throws boost::system::system_error Thrown on failure.
  296. */
  297. void cancel()
  298. {
  299. boost::system::error_code ec;
  300. this->get_service().cancel(this->get_implementation(), ec);
  301. boost::asio::detail::throw_error(ec, "cancel");
  302. }
  303. /// Cancel all asynchronous operations associated with the serial port.
  304. /**
  305. * This function causes all outstanding asynchronous read or write operations
  306. * to finish immediately, and the handlers for cancelled operations will be
  307. * passed the boost::asio::error::operation_aborted error.
  308. *
  309. * @param ec Set to indicate what error occurred, if any.
  310. */
  311. boost::system::error_code cancel(boost::system::error_code& ec)
  312. {
  313. return this->get_service().cancel(this->get_implementation(), ec);
  314. }
  315. /// Send a break sequence to the serial port.
  316. /**
  317. * This function causes a break sequence of platform-specific duration to be
  318. * sent out the serial port.
  319. *
  320. * @throws boost::system::system_error Thrown on failure.
  321. */
  322. void send_break()
  323. {
  324. boost::system::error_code ec;
  325. this->get_service().send_break(this->get_implementation(), ec);
  326. boost::asio::detail::throw_error(ec, "send_break");
  327. }
  328. /// Send a break sequence to the serial port.
  329. /**
  330. * This function causes a break sequence of platform-specific duration to be
  331. * sent out the serial port.
  332. *
  333. * @param ec Set to indicate what error occurred, if any.
  334. */
  335. boost::system::error_code send_break(boost::system::error_code& ec)
  336. {
  337. return this->get_service().send_break(this->get_implementation(), ec);
  338. }
  339. /// Set an option on the serial port.
  340. /**
  341. * This function is used to set an option on the serial port.
  342. *
  343. * @param option The option value to be set on the serial port.
  344. *
  345. * @throws boost::system::system_error Thrown on failure.
  346. *
  347. * @sa SettableSerialPortOption @n
  348. * boost::asio::serial_port_base::baud_rate @n
  349. * boost::asio::serial_port_base::flow_control @n
  350. * boost::asio::serial_port_base::parity @n
  351. * boost::asio::serial_port_base::stop_bits @n
  352. * boost::asio::serial_port_base::character_size
  353. */
  354. template <typename SettableSerialPortOption>
  355. void set_option(const SettableSerialPortOption& option)
  356. {
  357. boost::system::error_code ec;
  358. this->get_service().set_option(this->get_implementation(), option, ec);
  359. boost::asio::detail::throw_error(ec, "set_option");
  360. }
  361. /// Set an option on the serial port.
  362. /**
  363. * This function is used to set an option on the serial port.
  364. *
  365. * @param option The option value to be set on the serial port.
  366. *
  367. * @param ec Set to indicate what error occurred, if any.
  368. *
  369. * @sa SettableSerialPortOption @n
  370. * boost::asio::serial_port_base::baud_rate @n
  371. * boost::asio::serial_port_base::flow_control @n
  372. * boost::asio::serial_port_base::parity @n
  373. * boost::asio::serial_port_base::stop_bits @n
  374. * boost::asio::serial_port_base::character_size
  375. */
  376. template <typename SettableSerialPortOption>
  377. boost::system::error_code set_option(const SettableSerialPortOption& option,
  378. boost::system::error_code& ec)
  379. {
  380. return this->get_service().set_option(
  381. this->get_implementation(), option, ec);
  382. }
  383. /// Get an option from the serial port.
  384. /**
  385. * This function is used to get the current value of an option on the serial
  386. * port.
  387. *
  388. * @param option The option value to be obtained from the serial port.
  389. *
  390. * @throws boost::system::system_error Thrown on failure.
  391. *
  392. * @sa GettableSerialPortOption @n
  393. * boost::asio::serial_port_base::baud_rate @n
  394. * boost::asio::serial_port_base::flow_control @n
  395. * boost::asio::serial_port_base::parity @n
  396. * boost::asio::serial_port_base::stop_bits @n
  397. * boost::asio::serial_port_base::character_size
  398. */
  399. template <typename GettableSerialPortOption>
  400. void get_option(GettableSerialPortOption& option)
  401. {
  402. boost::system::error_code ec;
  403. this->get_service().get_option(this->get_implementation(), option, ec);
  404. boost::asio::detail::throw_error(ec, "get_option");
  405. }
  406. /// Get an option from the serial port.
  407. /**
  408. * This function is used to get the current value of an option on the serial
  409. * port.
  410. *
  411. * @param option The option value to be obtained from the serial port.
  412. *
  413. * @param ec Set to indicate what error occured, if any.
  414. *
  415. * @sa GettableSerialPortOption @n
  416. * boost::asio::serial_port_base::baud_rate @n
  417. * boost::asio::serial_port_base::flow_control @n
  418. * boost::asio::serial_port_base::parity @n
  419. * boost::asio::serial_port_base::stop_bits @n
  420. * boost::asio::serial_port_base::character_size
  421. */
  422. template <typename GettableSerialPortOption>
  423. boost::system::error_code get_option(GettableSerialPortOption& option,
  424. boost::system::error_code& ec)
  425. {
  426. return this->get_service().get_option(
  427. this->get_implementation(), option, ec);
  428. }
  429. /// Write some data to the serial port.
  430. /**
  431. * This function is used to write data to the serial port. The function call
  432. * will block until one or more bytes of the data has been written
  433. * successfully, or until an error occurs.
  434. *
  435. * @param buffers One or more data buffers to be written to the serial port.
  436. *
  437. * @returns The number of bytes written.
  438. *
  439. * @throws boost::system::system_error Thrown on failure. An error code of
  440. * boost::asio::error::eof indicates that the connection was closed by the
  441. * peer.
  442. *
  443. * @note The write_some operation may not transmit all of the data to the
  444. * peer. Consider using the @ref write function if you need to ensure that
  445. * all data is written before the blocking operation completes.
  446. *
  447. * @par Example
  448. * To write a single data buffer use the @ref buffer function as follows:
  449. * @code
  450. * serial_port.write_some(boost::asio::buffer(data, size));
  451. * @endcode
  452. * See the @ref buffer documentation for information on writing multiple
  453. * buffers in one go, and how to use it with arrays, boost::array or
  454. * std::vector.
  455. */
  456. template <typename ConstBufferSequence>
  457. std::size_t write_some(const ConstBufferSequence& buffers)
  458. {
  459. boost::system::error_code ec;
  460. std::size_t s = this->get_service().write_some(
  461. this->get_implementation(), buffers, ec);
  462. boost::asio::detail::throw_error(ec, "write_some");
  463. return s;
  464. }
  465. /// Write some data to the serial port.
  466. /**
  467. * This function is used to write data to the serial port. The function call
  468. * will block until one or more bytes of the data has been written
  469. * successfully, or until an error occurs.
  470. *
  471. * @param buffers One or more data buffers to be written to the serial port.
  472. *
  473. * @param ec Set to indicate what error occurred, if any.
  474. *
  475. * @returns The number of bytes written. Returns 0 if an error occurred.
  476. *
  477. * @note The write_some operation may not transmit all of the data to the
  478. * peer. Consider using the @ref write function if you need to ensure that
  479. * all data is written before the blocking operation completes.
  480. */
  481. template <typename ConstBufferSequence>
  482. std::size_t write_some(const ConstBufferSequence& buffers,
  483. boost::system::error_code& ec)
  484. {
  485. return this->get_service().write_some(
  486. this->get_implementation(), buffers, ec);
  487. }
  488. /// Start an asynchronous write.
  489. /**
  490. * This function is used to asynchronously write data to the serial port.
  491. * The function call always returns immediately.
  492. *
  493. * @param buffers One or more data buffers to be written to the serial port.
  494. * Although the buffers object may be copied as necessary, ownership of the
  495. * underlying memory blocks is retained by the caller, which must guarantee
  496. * that they remain valid until the handler is called.
  497. *
  498. * @param handler The handler to be called when the write operation completes.
  499. * Copies will be made of the handler as required. The function signature of
  500. * the handler must be:
  501. * @code void handler(
  502. * const boost::system::error_code& error, // Result of operation.
  503. * std::size_t bytes_transferred // Number of bytes written.
  504. * ); @endcode
  505. * Regardless of whether the asynchronous operation completes immediately or
  506. * not, the handler will not be invoked from within this function. Invocation
  507. * of the handler will be performed in a manner equivalent to using
  508. * boost::asio::io_service::post().
  509. *
  510. * @note The write operation may not transmit all of the data to the peer.
  511. * Consider using the @ref async_write function if you need to ensure that all
  512. * data is written before the asynchronous operation completes.
  513. *
  514. * @par Example
  515. * To write a single data buffer use the @ref buffer function as follows:
  516. * @code
  517. * serial_port.async_write_some(boost::asio::buffer(data, size), handler);
  518. * @endcode
  519. * See the @ref buffer documentation for information on writing multiple
  520. * buffers in one go, and how to use it with arrays, boost::array or
  521. * std::vector.
  522. */
  523. template <typename ConstBufferSequence, typename WriteHandler>
  524. void async_write_some(const ConstBufferSequence& buffers,
  525. BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
  526. {
  527. // If you get an error on the following line it means that your handler does
  528. // not meet the documented type requirements for a WriteHandler.
  529. BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
  530. this->get_service().async_write_some(this->get_implementation(),
  531. buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
  532. }
  533. /// Read some data from the serial port.
  534. /**
  535. * This function is used to read data from the serial port. The function
  536. * call will block until one or more bytes of data has been read successfully,
  537. * or until an error occurs.
  538. *
  539. * @param buffers One or more buffers into which the data will be read.
  540. *
  541. * @returns The number of bytes read.
  542. *
  543. * @throws boost::system::system_error Thrown on failure. An error code of
  544. * boost::asio::error::eof indicates that the connection was closed by the
  545. * peer.
  546. *
  547. * @note The read_some operation may not read all of the requested number of
  548. * bytes. Consider using the @ref read function if you need to ensure that
  549. * the requested amount of data is read before the blocking operation
  550. * completes.
  551. *
  552. * @par Example
  553. * To read into a single data buffer use the @ref buffer function as follows:
  554. * @code
  555. * serial_port.read_some(boost::asio::buffer(data, size));
  556. * @endcode
  557. * See the @ref buffer documentation for information on reading into multiple
  558. * buffers in one go, and how to use it with arrays, boost::array or
  559. * std::vector.
  560. */
  561. template <typename MutableBufferSequence>
  562. std::size_t read_some(const MutableBufferSequence& buffers)
  563. {
  564. boost::system::error_code ec;
  565. std::size_t s = this->get_service().read_some(
  566. this->get_implementation(), buffers, ec);
  567. boost::asio::detail::throw_error(ec, "read_some");
  568. return s;
  569. }
  570. /// Read some data from the serial port.
  571. /**
  572. * This function is used to read data from the serial port. The function
  573. * call will block until one or more bytes of data has been read successfully,
  574. * or until an error occurs.
  575. *
  576. * @param buffers One or more buffers into which the data will be read.
  577. *
  578. * @param ec Set to indicate what error occurred, if any.
  579. *
  580. * @returns The number of bytes read. Returns 0 if an error occurred.
  581. *
  582. * @note The read_some operation may not read all of the requested number of
  583. * bytes. Consider using the @ref read function if you need to ensure that
  584. * the requested amount of data is read before the blocking operation
  585. * completes.
  586. */
  587. template <typename MutableBufferSequence>
  588. std::size_t read_some(const MutableBufferSequence& buffers,
  589. boost::system::error_code& ec)
  590. {
  591. return this->get_service().read_some(
  592. this->get_implementation(), buffers, ec);
  593. }
  594. /// Start an asynchronous read.
  595. /**
  596. * This function is used to asynchronously read data from the serial port.
  597. * The function call always returns immediately.
  598. *
  599. * @param buffers One or more buffers into which the data will be read.
  600. * Although the buffers object may be copied as necessary, ownership of the
  601. * underlying memory blocks is retained by the caller, which must guarantee
  602. * that they remain valid until the handler is called.
  603. *
  604. * @param handler The handler to be called when the read operation completes.
  605. * Copies will be made of the handler as required. The function signature of
  606. * the handler must be:
  607. * @code void handler(
  608. * const boost::system::error_code& error, // Result of operation.
  609. * std::size_t bytes_transferred // Number of bytes read.
  610. * ); @endcode
  611. * Regardless of whether the asynchronous operation completes immediately or
  612. * not, the handler will not be invoked from within this function. Invocation
  613. * of the handler will be performed in a manner equivalent to using
  614. * boost::asio::io_service::post().
  615. *
  616. * @note The read operation may not read all of the requested number of bytes.
  617. * Consider using the @ref async_read function if you need to ensure that the
  618. * requested amount of data is read before the asynchronous operation
  619. * completes.
  620. *
  621. * @par Example
  622. * To read into a single data buffer use the @ref buffer function as follows:
  623. * @code
  624. * serial_port.async_read_some(boost::asio::buffer(data, size), handler);
  625. * @endcode
  626. * See the @ref buffer documentation for information on reading into multiple
  627. * buffers in one go, and how to use it with arrays, boost::array or
  628. * std::vector.
  629. */
  630. template <typename MutableBufferSequence, typename ReadHandler>
  631. void async_read_some(const MutableBufferSequence& buffers,
  632. BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
  633. {
  634. // If you get an error on the following line it means that your handler does
  635. // not meet the documented type requirements for a ReadHandler.
  636. BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
  637. this->get_service().async_read_some(this->get_implementation(),
  638. buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
  639. }
  640. };
  641. } // namespace asio
  642. } // namespace boost
  643. #include <boost/asio/detail/pop_options.hpp>
  644. #endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
  645. // || defined(GENERATING_DOCUMENTATION)
  646. #endif // BOOST_ASIO_BASIC_SERIAL_PORT_HPP