![직렬 드라이버가 tty 포트에 연결되는 방법](https://linux55.com/image/172869/%EC%A7%81%EB%A0%AC%20%EB%93%9C%EB%9D%BC%EC%9D%B4%EB%B2%84%EA%B0%80%20tty%20%ED%8F%AC%ED%8A%B8%EC%97%90%20%EC%97%B0%EA%B2%B0%EB%90%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
여기에서 Linus 샘플 UART 드라이버 코드를 살펴보겠습니다.
https://github.com/martinezjavier/ldd3/blob/master/tty/tiny_serial.c
다음은 tty 포트로 데이터를 보내는 UART 드라이버의 코드 조각입니다.
static void tiny_timer(unsigned long data)
{
struct uart_port *port;
struct tty_struct *tty;
struct tty_port *tty_port;
port = (struct uart_port *)data;
if (!port)
return;
if (!port->state)
return;
tty = port->state->port.tty;
if (!tty)
return;
tty_port = tty->port;
/* add one character to the tty port */
/* this doesn't actually push the data through unless tty->low_latency is set */
tty_insert_flip_char(tty_port, TINY_DATA_CHARACTER, 0);
tty_flip_buffer_push(tty_port);
/* resubmit the timer again */
timer->expires = jiffies + DELAY_TIME;
add_timer(timer);
/* see if we have any data to transmit */
tiny_tx_chars(port);
}
그러나 코드를 보면 UART 포트와 tty 포트 간의 결합이 어떻게 설정되는지 명확하지 않습니다. Linux에서는 수동 구성이 필요합니까?