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