如何在不更改任何引脚的情况下在linux中打开串行端口? [英] How to open serial port in linux without changing any pin?

查看:95
本文介绍了如何在不更改任何引脚的情况下在linux中打开串行端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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
}

,并且open()调用后,RTS握手线不再更改. 请注意,只要加载了修改后的内核驱动程序,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中打开串行端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