问题描述
Posix 需要在端口打开时更改 RTS 引脚.我想要一种方法来避免它.
Posix requires changing RTS pin on port opening. I want a way to avoid it.
推荐答案
遇到同样的问题,我会尝试通过修补 ftdi_sio
内核驱动程序.您只需要像这样在 ftdi_dtr_rts()
中取消注释一小段代码:
Having the same problem, I'd give it a try by patching the ftdi_sio
kernel driver. You just need to uncomment a small piece of code in ftdi_dtr_rts()
like this:
static void ftdi_dtr_rts(struct usb_serial_port *port, int on) {
...
/* drop RTS and DTR */
if (on)
set_mctrl(port, TIOCM_DTR /*| TIOCM_RTS*/); // <<-- HERE
else
clear_mctrl(port, TIOCM_DTR /*| TIOCM_RTS*/); // <<-- and HERE
}
并且 RTS 握手线在 open()
调用时不再更改.请注意,只要加载了修改后的内核驱动程序,uart 就可能不再使用 RTS/CTS 硬件握手.但是您仍然可以通过调用例如手动控制 RTS 握手线的状态:
and the RTS handshake line is not longer changed upon open()
call.Note, that the uart than might not longer working with RTS/CTS hardware handshake, as long as your modified kernel driver is loaded. But you can still control the state of the RTS handshake line manually by calling e.g.:
int opins = TIOCM_RTS;
ioctl(tty_fd, TIOCMBIC, &opins);
我使用 picocom 2.3a 的 Ctrl+A+G
命令对此进行了测试,运行 Kubuntu 16.04 64 位和 Ftdi FT2232H 基于 USB uart 适配器.
I'd tested this with the Ctrl+A+G
command of picocom 2.3a, running Kubuntu 16.04 64 bit and Ftdi FT2232H based usb uart adapter.
您可以在此处找到有关此主题的更多详细信息.
You might find more details on this topic here.
这篇关于如何在不更改任何引脚的情况下在linux中打开串口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!