Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/boost/cobalt/io/serial_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ struct BOOST_SYMBOL_VISIBLE serial_port final : stream
[[nodiscard]] BOOST_COBALT_IO_DECL system::result<void> set_parity(parity rate);
[[nodiscard]] BOOST_COBALT_IO_DECL system::result<parity> get_parity();

using stop_bits = asio::serial_port_base::stop_bits::type;

[[nodiscard]] BOOST_COBALT_IO_DECL system::result<void> set_stop_bits(stop_bits stop_bits);
[[nodiscard]] BOOST_COBALT_IO_DECL system::result<stop_bits> get_stop_bits();

using native_handle_type = typename asio::basic_serial_port<executor>::native_handle_type;
native_handle_type native_handle() {return serial_port_.native_handle();}

Expand Down
15 changes: 15 additions & 0 deletions src/io/serial_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ auto serial_port::get_parity() -> system::result<parity>
return ec ? ec : system::result<parity>(br.value());
}

system::result<void> serial_port::set_stop_bits(stop_bits stop_bits)
{
system::error_code ec;
serial_port_.set_option(asio::serial_port_base::stop_bits(stop_bits), ec);
return ec ? ec : boost::system::result<void>();
}

auto serial_port::get_stop_bits() -> system::result<stop_bits>
{
system::error_code ec;
asio::serial_port_base::stop_bits sb;
serial_port_.get_option(sb, ec);
return ec ? ec : boost::system::result<stop_bits>(sb.value());
}

serial_port::serial_port(const cobalt::executor & executor)
: serial_port_(executor) {}
serial_port::serial_port(std::string_view device, const cobalt::executor & executor)
Expand Down