aboutsummaryrefslogtreecommitdiff
path: root/pw_stream_uart_linux/docs.rst
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2024-03-06 09:29:56 -0800
committerXin Li <delphij@google.com>2024-03-06 09:29:56 -0800
commit646563934a3e2ee26f50171f94d95173a1662e2c (patch)
treec1643be8ab17fc607cea748a8bb1d621a5964873 /pw_stream_uart_linux/docs.rst
parentb1463ed3bc39c55c2a9496b8332940473fc3c023 (diff)
parent28d03a2a1cabbe01d7bcb6cf5166c10e50d3c2c6 (diff)
downloadpigweed-master.tar.gz
Merge Android 14 QPR2 to AOSP mainHEADmastermain
Bug: 319669529 Merged-In: Icdf552029fb97a34e83c6dd7799433fc473a2506 Change-Id: I193fcbb5c284df7b04c8b6f860a61ffb6f521d37
Diffstat (limited to 'pw_stream_uart_linux/docs.rst')
-rw-r--r--pw_stream_uart_linux/docs.rst37
1 files changed, 37 insertions, 0 deletions
diff --git a/pw_stream_uart_linux/docs.rst b/pw_stream_uart_linux/docs.rst
new file mode 100644
index 000000000..853da78d9
--- /dev/null
+++ b/pw_stream_uart_linux/docs.rst
@@ -0,0 +1,37 @@
+.. _module-pw_stream_uart_linux:
+
+====================
+pw_stream_uart_linux
+====================
+``pw_stream_uart_linux`` implements the
+:cpp:class:`pw::stream::NonSeekableReaderWriter` interface for reading from and
+writing to a UART using Linux TTY interfaces.
+
+.. note::
+ This module will likely be superseded by a future ``pw_uart`` interface.
+
+C++
+===
+.. doxygenclass:: pw::stream::UartStreamLinux
+ :members:
+
+Examples
+========
+A simple example illustrating writing to a UART:
+
+.. code-block:: cpp
+
+ constexpr const char* kUartPath = "/dev/ttyS0";
+ constexpr uint32_t kBaudRate = 115200;
+
+ pw::stream::UartStreamLinux stream;
+ PW_TRY(stream.Open(kUartPath, kBaudRate));
+
+ std::array<std::byte, 10> to_write = {};
+ PW_TRY(stream.Write(to_write));
+
+Caveats
+=======
+No interfaces are supplied for configuring data bits, stop bits, or parity.
+These attributes are left as they are already configured on the TTY; only the
+speed is modified.