bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-ncurses] Reset clears CLOCAL flag breaking some hardware serial


From: Michal Suchanek
Subject: Re: [bug-ncurses] Reset clears CLOCAL flag breaking some hardware serial ports
Date: Sat, 4 Nov 2023 19:11:29 +0000

Hello,

On Sat, 4 Nov 2023 at 14:21, Thomas Dickey <dickey@his.com> wrote:
>
> On Wed, Oct 18, 2023 at 10:19:25AM +0200, Dr. Werner Fink wrote:
> > On 2023/10/05 03:59:21 -0400, Thomas Dickey wrote:
> > > On Thu, Oct 05, 2023 at 09:35:04AM +0200, Dr. Werner Fink wrote:
> > > > On 2023/10/04 10:40:35 +0000, Michal Suchanek wrote:
> > > > > Hello,
> > > > >
> > > > > on some development boards and server BMCs the hardware apparently
> > > > > lacks the modem control lines.
> > > > >
> > > > > The OS correctly sets the CLOCAL flag and the terminal works. However,
> > > > > when there is a need to reset the terminal after adjusting the TERM
> > > > > variable the reset tool clears the CLOCAL flag. This is not documented
> > > > > in the man page nor can I see any reason in the git history why this
> > > > > functionality was added (in ncurses 4.1 AFAICS).
> > > >
> > > > That is back more than 25 years ... ncurses-4.1/progs/tset.c
> > >
> > > "more than 25 years" actually goes back to 1995 (28 years), as mentioned 
> > > here
> > >
> > > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=60377
> > >
> > > call that ncurses 1.9.6:
> > >
> > > https://invisible-island.net/ncurses/ncurses-license.html#ncurses_1_9_6
> > >
> > > Just changing it may be disruptive, which prompts caution.
> > >
> > > In my response on the Debian bug report, I had in mind making a table for
> > > the manual to explain the change, and perhaps make it an option rather
> > > than surprise everyone.
> > >
> > > >  static void
> > > >  reset_mode(void)
> > > >
> > > >  [...]
> > > >
> > > >  mode.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD | CLOCAL);
> > > >
> > > >
> > > > >
> > > > > On the affected devices (such as Raspberry Pi) the symptom is that
> > > > > terminal applications using the alternate screen such as less or vim
> > > > > keep waiting in the kernel and never start.
> > > > >
> > > > > I don't think that the CLOCAL flag is part of what the reset tool
> > > > > should change much like the terminal baud rate - this is property of
> > > > > how the terminal is connected, and not the terminal type.
> > > >
> > > > I suggest to check if the open file descriptor of the the tty line has
> > > > set O_NONBLOCK via fcntl/F_GETFL and if so not to clear CLOCAL.
> > > > Normally opening a a port to a modem blocks until the modem reports
> > > > carrier detection, therefore O_NONBLOCK is used.  Then the first read
> > > > or write call will wait for carrier to be established.
> > > >
> > > > Werner
> >
> > I can remember an old tool I had written for blogd called isserial.
> > It simply check if the current input file descriptor has the Modem
> > Control ioctl TIOCMGET ... means if the ioctl() returns -1 with error
> > ENOTTY it is a standard terminal line whereas serials lines do not
> > show an error ENOTTY.
>
> That sounds helpful - but I don't know whether Michal's original comment
> indicates that it may/may not work:
>
>         on some development boards and server BMCs the hardware apparently
>         lacks the modem control lines.

I can't say what the tool would detect, can't reproduce it from the description.

But let's say it detects if the serial port is hardware or virtual.

In the virtual case nobody ever cared, the settings are ignored anyway.

In the hardware port case the line settings need to be preserved.

The only information about baud rate, data bits, parity, stop bits,
and modem control lines that are available are the current line
settings. If those are changed that information is lost and the
communication may break as has been observed in the bug.

Thanks

Michal



reply via email to

[Prev in Thread] Current Thread [Next in Thread]