[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZLk6nu_PuH5Tr-L8@hovoldconsulting.com>
Date: Thu, 20 Jul 2023 15:46:06 +0200
From: Johan Hovold <johan@...nel.org>
To: Jarkko Sonninen <kasper@....fi>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] USB: serial: xr: Add TIOCGRS485 and TIOCSRS485 ioctls
On Thu, Jul 06, 2023 at 10:37:51PM +0300, Jarkko Sonninen wrote:
> On 6/20/23 15:38, Johan Hovold wrote:
> Thank you. Sorry for slow responses. My mind has been elsewhere.
No worries at all.
> > On Sun, Apr 23, 2023 at 09:59:28PM +0300, Jarkko Sonninen wrote:
> >> User enables RS-485 mode by setting SER_RS485_ENABLED flag in
> >> struct serial_rs485 flags. User should also set either
> >> SER_RS485_RTS_ON_SEND or SER_RS485_RTS_AFTER_SEND to select the
> >> behaviour of the RTS#/RS485 pin. Setting SER_RS485_RTS_ON_SEND
> >> will drive RTS#/RS485 high during transmission. As this is the
> >> typical application described by Exar, it is selected when
> >> user sets neither or both flags.
> > Since RTS# is active low, shouldn't SER_RS485_RTS_ON_SEND drive RTS# low
> > rather than high during transmission as I also pointed out earlier?
>
> I guess you are right. I'll change that.
>
>
> I use an exar usb adapter to control a solar charging controller. I
> haven't found any other type of exar adapters in ebay.
>
> This adapter uses high level (RTS off) on TX. So I really would like it
> to work with the default configuration.
>
> I hope it is ok to use SER_RS485_RTS_AFTER_SEND as the default
I was first going to argue against with this as serial core defaults to
SER_RS485_RTS_ON_SEND when neither is set, but I changed my mind as I
believe this is more in line with how these flags were intended to be
used.
Having both flags set to the same value clearly makes no sense, but if
left that way I think SER_RS485_RTS_ON_SEND should take precedence and
SER_RS485_RTS_AFTER_SEND simply be set not its negation (when the
hardware does not support the nonsensical RTS always asserted
combination...). That is:
/* RTS always toggles after TX */
if (rs485->flags & SER_RS485_RTS_ON_SEND)
rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
else
rs485->flags |= SER_RS485_RTS_AFTER_SEND;
Since you still need to use the new ioctl() to enable RS485 mode, there
shouldn't really be any reason not to simultaneously set the polarity
your application expects anyway.
Johan
Powered by blists - more mailing lists