简体   繁体   English

linux-device-driver-串行8250回送驱动程序代码?

[英]linux-device-driver - serial 8250 loopback driver code?

I want to implement a serial loopback driver code in 8250.c found in /drivers/tty/serial/8250.c as found in linux-3.6.1 kernel. 我想在/drivers/tty/serial/8250.c中找到的8250.c中实现串行回送驱动程序代码,在linux-3.6.1内核中找到。 I do not want to use the hardware loopback(ie by shorting pin 2(tx) and 3(rx) of the standard serial port), instead I want to modify the 8250.c driver such that, the data from user space will travel from the "serial8250_tx_char" function directly to the "serial8250_rx_char" without going to the hardware, ie I want to receive what is transmitted? 我不想使用硬件环回(即通过短接标准串行端口的引脚2(tx)和3(rx)),而是想修改8250.c驱动程序,以便用户空间中的数据可以传输从“ serial8250_tx_char”功能直接转到“ serial8250_rx_char”,而无需使用硬件,即我想接收传输的内容?

One possible implementation would be to put the transmission circular buffer data into the tty flip buffer, and then push this data up to the tty core so that the user space can receive it? 一种可能的实现方式是将传输循环缓冲区数据放入tty翻转缓冲区中,然后将此数据推入tty内核,以便用户空间可以接收它? I want to know how to do it in the code. 我想知道如何在代码中做到这一点。 We can search the "rx and tx" functions mentioned above-that is where I am looking, and how will I test this, means by writing on the device file and then immediately receiving the same. 我们可以搜索上面提到的“ rx和tx”函数-这就是我正在寻找的地方,以及我将如何对其进行测试,这意味着通过写入设备文件,然后立即将其接收。

I also have a sample patch, but not sure, whether it will work. 我也有一个示例补丁,但不确定是否会起作用。

Any help would be appreciated... 任何帮助,将不胜感激...

Abhijit 阿比吉特

`@@ -2112,6 +2116,7 @@ static int serial8250_startup(struct uart_port *port)
                if (is_real_interrupt(up->port.irq))
                        up->port.mctrl |= TIOCM_OUT2;

   + up->port.mctrl |= TIOCM_LOOP;
    serial8250_set_mctrl(&up->port, up->port.mctrl);

    /* Serial over Lan (SoL) hack:

This will set UART to work in internal loop-back mode.` 这会将UART设置为在内部环回模式下工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM