1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Serial Ports</title> 5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../boost_asio.html" title="Boost.Asio"> 8<link rel="up" href="../overview.html" title="Overview"> 9<link rel="prev" href="timers.html" title="Timers"> 10<link rel="next" href="signals.html" title="Signal Handling"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 15<td align="center"><a href="../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="timers.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="signals.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_asio.overview.serial_ports"></a><a class="link" href="serial_ports.html" title="Serial Ports">Serial Ports</a> 28</h3></div></div></div> 29<p> 30 Boost.Asio includes classes for creating and manipulating serial ports in 31 a portable manner. For example, a serial port may be opened using: 32 </p> 33<pre class="programlisting">serial_port port(my_io_context, name); 34</pre> 35<p> 36 where name is something like <code class="computeroutput">"COM1"</code> on Windows, and 37 <code class="computeroutput">"/dev/ttyS0"</code> on POSIX platforms. 38 </p> 39<p> 40 Once opened, the serial port may be used as a <a class="link" href="core/streams.html" title="Streams, Short Reads and Short Writes">stream</a>. 41 This means the objects can be used with any of the <a class="link" href="../reference/read.html" title="read">read()</a>, 42 <a class="link" href="../reference/async_read.html" title="async_read">async_read()</a>, <a class="link" href="../reference/write.html" title="write">write()</a>, <a class="link" href="../reference/async_write.html" title="async_write">async_write()</a>, 43 <a class="link" href="../reference/read_until.html" title="read_until">read_until()</a> or <a class="link" href="../reference/async_read_until.html" title="async_read_until">async_read_until()</a> 44 free functions. 45 </p> 46<p> 47 The serial port implementation also includes option classes for configuring 48 the port's baud rate, flow control type, parity, stop bits and character 49 size. 50 </p> 51<h5> 52<a name="boost_asio.overview.serial_ports.h0"></a> 53 <span class="phrase"><a name="boost_asio.overview.serial_ports.see_also"></a></span><a class="link" href="serial_ports.html#boost_asio.overview.serial_ports.see_also">See 54 Also</a> 55 </h5> 56<p> 57 <a class="link" href="../reference/serial_port.html" title="serial_port">serial_port</a>, <a class="link" href="../reference/serial_port_base.html" title="serial_port_base">serial_port_base</a>, 58 <a class="link" href="../reference/serial_port_base__baud_rate.html" title="serial_port_base::baud_rate">serial_port_base::baud_rate</a>, 59 <a class="link" href="../reference/serial_port_base__flow_control.html" title="serial_port_base::flow_control">serial_port_base::flow_control</a>, 60 <a class="link" href="../reference/serial_port_base__parity.html" title="serial_port_base::parity">serial_port_base::parity</a>, 61 <a class="link" href="../reference/serial_port_base__stop_bits.html" title="serial_port_base::stop_bits">serial_port_base::stop_bits</a>, 62 <a class="link" href="../reference/serial_port_base__character_size.html" title="serial_port_base::character_size">serial_port_base::character_size</a>. 63 </p> 64<h5> 65<a name="boost_asio.overview.serial_ports.h1"></a> 66 <span class="phrase"><a name="boost_asio.overview.serial_ports.notes"></a></span><a class="link" href="serial_ports.html#boost_asio.overview.serial_ports.notes">Notes</a> 67 </h5> 68<p> 69 Serial ports are available on all POSIX platforms. For Windows, serial ports 70 are only available at compile time when the I/O completion port backend is 71 used (which is the default). A program may test for the macro <code class="computeroutput">BOOST_ASIO_HAS_SERIAL_PORT</code> 72 to determine whether they are supported. 73 </p> 74</div> 75<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 76<td align="left"></td> 77<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 78 Kohlhoff<p> 79 Distributed under the Boost Software License, Version 1.0. (See accompanying 80 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 81 </p> 82</div></td> 83</tr></table> 84<hr> 85<div class="spirit-nav"> 86<a accesskey="p" href="timers.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="signals.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 87</div> 88</body> 89</html> 90