All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stuart Longland <stuartl-3e+Fe6x+DsgJbe36r25VNhCuuivNXqWP@public.gmane.org>
To: Oliver Neukum <oneukum-IBi9RG/b67k@public.gmane.org>,
	Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Alan Cox
	<gnomes-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>,
	linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@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 08:07:54 +1000	[thread overview]
Message-ID: <ae2907c2-cb0f-61e4-c6f2-af3dcec93ace@longlandclan.id.au> (raw)
In-Reply-To: <1498565331.30390.5.camel-IBi9RG/b67k@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1862 bytes --]

On 27/06/17 22:08, Oliver Neukum wrote:
> Am Dienstag, den 27.06.2017, 19:43 +1000 schrieb Stuart Longland:
>> 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
>>
>> and to select 4-wire ("full duplex") RS-485, one does:
>> # echo rs485fd > /sys/class/tty/ttyUSB0/standard 
> This looks like something that people will put into udev.
> So the switch will be done via udev, but the user not necessarily
> started via udev. Looks like a race to me.

It is a race, but unless a daemon is watching for the very moment that a
particular serial interface appears, it's one that init scripts are very
likely to win.

Short of having a flag that blocks reads/writes until a given sysfs file
is written to say "I'm ready, go ahead"… there aren't that many options
I can think of.

> And what do you if the interface is already opened and the sysfs
> interface is used?

We return -EBUSY?  If the interface is open, there isn't a lot we can
do, the user either puts up with unpredictable behaviour or we refuse
the switch.

By unpredictable behaviour: if the device is well behaved, there might
be a small signal level glitch… but I'd expect serial devices to be
tolerant of that kind of step change in signal.  (Think hot-plugging
serial links.)

This beats the official Moxa solution: their Windows driver wants a
reboot of the entire machine to switch between serial standards.
-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2017-06-27 22:07 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 [this message]
     [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
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=ae2907c2-cb0f-61e4-c6f2-af3dcec93ace@longlandclan.id.au \
    --to=stuartl-3e+fe6x+dsgjbe36r25vnhcuuivnxqwp@public.gmane.org \
    --cc=gnomes-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org \
    --cc=johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=oneukum-IBi9RG/b67k@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.