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
Unknown Object (File)
Mon, Mar 4, 3:24 AM
Unknown Object (File)
Mon, Mar 4, 3:19 AM
Unknown Object (File)
Feb 18 2024, 8:19 AM
Unknown Object (File)
Feb 7 2024, 6:41 PM
Unknown Object (File)
Jan 7 2024, 6:56 AM
Unknown Object (File)
Dec 31 2023, 9:44 AM
Unknown Object (File)
Dec 31 2023, 9:44 AM
Unknown Object (File)
Dec 22 2023, 10:41 PM
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.