Re: [PATCH 4/4] tty: serial: 8250: Add support for MOXA PCIe boards to switch interface between RS422/RS485

From: Crescent CY Hsieh
Date: Tue Oct 03 2023 - 05:58:04 EST


On Mon, Oct 02, 2023 at 09:19:26AM +0200, Jiri Slaby wrote:
> On 02. 10. 23, 3:57, Crescent CY Hsieh wrote:
> > MOXA PCIe boards have 4 serial interfaces and don't require additional
> > stuff to switch between interfaces:
> >
> > - RS232
> > - RS422
> > - RS485_2W (half-duplex)
> > - RS485_4W (full-duplex)
> >
> > By using ioctl command "TIOCRS485", it can switch between default
> > interface and RS485 if supported.
> >
> > That means, for RS422/RS485 board, it can switch between RS422 and
> > RS485 by setting the flags within struct serial_rs485.
> >
> > However, for the RS232/RS422/RS485 board, it can only switch between
> > RS232 and RS485, there's no flag for switching interface into RS422.
> >
> > This patch adds a flag call "SER_RS422_ENALBED" in serial.h and modifies
>
> Hopefully not SER_RS422_ENALBED.

What if I use an existing flag within struct serial_rs485 to represent
RS422 as a workaround solution?

> > @@ -1299,7 +1299,7 @@ static int uart_get_icount(struct tty_struct *tty,
> > #define SER_RS485_LEGACY_FLAGS (SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | \
> > SER_RS485_RTS_AFTER_SEND | SER_RS485_RX_DURING_TX | \
> > - SER_RS485_TERMINATE_BUS)
> > + SER_RS485_TERMINATE_BUS | SER_RS422_ENALBED)
>
> So have you tested this at all?

I have tested it by switching the serial interface using TIOCSRS485
ioctl command, but it seems that I send the wrong patch which mistyping
SER_RS422_ENABLED.

---
Sincerely,
Crescent CY Hsieh