1.. zephyr:code-sample:: uart-native-tty 2 :name: Native TTY UART 3 :relevant-api: uart_interface 4 5 Use native TTY driver to send and receive data between two UART-to-USB bridge dongles. 6 7Overview 8******** 9 10This sample demonstrates the usage of the Native TTY UART driver. It uses two 11UART to USB bridge dongles that are wired together, writing demo data to one 12dongle and reading it from the other." 13 14The source code for this sample application can be found at: 15:zephyr_file:`samples/drivers/uart/native_tty`. 16 17You can learn more about the Native TTY UART driver in the 18:ref:`TTY UART <native_tty_uart>` section of the native_sim board 19documentation. 20 21Requirements 22************ 23 24#. Two UART to USB bridge dongles. Each dongle must have its TX pin wired to the 25 other dongle's RX pin. The ground connection is not needed. Both dongles must 26 be plugged into the host machine. 27#. The DT overlay provided with the sample expects the dongles to appear as 28 ``/dev/ttyUSB0`` and ``/dev/ttyUSB1`` in the system. You can check what they 29 are in your system by running the command ``ls -l /dev/tty*``. If that is not 30 the case on your machine you can either change the ``serial-port`` properties 31 in the ``boards/native_sim.overlay`` file or using the command line options 32 ``-uart_port`` and ``-uart_port2``. 33 34Building and Running 35******************** 36 37This application can be built and executed on :ref:`native_sim <native_sim>` as follows: 38 39.. zephyr-app-commands:: 40 :zephyr-app: samples/drivers/uart/native_tty 41 :host-os: unix 42 :board: native_sim 43 :goals: run 44 :compact: 45 46Sample Output 47============= 48 49.. code-block:: console 50 51 uart_1 connected to pseudotty: /dev/pts/6 52 uart2 connected to the serial port: /dev/ttyUSB1 53 uart connected to the serial port: /dev/ttyUSB0 54 *** Booting Zephyr OS build v3.4.0-rc2-97-ge586d02c137d *** 55 Device uart sent: "Hello from device uart, num 9" 56 Device uart2 received: "Hello from device uart, num 9" 57 Device uart sent: "Hello from device uart, num 8" 58 Device uart2 received: "Hello from device uart, num 8" 59 Device uart sent: "Hello from device uart, num 7" 60 Device uart2 received: "Hello from device uart, num 7" 61 Device uart sent: "Hello from device uart, num 6" 62 Device uart2 received: "Hello from device uart, num 6" 63 Device uart sent: "Hello from device uart, num 5" 64 Device uart2 received: "Hello from device uart, num 5" 65 Device uart sent: "Hello from device uart, num 4" 66 Device uart2 received: "Hello from device uart, num 4" 67 Device uart sent: "Hello from device uart, num 3" 68 Device uart2 received: "Hello from device uart, num 3" 69 Device uart sent: "Hello from device uart, num 2" 70 Device uart2 received: "Hello from device uart, num 2" 71 Device uart sent: "Hello from device uart, num 1" 72 Device uart2 received: "Hello from device uart, num 1" 73 Device uart sent: "Hello from device uart, num 0" 74 Device uart2 received: "Hello from device uart, num 0" 75 76 Changing baudrate of both uart devices to 9600! 77 78 Device uart sent: "Hello from device uart, num 9" 79 Device uart2 received: "Hello from device uart, num 9" 80 Device uart sent: "Hello from device uart, num 8" 81 Device uart2 received: "Hello from device uart, num 8" 82 Device uart sent: "Hello from device uart, num 7" 83 Device uart2 received: "Hello from device uart, num 7" 84 Device uart sent: "Hello from device uart, num 6" 85 Device uart2 received: "Hello from device uart, num 6" 86 Device uart sent: "Hello from device uart, num 5" 87 Device uart2 received: "Hello from device uart, num 5" 88 Device uart sent: "Hello from device uart, num 4" 89 Device uart2 received: "Hello from device uart, num 4" 90 Device uart sent: "Hello from device uart, num 3" 91 Device uart2 received: "Hello from device uart, num 3" 92 Device uart sent: "Hello from device uart, num 2" 93 Device uart2 received: "Hello from device uart, num 2" 94 Device uart sent: "Hello from device uart, num 1" 95 Device uart2 received: "Hello from device uart, num 1" 96 Device uart sent: "Hello from device uart, num 0" 97 Device uart2 received: "Hello from device uart, num 0" 98