2009-03-26 07:47:48

by Paul Rolland

[permalink] [raw]
Subject: Linux 2.6.x - Serial port signalling not maintained when closing device

Hello,

I'm using small devices that are connected on the serial port, and powered
using RTS and DTR.
When using kernel 2.4.x (at least 2.4.31), I could easily control the
powering of the device using :
stty -F /dev/ttyS0 ospeed 9600 (this would put RTS and DTR to 1 / power)
and
stty -F /dev/ttyS0 ospeed 0 (this would turn it off).

I've recently updated one of the machine to a new 2.6.29 kernel, and this
is not working anymore.
As far as I can see, I need to have an application that keeps /dev/ttyS0
open for this to work. As soon as no application is using the port,
everything goes down again.

This is a significant change between 2.4.x and 2.6.x. Is there a way to
change 2.6.x behavior to go back to the 2.4.x ? When was this change
introduce ?

This serial port controler is a 16550A, the machine is an x86 platform, so
nothing unusual.

Best regards,
Paul


2009-03-26 08:21:52

by Alan

[permalink] [raw]
Subject: Re: Linux 2.6.x - Serial port signalling not maintained when closing device

> As far as I can see, I need to have an application that keeps /dev/ttyS0
> open for this to work. As soon as no application is using the port,
> everything goes down again.

Yes - the 2.6 kernel has the newer uart driver layer and is also
(throughout) much more aggressive about power management. You'll see the
same with magic electronic project parallel port hacks where the port is
turned off when the device file is not open.

> This is a significant change between 2.4.x and 2.6.x.

Only to your rather unusual use of things. For normal use the current
behaviour is far more correct.

> Is there a way to
> change 2.6.x behavior to go back to the 2.4.x ? When was this change
> introduce ?

Just keep the port open when you are using it. Even in 2.4 the driver
could have been unloaded on some setups if you didn't have a port open.

Alan

2009-03-26 15:09:07

by Paul Fulghum

[permalink] [raw]
Subject: Re: Linux 2.6.x - Serial port signalling not maintained when closing device

Paul Rolland wrote:
> I'm using small devices that are connected on the serial port, and powered
> using RTS and DTR.
> When using kernel 2.4.x (at least 2.4.31), I could easily control the
> powering of the device using :
> stty -F /dev/ttyS0 ospeed 9600 (this would put RTS and DTR to 1 / power)
> and
> stty -F /dev/ttyS0 ospeed 0 (this would turn it off).
>
> I've recently updated one of the machine to a new 2.6.29 kernel, and this
> is not working anymore.
> As far as I can see, I need to have an application that keeps /dev/ttyS0
> open for this to work. As soon as no application is using the port,
> everything goes down again.

Are you explicitly clearing the HUPCL flag?
(stty -F /dev/ttyS0 -hupcl)

I just did a quick test on 2.6.22 and DTR/RTS are maintained
with your commands above, but only after clearing HUPCL.

--
Paul Fulghum
MicroGate Systems, Ltd.
=Customer Driven, by Design=
(800)444-1982
(512)345-7791 (Direct)
(512)343-9046 (Fax)
Central Time Zone (GMT -5h)
http://www.microgate.com