All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Stuart Longland
	<stuartl-3e+Fe6x+DsgJbe36r25VNhCuuivNXqWP@public.gmane.org>
Cc: Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Alan Cox
	<gnomes-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
Subject: Re: Moxa UPort 1150 and RS-422/485… what's the "proper" way to switch modes
Date: Wed, 28 Jun 2017 17:16:20 +0200	[thread overview]
Message-ID: <20170628151620.GB17630@localhost> (raw)
In-Reply-To: <42601356-656d-57d0-d366-a0933780b8f9-3e+Fe6x+DsgJbe36r25VNhCuuivNXqWP@public.gmane.org>

On Tue, Jun 27, 2017 at 07:43:28PM +1000, Stuart Longland wrote:
> On 27/06/17 19:04, Johan Hovold wrote:
> >> What's the "proper" way to configure such ports for RS-422 and/or 4-wire
> >> RS-485?  Is there an example driver in the tree that I can use as a
> >> guide to porting Moxa's mode-switch code over to the ti_usb_3410_5052
> >> driver?
> > 
> > I'm afraid not. We have the TIOCSRS485 ioctl, but that doesn't really
> > fit here (currently) as we're not just enabling 2-wire-rs485 style
> > signalling (using RTS to control the tranceiver), but are also
> > configuring the electrical interface (e.g. which pins on the DB9
> > connector are being used for which functions).
> > 
> > This question is raised every now and then; typically when a new
> > driver is being merged (e.g. mxuport or when support for your device was
> > added), but we have yet to decide on the proper interface.
> > 
> > Extending the TIOCSRS485 ioctl has been discussed, and one alternative
> > could be a sysfs-based interface as this would typically be something
> > you'd want to configure at boot and before opening the device (and
> > toggling DTR).
> 
> I did consider sysfs this morning… this would make a lot of sense.
> These things being USB, it is possible that a udev trigger could put it
> in the appropriate mode when they are plugged in.  Sounds a much better
> option than re-purposing other fields.

Unless there are too many attributes to set at least, otherwise a single
ioctl might still be still be more convenient. Note that there is room
for extending the TIOCSRS485 ioctl.

> > Either way, we need do determine the right level of abstraction as some
> > of the related properties are fairly device dependent (master/slave
> > mode, terminating resistors, auto direction, echo, etc).
> > 
> > For the record, note that we do have the mxser driver, and a few more
> > old drivers, implementing custom ioctls for this, but we really should
> > not be adding more of those.
> 
> Yeah, I won't be adding ioctls… it makes the interface too
> hardware-specific.  If anything, the ioctls might be a hint to what
> enumerated properties to expose on sysfs, then the ioctl interface can
> be gradually phased out.
> 
> I'll have a look at mxser.  At this point I'm thinking gathering a
> listing of what devices support what configuration options would be
> worthwhile.  I know the UPort 1150 supports 2-wire RS-485, 4-wire
> RS-485, RS-422 and RS-232… the UPort 1100 drops support for RS-232… I
> don't think either offer termination resistance options.

There are more Moxa devices with rs485-support, including those managed
by the mxuport driver. Some Edgeport devices apparently support some of
those more exotic settings like termination, see

	https://marc.info/?l=linux-usb&m=129798628514104&w=2

The above thread also has some discussion about extending the TIOCSRS485
ioctl.

Other USB serial devices that have some support for rs485 include cp210x
(using a gpio pin to control the tranceiver), and some Fintek devices.

Also note that the vendor driver for UPort 1150 treats rs422 and
rs485-4w the same and really only has three distinct modes (rs232, and
rs485 with receiver enabled or disabled).

> Maybe a good start would be a "standard" option (referring to the
> physical signalling standard, TTL/RS-232/RS-422/RS-485), that lists the
> available standards when read and shows the "selected" standard in
> brackets (like the 'trigger' option of the LEDs sysfs interface)… so for
> this case:
> 
> # cat /sys/class/tty/ttyUSB0/standard
> [rs232] rs422 rs485 rs485fd

Yeah, I once suggested something like this for Moxa, but I think we need
to at least consider the various parameters available first if we are to
come up with a generic interface.

> and to select 4-wire ("full duplex") RS-485, one does:
> # echo rs485fd > /sys/class/tty/ttyUSB0/standard
> 
> A hypothetical dongle that supports pin re-mapping might have
> properties: rxd, txd, rts, cts, dtr, dsr, cd, ri, gnd (for RS-232; maybe
> a, b and gnd for RS-485 or txa, txb, rxa, rxb, gnd for
> RS-422/full-duplex-RS-485) that gives the pin numbers/labels:
> 
> cd: [1] 2 3 4 5 6 7 8 9
> rx: 1 [2] 3 4 5 6 7 8 9
> tx: 1 2 [3] 4 5 6 7 8 9
> … etc …

This I think might be taking it too far at this stage though. :)

> and termination resistance (separate options for RX and TX) might be a
> selection of off, and the available resistances. (e.g. "50", "75",
> "120", "1k" … whatever the device supports.)

A binary setting here might suffice.

> I'm open to ideas here, I'm not sure how many configurable serial
> interfaces there are out there (USB or otherwise), so if people watching
> the list can provide some examples of these devices, this will be a big
> help.

I mention a few above, and there are some old ones like rocket and mxser
that have a custom ioctl for this.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-06-28 15:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4a469222-d48d-f498-f2db-ca582295adc3@longlandclan.id.au>
     [not found] ` <4a469222-d48d-f498-f2db-ca582295adc3-3e+Fe6x+DsgJbe36r25VNhCuuivNXqWP@public.gmane.org>
2017-06-27  9:04   ` Moxa UPort 1150 and RS-422/485… what's the "proper" way to switch modes Johan Hovold
2017-06-27  9:43     ` Stuart Longland
     [not found]       ` <42601356-656d-57d0-d366-a0933780b8f9-3e+Fe6x+DsgJbe36r25VNhCuuivNXqWP@public.gmane.org>
2017-06-27 12:08         ` Oliver Neukum
     [not found]           ` <1498565331.30390.5.camel-IBi9RG/b67k@public.gmane.org>
2017-06-27 22:07             ` Stuart Longland
     [not found]               ` <ae2907c2-cb0f-61e4-c6f2-af3dcec93ace-3e+Fe6x+DsgJbe36r25VNhCuuivNXqWP@public.gmane.org>
2017-06-28  9:19                 ` Oliver Neukum
     [not found]                   ` <1498641549.10278.5.camel-IBi9RG/b67k@public.gmane.org>
2017-06-28 12:01                     ` Greg KH
     [not found]                       ` <20170628120120.GA10502-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2017-06-28 12:41                         ` Oliver Neukum
     [not found]                           ` <1498653709.10278.17.camel-IBi9RG/b67k@public.gmane.org>
2017-06-28 14:59                             ` Bjørn Mork
2017-06-28 15:35                 ` Johan Hovold
2017-06-28 15:34             ` Johan Hovold
2017-06-29 19:50               ` Alan Cox
2017-07-03  8:51                 ` Johan Hovold
2017-06-28 15:16         ` Johan Hovold [this message]
2017-08-18  2:56   ` [PATCH] USB: serial: ti_usb_3410_5052: Port uart_mode from io_ti Stuart Longland
     [not found]     ` <20170818025659.4402-1-stuartl-EoQOJlg3kTYQrrorzV6ljw@public.gmane.org>
2017-08-18  3:16       ` Stuart Longland
2017-08-19 20:40       ` Maksim Salau
     [not found]         ` <20170819234056.37c7d339-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-19 20:47           ` Stuart Longland
2017-08-28  8:56       ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170628151620.GB17630@localhost \
    --to=johan-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=gnomes-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org \
    --cc=linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stuartl-3e+Fe6x+DsgJbe36r25VNhCuuivNXqWP@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.