1.. _module-pw_stream_uart_linux: 2 3==================== 4pw_stream_uart_linux 5==================== 6``pw_stream_uart_linux`` implements the 7:cpp:class:`pw::stream::NonSeekableReaderWriter` interface for reading from and 8writing to a UART using Linux TTY interfaces. 9 10.. note:: 11 This module will likely be superseded by a future ``pw_uart`` interface. 12 13C++ 14=== 15.. doxygenclass:: pw::stream::UartStreamLinux 16 :members: 17 18Examples 19======== 20A simple example illustrating only changing baud-rate and writing to a UART: 21 22.. code-block:: cpp 23 24 constexpr const char* kUartPath = "/dev/ttyS0"; 25 constexpr pw::stream::UartStreamLinux::Config kConfig = { 26 .baud_rate = 115200, 27 // Flow control is unmodified on tty. 28 }; 29 pw::stream::UartStreamLinux stream; 30 PW_TRY(stream.Open(kUartPath, kConfig)); 31 32 std::array<std::byte, 10> to_write = {}; 33 PW_TRY(stream.Write(to_write)); 34 35 36A simple example illustrating enabling flow control and writing to a UART: 37 38.. code-block:: cpp 39 40 constexpr const char* kUartPath = "/dev/ttyS0"; 41 constexpr pw::stream::UartStreamLinux::Config kConfig = { 42 .baud_rate = 115200, 43 .flow_control = true, // Enable hardware flow control. 44 }; 45 pw::stream::UartStreamLinux stream; 46 PW_TRY(stream.Open(kUartPath, kConfig)); 47 48 std::array<std::byte, 10> to_write = {}; 49 PW_TRY(stream.Write(to_write)); 50 51Caveats 52======= 53No interfaces are supplied for configuring data bits, stop bits, or parity. 54These attributes are left as they are already configured on the TTY; only the 55speed or flow control is modified. 56