samples/drivers/uart/native_tty/README.html · samples/drivers/uart/native_tty/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Drivers · UART

Native TTY UART

교차 TX/RX 배선과 ttyUSB 경로, runtime baudrate 변경을 검증합니다.

Official pathsamples/drivers/uart/native_tty/README.html
Source filesamples/drivers/uart/native_tty/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Dongle 요구 사항, overlay·CLI 대안과 num 9~0 전체 출력을 보존합니다.

Dongles

2

Ports

ttyUSB0 · ttyUSB1

Baudrate

9600 전환

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 351F2413BD094AFFC25384C8795372EB172E346236FE0A352AAF5C3BF1374813
.. zephyr:code-sample:: uart-native-tty
   :name: Native TTY UART
   :relevant-api: uart_interface

   Use native TTY driver to send and receive data between two UART-to-USB bridge dongles.

Overview
********

This sample demonstrates the usage of the Native TTY UART driver. It uses two
UART to USB bridge dongles that are wired together, writing demo data to one
dongle and reading it from the other."

The source code for this sample application can be found at:
:zephyr_file:`samples/drivers/uart/native_tty`.

You can learn more about the Native TTY UART driver in the
:ref:`TTY UART <native_tty_uart>` section of the native_sim board
documentation.

Requirements
************

#. Two UART to USB bridge dongles. Each dongle must have its TX pin wired to the
   other dongle's RX pin. The ground connection is not needed. Both dongles must
   be plugged into the host machine.
#. The DT overlay provided with the sample expects the dongles to appear as
   ``/dev/ttyUSB0`` and ``/dev/ttyUSB1`` in the system. You can check what they
   are in your system by running the command ``ls -l /dev/tty*``. If that is not
   the case on your machine you can either change the ``serial-port`` properties
   in the ``boards/native_sim.overlay`` file or using the command line options
   ``-uart_port`` and ``-uart_port2``.

Building and Running
********************

This application can be built and executed on :ref:`native_sim <native_sim>` as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/drivers/uart/native_tty
   :host-os: unix
   :board: native_sim
   :goals: run
   :compact:

Sample Output
=============

.. code-block:: console

   uart_1 connected to pseudotty: /dev/pts/6
   uart2 connected to the serial port: /dev/ttyUSB1
   uart connected to the serial port: /dev/ttyUSB0
   *** Booting Zephyr OS build v3.4.0-rc2-97-ge586d02c137d ***
   Device uart sent: "Hello from device uart, num 9"
   Device uart2 received: "Hello from device uart, num 9"
   Device uart sent: "Hello from device uart, num 8"
   Device uart2 received: "Hello from device uart, num 8"
   Device uart sent: "Hello from device uart, num 7"
   Device uart2 received: "Hello from device uart, num 7"
   Device uart sent: "Hello from device uart, num 6"
   Device uart2 received: "Hello from device uart, num 6"
   Device uart sent: "Hello from device uart, num 5"
   Device uart2 received: "Hello from device uart, num 5"
   Device uart sent: "Hello from device uart, num 4"
   Device uart2 received: "Hello from device uart, num 4"
   Device uart sent: "Hello from device uart, num 3"
   Device uart2 received: "Hello from device uart, num 3"
   Device uart sent: "Hello from device uart, num 2"
   Device uart2 received: "Hello from device uart, num 2"
   Device uart sent: "Hello from device uart, num 1"
   Device uart2 received: "Hello from device uart, num 1"
   Device uart sent: "Hello from device uart, num 0"
   Device uart2 received: "Hello from device uart, num 0"

   Changing baudrate of both uart devices to 9600!

   Device uart sent: "Hello from device uart, num 9"
   Device uart2 received: "Hello from device uart, num 9"
   Device uart sent: "Hello from device uart, num 8"
   Device uart2 received: "Hello from device uart, num 8"
   Device uart sent: "Hello from device uart, num 7"
   Device uart2 received: "Hello from device uart, num 7"
   Device uart sent: "Hello from device uart, num 6"
   Device uart2 received: "Hello from device uart, num 6"
   Device uart sent: "Hello from device uart, num 5"
   Device uart2 received: "Hello from device uart, num 5"
   Device uart sent: "Hello from device uart, num 4"
   Device uart2 received: "Hello from device uart, num 4"
   Device uart sent: "Hello from device uart, num 3"
   Device uart2 received: "Hello from device uart, num 3"
   Device uart sent: "Hello from device uart, num 2"
   Device uart2 received: "Hello from device uart, num 2"
   Device uart sent: "Hello from device uart, num 1"
   Device uart2 received: "Hello from device uart, num 1"
   Device uart sent: "Hello from device uart, num 0"
   Device uart2 received: "Hello from device uart, num 0"

