Skip to content
Advertisement

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

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

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement