简体   繁体   English

Linux内核中的tty_tiocmset屏蔽所需的调制解调器信号

[英]tty_tiocmset in linux kernel masks desired modem signal

I am running an embedded linux kernel on hardware that can be configured as DTE/DCE. 我在可以配置为DTE / DCE的硬件上运行嵌入式Linux内核。 In the tty/serial drivers in a file called tty_io.c there is a function tty_tiocmset() which takes a bit pattern from the tty_ioctl for setting/clearing specific modem control signals. 在名为tty_io.c的文件中的tty / serial驱动程序中,有一个函数tty_tiocmset(),该函数从tty_ioctl中获取位模式以设置/清除特定的调制解调器控制信号。 Interestingly, the tty_tiocmset() function masks all other modem signals besides TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP (this mask is shown in the code below). 有趣的是,除了TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 | TIOCM_OUT2 | TIOCM_LOOP外,tty_tiocmset()函数还屏蔽了所有其他调制解调器信号(此屏蔽显示在下面的代码中)。 However, if you look at the documentation it appears that all modem signals should be able to be set/cleared http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html scroll down to "Modem Control". 但是,如果您查看文档,则似乎应该能够设置/清除所有调制解调器信号http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html滚动直到“调制解调器控制”。

Does anybody simply know why this mask is present without other signals such as RI, CD, CTS, DSR? 是否有人会简单地知道为什么没有其他信号(例如RI,CD,CTS,DSR)时会出现此掩码? Also is there another way to use the unmodified driver to control the other modem signals? 还有没有其他方法可以使用未修改的驱动程序来控制其他调制解调器信号?

Linux was originally hosted on the x86 PC platform, which used 8250-type UARTs. Linux最初托管在x86 PC平台上,该平台使用8250型UART。 The modem signal names OUT1 & OUT2 are not EIA/RS-232 names but do appear in the Western Digital 8250 data sheet! 调制解调器信号名称OUT1和OUT2不是EIA / RS-232名称,但确实出现在Western Digital 8250数据表中! Those 5 bits listed for tty_tiocmset() match (by name & function) the 5 bits available in the 8250 Modem Control Register. tty_tiocmset()列出的那5位与8250调制解调器控制寄存器中的5位相匹配(按名称和功能)。 Any additional control lines would have to be implemented by logic external to the 8250. 任何其他控制线都必须由8250外部的逻辑来实现。

Does anybody simply know why this mask is present without other signals such as RI, CD, CTS, DSR? 是否有人会简单地知道为什么没有其他信号(例如RI,CD,CTS,DSR)时会出现此掩码?

Those four that you mention are input signals to a DTE port, and PCs are normally configured (or assume/default) to be DTE. 您提到的那四个是DTE端口的输入信号,通常将PC配置(或假定/默认)为DTE。
Input signals would not appear in an output control register. 输入信号不会出现在输出控制寄存器中。
Maybe this is a bug when Linux is embedded in a device for a DCE port? 当Linux嵌入DCE端口的设备中时,这可能是一个错误吗?
These input signals do appear in the Modem Status Register. 这些输入信号的确出现在调制解调器状态寄存器中。

Also is there another way to use the unmodified driver to control the other modem signals? 还有没有其他方法可以使用未修改的驱动程序来控制其他调制解调器信号?

You could remap OUT1 and OUT2 to whatever additional DTE signal(s) you need to output. 您可以将OUT1OUT2重新映射到您需要输出的任何其他DTE信号。
If you need to setup the port for DCE, then you may have to remap all four control lines. 如果需要为DCE设置端口,则可能必须重新映射所有四个控制线。
For a DCE port (ie modem) there are typically only 4 output control lines: DCD, CTS, DSR, and RI. 对于DCE端口(即调制解调器),通常只有4条输出控制线:DCD,CTS,DSR和RI。 And there are exactly 4 output control bits (besides loopback) in the 8250 MCR! 8250 MCR中恰好有4个输出控制位(除了环回)!

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

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