シリアルドライバがttyポートに接続される方法

シリアルドライバがttyポートに接続される方法

ここで、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では手動設定が必要ですか?

ベストアンサー1

おすすめ記事