“Serial TTY line discipline”的版本间的差异

来自百问网嵌入式Linux wiki
第11行: 第11行:
  
 
===Components description===
 
===Components description===
''From client application to hardware''
+
''从客户端应用程序到硬件''
* Application: customer application to read/write data from the peripheral connected on the serial port.
+
* 应用程序:客户应用程序,用于从串行端口上连接的外围设备读取/写入数据。
  
* [[TTY tools]]: tools provided by Linux community, such as '''stty''', '''ldattach''', '''inputattach''', '''tty''', '''ttys''', '''agetty''', '''mingetty''', '''kermit''' and '''minicom'''.
+
* [[TTY tools]]: Linux社区提供的工具,例 '''stty''', '''ldattach''', '''inputattach''', '''tty''', '''ttys''', '''agetty''', '''mingetty''', '''kermit''' and '''minicom'''.
{{ReviewsComments|FGA W1941: I can't find TTY tools in above figure. Is it relevant here?.}}
 
* Termios: API<ref name="termios API">[http://man7.org/linux/man-pages/man3/termios.3.html termios API], Linux Programmer's Manual termios API Documentation (user land API with serial devices)</ref> which offers an interface to develop an application using serial drivers.
 
*Client subsystem: kernel subsystem client of '''TTY''' core (Example:  a Bluetooth device)
 
{{ReviewsComments|FGA W1941: I can't find "Client subsystem" in above figure.}}
 
* TTY framework: high-level TTY structures management, including {{CodeSource | Linux kernel | drivers/tty/tty_io.c | '''tty character device driver'''}}, {{CodeSource | Linux kernel | drivers/tty | '''TTY core functions'''}}, [[Serial TTY line discipline| '''line discipline''']].
 
{{ReviewsComments|FGA W1941: "TTY framework" -> "TTY Core" in above figure ?}}
 
* Serial framework: low-level serial driver management, including the {{CodeSource | Linux kernel | drivers/tty/serial/serial_core.c | '''serial core''' functions}}.
 
{{ReviewsComments|FGA W1941: "Serial framework" -> "Serial Core" in above figure ?}}
 
* USART driver: {{CodeSource | Linux kernel | drivers/tty/serial/stm32-usart.c | stm32-usart}} '''low-level serial driver''' for all stm32 family devices.
 
  
* [[USART internal peripheral| STM32 USART]]: '''STM32 frontend IP''' connected to the external devices through a serial port
+
* Termios: API<ref name="termios API">[http://man7.org/linux/man-pages/man3/termios.3.html termios API], Linux Programmer's Manual termios API Documentation (user land API with serial devices)</ref> 提供使用串行驱动程序开发应用程序的接口。
{{ReviewsComments|FGA W1941: Maybe worth adding the external device in the above figure ?}}
+
*客户端子系统:'''TTY'''内核的内核子系统客户端(示例:蓝牙设备)
 +
 
 +
* TTY框架:高层TTY结构管理,包括 {{CodeSource | Linux kernel | drivers/tty/tty_io.c | '''tty character device driver'''}}, {{CodeSource | Linux kernel | drivers/tty | '''TTY core functions'''}}, [[Serial TTY line discipline| '''line discipline''']].
 +
 
 +
* 串行框架:低级串行驱动程序管理,包括{{CodeSource | Linux kernel | drivers/tty/serial/serial_core.c | '''serial core''' functions}}.
 +
 
 +
* USART驱动程序:{{CodeSource | Linux kernel | drivers/tty/serial/stm32-usart.c | stm32-usart}} '“低级串行驱动程序'”,用于所有stm32系列设备。
 +
* [[USART internal peripheral| STM32 USART]]: ''' STM32前端IP''' 通过串行端口连接到外部设备
  
 
===APIs description===
 
===APIs description===

2020年11月9日 (一) 10:49的版本

本文提供有关 Linux® TTY 框架的信息。 它说明了如何使用线路规则激活“ UART”接口,以及如何从用户和内核空间访问它。

Framework purpose

UART是几种设备类型(例如蓝牙,NFC,FM收音机和GPS设备)的通用接口。
从内核版本4.12开始,TTY框架中引入了串行设备总线(也称为Serdev),以改善提供给连接到串行端口的设备的接口。 请参考 Serial TTY overview文章,以详细了解TTY框架的用途。尽管如此,仍然有可能(即使不推荐)使用行规“驱动程序”。 本文重点介绍提供给连接到串行端口的设备的线路规范接口。

System overview

Serial TTY Line Discipline overview.png


Components description

从客户端应用程序到硬件

  • 应用程序:客户应用程序,用于从串行端口上连接的外围设备读取/写入数据。
  • TTY tools: Linux社区提供的工具,例 stty, ldattach, inputattach, tty, ttys, agetty, mingetty, kermit and minicom.
  • Termios: API[1] 提供使用串行驱动程序开发应用程序的接口。
  • 客户端子系统:TTY内核的内核子系统客户端(示例:蓝牙设备)

APIs description

The TTY provides only character device interface (named /dev/ttyX) to user space. The main API for user space TTY client applications is provided by the portable POSIX terminal interface termios, which relies on /dev/ttyX interface for TTY link configuration.

The termios API[1] is a user land API, and its functions describe a general terminal interface that is provided to control asynchronous communications ports.

The POSIX termios API abstracts the low-level details of the hardware, and provides a simple yet complete programming interface that can be used for advanced projects. It is a wrapper on character device API [2] ioctl operations.

Info.png A line discipline driver can be used when a serial interface is needed at kernel level.

For example, a kernel driver maybe needed to control an external device through an U(S)ART port. <securetransclude src="ProtectedTemplate:ReviewsComments" params="FGA W1941: I rephrased above note, can you please double-ckeck ?"></securetransclude>{{#set:Has reviews comments=true}}

  • The line discipline will be responsible for:
    • creating this new kernel API
    • routing data flow between serial core and new kernel API

<securetransclude src="ProtectedTemplate:ReviewsComments" params="FGA W1941: No how to use section, nor examples ? Is it deliberate ?<br/> FGA W1941: Maybe worth pointing out some existing examples in the kernel ?"></securetransclude>{{#set:Has reviews comments=true}}

References

  1. 1.01.1 termios API, Linux Programmer's Manual termios API Documentation (user land API with serial devices)
  2. Character device API overview, Accessing hardware from userspace training, Bootlin documentation