Re: Open a tty for write without raising RTS

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

 



On 08/02/2015 09:03 AM, Joe Nall wrote:
> 
>> On Aug 2, 2015, at 6:37 AM, Peter Hurley <peter@xxxxxxxxxxxxxxxxxx> wrote:
>>
>> On Sat, Aug 1, 2015 at 11:26 AM, Joe Nall <joe@xxxxxxxx> wrote:
>> Is there a mechanism to open a serial port for writing without impacting the control lines?
>>
>> Sorry, no.
> 
> Why would RTS be asserted when there is no reader? Does O_WRONLY have no meaning for a tty?

A write-only tty is setup by clearing the CREAD termios bit:

	termios.c_cflag &= ~CREAD;

Not all drivers honor the bit but they should, so if not, please report a bug
here.

The filp pointer flags are interpreted and asserted by the VFS layer, so there's
not add'l logic in tty drivers below that.

>> It is possible to open, set baud to B0, and close; subsequent open()'s would not
>> raise RTS. However, RTS would be raised when restoring the baud rate prior to writing.
>>
>> What's the purpose of not raising RTS?
> 
> We have a couple of use cases.
> 
> The first is an application that receives and transmits messages on a serial port. The user interface allows transmit and receive to be enabled separately. Right now, the application starts in a disabled receive state by explicitly opening the device and then deasserting DTR/RTS. When the user want to enable reception, we raise DTR/RTS. This has a brief window where RTS is asserted incorrectly that I would like to be able to remove. There has also been some concern that manually raising RTS might impact subsequent automatic flow control.

Please reports bugs with any drivers that misbehave wrt automatic flow control and manual RTS.
The expected behavior is for lowering RTS via ioctl(TIOCMSET) to cause RTS pin to
logically lower, and raising RTS via ioctl(TIOCMSET) to resume normal flow control (either on
or automatic flow control).

> I had hoped I could rewrite the code to use separate read only and write only fds and get rid of the application fiddling with DTR/RTS.

Apologies if this comes across the wrong way, but ISTM that the application should reflect the
actual state rather than start in a state that does not match the hardware state.

Regardless, AFAIK there is no way to initialize termios before opening the tty.

> The second is an application that statuses the control lines on software. The code is raising DTR/RTS as a side effect of opening the device. Setting the baud rate to B0 won't work in this case either.

For this, you can screen-scrape /proc/tty/driver/serial

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



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux