samples/subsys/console/getline/README.html · samples/subsys/console/getline/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Console · Line Input

console_getline()

Enter까지 받은 input line을 반환하되 end-of-line character는 제외합니다.

Official pathsamples/subsys/console/getline/README.html
Source filesamples/subsys/console/getline/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

ANSI C gets·fgets 비교, UART 요구 사항과 QEMU run·exit 절차를 설명합니다.

API

console_getline

Unit

Line

EOL

LF · CR excluded

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 64219F2FE9CF2E3C0D0324B52AFAF4864C81A2120240CBB96923F90DE4BC0589
.. zephyr:code-sample:: console_getline
   :name: console_getline()

   Use console_getline() to read an input line from the console.

Overview
********

This example shows how to use :c:func:`console_getline` function.
Similar to the well-known ANSI C gets() and fgets() functions,
:c:func:`console_getline` either returns the next available input
line or blocks waiting for one. Using this function, it should be fairly
easy to port existing ANSI C, POSIX, or Linux applications which process
console input line by line. The sample also allows to see details of how
a line is returned by the function.

If you are interested in character by character console input, see
:zephyr:code-sample:`console_getchar`.


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

UART console is required to run this sample.


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

The easiest way to run this sample is using QEMU:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/console/getline
   :host-os: unix
   :board: qemu_x86
   :goals: run
   :compact:

Now start pressing keys on a keyboard, followed by Enter. The input line
will be printed back, with a hex code of the last character, to show that
line does not include any special "end of line" characters (like LF, CR,
etc.)
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.

Part 3

한국어 전문 번역

개요

console_getline() function으로 console input line 하나를 읽는 example입니다.

ANSI C gets()와 fgets()처럼 다음 input line이 준비돼 있으면 반환하고, 없으면 line이 들어올 때까지 block합니다. Console input을 line 단위로 처리하는 ANSI C, POSIX 또는 Linux application을 port하기 쉽게 합니다.

Sample은 function이 line을 어떤 형태로 반환하는지도 보여 줍니다. Character 단위 input이 필요하면 console_getchar() sample을 사용합니다.

요구 사항

UART console이 필요합니다.

빌드 및 실행

가장 쉬운 실행 방법은 QEMU입니다. qemu_x86로 build한 뒤 run target을 실행합니다.

west build -b qemu_x86 samples/subsys/console/getline
west build -t run

Keyboard로 text를 입력하고 Enter를 누르면 input line과 마지막 character의 hex code를 되돌려 줍니다. 반환된 line에는 LF, CR 같은 특별한 end-of-line character가 포함되지 않음을 이 hex code로 확인할 수 있습니다. QEMU는 CTRL+A 뒤 x로 종료합니다.

Source

출처

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