How to open serial port in linux without changing any pin?

后端 未结 4 1088
南旧
南旧 2021-02-19 00:39

Posix requires changing RTS pin on port opening. I want a way to avoid it.

4条回答
  •  野的像风
    2021-02-19 01:26

    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
    }
    

    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);
    

    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.

提交回复
热议问题