Page MenuHomeFreeBSD

Allow control over initial state of RTS and DTR lines
ClosedPublic

Authored by shurd on Apr 23 2019, 8:47 PM.
Tags
None
Referenced Files
F68262108: D20031.diff
Mon, Sep 25, 9:24 PM
Unknown Object (File)
Fri, Sep 1, 5:15 AM
Unknown Object (File)
Fri, Sep 1, 5:13 AM
Unknown Object (File)
Fri, Sep 1, 5:13 AM
Unknown Object (File)
Fri, Sep 1, 5:07 AM
Unknown Object (File)
Fri, Sep 1, 4:51 AM
Unknown Object (File)
Aug 19 2023, 2:02 AM
Unknown Object (File)
Jul 13 2023, 6:23 AM
Subscribers

Details

Summary

Some devices take undesired actions when RTS and DTR are
asserted. Some development boards for example will reset on DTR,
and some radio interfaces will transmit on RTS.

This patch allows "stty -f /dev/ttyu9.init -rtsdtr" to prevent
RTS and DTR from being asserted on open(), allowing these devices
to be used without problems.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans added a subscriber: ian.

Tagging @ian as well, as he may be interested in this for $work purposes.

I think this also needs to cover the DTR|RTS setting in ucom_open (^/sys/dev/usb/serial/usb_serial.c) for completeness sake, but I defer to @imp and @ian as they've likely got better intuition of how that should work.

Tagging @ian as well, as he may be interested in this for $work purposes.

I think this also needs to cover the DTR|RTS setting in ucom_open (^/sys/dev/usb/serial/usb_serial.c) for completeness sake, but I defer to @imp and @ian as they've likely got better intuition of how that should work.

Hrm, presumably that's there for cases where ucom_open() is called via ucom_param() or ucom_attach_tty()?

Tagging @ian as well, as he may be interested in this for $work purposes.

I think this also needs to cover the DTR|RTS setting in ucom_open (^/sys/dev/usb/serial/usb_serial.c) for completeness sake, but I defer to @imp and @ian as they've likely got better intuition of how that should work.

Hrm, presumably that's there for cases where ucom_open() is called via ucom_param() or ucom_attach_tty()?

Yeah, that looks right. That gets a little bit tricky... if we're responding to an open of the tty, ucom will always invoke ucom_open through ucom_param because of how the lower layer operates. It'll subsequently get invoked as tsw_open, but at that point the upper layer will have already been initialized and it does nothing.

I think the right thing to do is probably to exclude only the ucom_attach_tty -> ucom_open path from honoring this.

bin/stty/print.c
187 ↗(On Diff #56551)

This seems insane, we have no precedent I can think of for a '--something' setting in stty, and it creates a potential conflict with getopt_long() style args, which are supported by linux stty, so you gotta think some day someone is going to add that to our version.

The option name should be nortsdtr, or the whole concept should be inverted to make it a positive CRTSDTR flag that's on by default and off with -rtsdtr.

share/man/man4/termios.4
1275 ↗(On Diff #56551)

Manpage style requires a new sentence to begin on its own line.

Address feedback, add support to umcs.

  • Use nortsdtr as the flag name rather than -rtsdtr.
  • Fix manpage style.
  • Add check in usb_serial.c to USB serial more devices.
  • Make umcs respect the flag in the ucom_cfg_open() callback.

I really dislike the noFOO stuff.
It should be like clocal. clocal ignores modem status lines on input.
One option is to call it just rtsdtr and -rtsdtr turns it off. It would default to being on, but that's tricky to implement
The other would be to call it something like cappready to signal that the application controls turning it on or off.

I know this is a somewhat meta comment, kinda late in the game.

bin/stty/print.c
187 ↗(On Diff #56551)

Yes. I concur.

bin/stty/stty.1
148–149 ↗(On Diff #56724)

Double negatives will generate much hate.

Use rtsdtr as the stty argument to set the default mode, and -rtsdtr to
disable automatically asserting them on open().

This causes the stty argument to have the opposite polarity as the control
flag. The stty flag name can be renamed fairly easily, but the control flag
pretty much needs to default to zero.

Use rtsdtr as the stty argument to set the default mode, and -rtsdtr to
disable automatically asserting them on open().

This causes the stty argument to have the opposite polarity as the control
flag. The stty flag name can be renamed fairly easily, but the control flag
pretty much needs to default to zero.

mandtr is what I thought of, but rtsdtr works fine too.

This revision is now accepted and ready to land.Jun 6 2019, 4:23 PM
This revision was automatically updated to reflect the committed changes.