File: serial_ports.qbk

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (45 lines) | stat: -rw-r--r-- 2,067 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[/
 / Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section:serial_ports Serial Ports]

Boost.Asio includes classes for creating and manipulating serial ports in a portable
manner. For example, a serial port may be opened using:

  serial_port port(my_io_context, name);

where name is something like `"COM1"` on Windows, and `"/dev/ttyS0"` on POSIX
platforms.

Once opened, the serial port may be used as a [link boost_asio.overview.core.streams
stream]. This means the objects can be used with any of the [link
boost_asio.reference.read read()], [link boost_asio.reference.async_read async_read()],
[link boost_asio.reference.write write()], [link boost_asio.reference.async_write
async_write()], [link boost_asio.reference.read_until read_until()] or [link
boost_asio.reference.async_read_until async_read_until()] free functions.

The serial port implementation also includes option classes for configuring the
port's baud rate, flow control type, parity, stop bits and character size.

[heading See Also]

[link boost_asio.reference.serial_port serial_port],
[link boost_asio.reference.serial_port_base serial_port_base],
[link boost_asio.reference.serial_port_base__baud_rate serial_port_base::baud_rate],
[link boost_asio.reference.serial_port_base__flow_control serial_port_base::flow_control],
[link boost_asio.reference.serial_port_base__parity serial_port_base::parity],
[link boost_asio.reference.serial_port_base__stop_bits serial_port_base::stop_bits],
[link boost_asio.reference.serial_port_base__character_size serial_port_base::character_size].

[heading Notes]

Serial ports are available on all POSIX platforms. For Windows, serial ports
are only available at compile time when the I/O completion port backend is used
(which is the default). A program may test for the macro
`BOOST_ASIO_HAS_SERIAL_PORT` to determine whether they are supported.

[endsect]