Part 3

한국어 전문 번역

개요

이 sample은 Native TTY UART driver의 사용법을 보여줍니다. 서로 배선한 UART-to-USB bridge dongle 두 개를 사용하여 한 dongle에 demo data를 쓰고 다른 dongle에서 읽습니다.

Sample application source code는 samples/drivers/uart/native_tty에 있습니다.

Native TTY UART driver에 관한 자세한 내용은 native_sim board 문서의 TTY UART 절에서 확인할 수 있습니다.

요구 사항

  1. UART-to-USB bridge dongle 두 개가 필요합니다. 각 dongle의 TX pin을 다른 dongle의 RX pin에 연결해야 합니다. Ground 연결은 필요하지 않으며 두 dongle을 모두 host machine에 꽂아야 합니다.
  2. Sample의 DT overlay는 dongle이 system에 /dev/ttyUSB0과 /dev/ttyUSB1로 나타난다고 가정합니다. ls -l /dev/tty*로 실제 이름을 확인하십시오. 다르면 boards/native_sim.overlay의 serial-port property를 바꾸거나 command line option -uart_port와 -uart_port2를 사용할 수 있습니다.

Build와 실행

다음과 같이 native_sim에서 application을 build하고 실행할 수 있습니다.

west build -b native_sim samples/drivers/uart/native_tty
west build -t run

Sample 출력

uart_1 connected to pseudotty: /dev/pts/6
uart2 connected to the serial port: /dev/ttyUSB1
uart connected to the serial port: /dev/ttyUSB0
*** Booting Zephyr OS build v3.4.0-rc2-97-ge586d02c137d ***
Device uart sent: "Hello from device uart, num 9"
Device uart2 received: "Hello from device uart, num 9"
Device uart sent: "Hello from device uart, num 8"
Device uart2 received: "Hello from device uart, num 8"
Device uart sent: "Hello from device uart, num 7"
Device uart2 received: "Hello from device uart, num 7"
Device uart sent: "Hello from device uart, num 6"
Device uart2 received: "Hello from device uart, num 6"
Device uart sent: "Hello from device uart, num 5"
Device uart2 received: "Hello from device uart, num 5"
Device uart sent: "Hello from device uart, num 4"
Device uart2 received: "Hello from device uart, num 4"
Device uart sent: "Hello from device uart, num 3"
Device uart2 received: "Hello from device uart, num 3"
Device uart sent: "Hello from device uart, num 2"
Device uart2 received: "Hello from device uart, num 2"
Device uart sent: "Hello from device uart, num 1"
Device uart2 received: "Hello from device uart, num 1"
Device uart sent: "Hello from device uart, num 0"
Device uart2 received: "Hello from device uart, num 0"

Changing baudrate of both uart devices to 9600!

Device uart sent: "Hello from device uart, num 9"
Device uart2 received: "Hello from device uart, num 9"
Device uart sent: "Hello from device uart, num 8"
Device uart2 received: "Hello from device uart, num 8"
Device uart sent: "Hello from device uart, num 7"
Device uart2 received: "Hello from device uart, num 7"
Device uart sent: "Hello from device uart, num 6"
Device uart2 received: "Hello from device uart, num 6"
Device uart sent: "Hello from device uart, num 5"
Device uart2 received: "Hello from device uart, num 5"
Device uart sent: "Hello from device uart, num 4"
Device uart2 received: "Hello from device uart, num 4"
Device uart sent: "Hello from device uart, num 3"
Device uart2 received: "Hello from device uart, num 3"
Device uart sent: "Hello from device uart, num 2"
Device uart2 received: "Hello from device uart, num 2"
Device uart sent: "Hello from device uart, num 1"
Device uart2 received: "Hello from device uart, num 1"
Device uart sent: "Hello from device uart, num 0"
Device uart2 received: "Hello from device uart, num 0"

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.