Mailing List Archive

1 2  View All
Re: Serial custom speed deprecated? [ In reply to ]
> Also, Oxford's 16PCI95x family has three different points of altering
> the clock; the clock prescaler, the actual sample rate (which is the
> classic /16 that most are used to), and the actual divisor. That can
> produce pretty much any baud rate, albeit with some error.

Their data sheet doesn't explain it too well, but it looks like they
use a similar implementation to the MSP430 UARTs, which are designed
to work with very low clock rates. (32768 Hz watch crystals are
popular.)

Just as a reminder, UART receive operation is generally:
- After detecting a falling edge, wait half a bit time.
- Sample the input 3x and majority-vote. If the input
line is still low, call this a start bit and prepare to
receive a character.
- Wait one bit time, sample 3x, and call the majority the start bit.
- Repeat for all data bits and the stop bit. If the stop bit isn't
1 as expected, note a framing error.

This is traditionally done by running a 16x clock sampling the
input, and after detecting a start bit on one clock (call that
clock 0), sample the start bit on clocks 7, 8 and 9, the first bit
on clocks 23, 24 and 25, etc.

MSP430 UARTs have a fully programmable clocks/bit number (no fixed /16,
although you want a few clocks per bit so the standard "sample 3x and
majority vote" algorithm works), and can add +1 clock to individual
bit times to approximate a desired baud rate more closely by dithering.
Oh, and they use both edges of the clock.

So it can go to a baud rate 1/3 of the input baud clock (sample the
start bit at 1, 1.5 and 2 clocks, then the first bit at 4, 4.5 and 5,
etc.), and proceed to 9/24, 10/24, etc.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
linux@horizon.com wrote:
>> Or we could just add a standardised extra set of speed ioctls, but then
>> we need to decide what occurs if I set the speed and then issue a
>> termios call - does it override or not.
>
<snip>
> Alternatively, you could observe that asynchronous communications only
> requires agreement withing 5% between sender and receiver, so specifying
> a baud rate to much better than 1% is not too important.

To nitpick.
For a 10 bit long word, if the receiver syncs to within 1/8th of the
middle of a bit-time at the start, you've got 2/8th of a bit-time of
disagreement possible, before you are likely to get errors, especially
on limited slew-rate signals. (more modern chips will likely sample faster)
Or 3/80, or 2.5%. If the other side has made a similar calculation, then
you should only really rely on 1%.
5% is the best possible case - that will in most circumstances cause errors.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
> To nitpick.
> For a 10 bit long word, if the receiver syncs to within 1/8th of the
> middle of a bit-time at the start, you've got 2/8th of a bit-time of
> disagreement possible, before you are likely to get errors, especially
> on limited slew-rate signals. (more modern chips will likely sample faster)
> Or 3/80, or 2.5%. If the other side has made a similar calculation, then
> you should only really rely on 1%.
> 5% is the best possible case - that will in most circumstances cause errors.

You're quite right; 5% assumes perfect signal edges, which you don't
get in practice, especially at high baud rates. Also, you have
frational stop bit tricks from some modems.

Still, as I suggested, half-precision floating point (1 sign, 5 exponent,
10 mantissa) as used for HDR graphics has a relative error range of 1/1024
(0.098%) to 1/2047 (0.049%), and would be an excellent match.

It's not a terribly serious suggestion, as I don't think 134.5 baud
is a serious issue these days, but it does make clear that there's no
difference between 115,200 baud and 115,299 baud.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Thu, Aug 24, 2006 at 11:11:41PM +0100, Alan Cox wrote:
> Ar Iau, 2006-08-24 am 16:43 -0400, ysgrifennodd linux-os (Dick Johnson):
> > at 75 and increases by powers-of-two. This is because the hardware
> > always had fixed clocks with dividers that divided by powers-of-two.
> > What is the claim for the requirement of strange baud-rates set
> > as an integer of dimension "baud?" Where does this requirement
> > come from and what devices use these?

> A lot of chips will do all sorts of interesting speeds such as
> 31.5Kbit because today the clocks are themselves quite configurable.

More importantly, the base-clocks are getting higher and higher, and
the division is no longer a "power-of-two". Thus 9600 is no longer
2.456MHz / 2^8, but something like 33MHz / 3438. This allows modern
hardware to run much faster baud rates, as well as custom slower baud
rates.

Note that IMHO, we should have started hiding this mess from /drivers/
a long time ago. The tty layer should convert the B_9600 thingies to
"9600", the integer, and then call the set_termios function. The
driver should be prohibited from looking at how the the baud rate came
to be 9600, and attempt to approach the requested baud rate as good as
possible. It might return a flag somewhere: Not exact. In the example
above, the resulting baud rate is about 1.4 baud off: 9598.6. This is
not a problem in very many cases.

Once this is in place, you lose a lot of "figure out the baud rate
integer from the B_xxx settings" code in all the drivers, as well as
that we get to provide a new interface to userspace without having to
change ALL drivers at the same time. This decouples the drivers from
the kernel<->userspace interface.

Roger.

--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement.
Does it sit on the couch all day? Is it unemployed? Please be specific!
Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Sun, Aug 27, 2006 at 08:52:11AM +0200, Rogier Wolff wrote:
> Once this is in place, you lose a lot of "figure out the baud rate
> integer from the B_xxx settings" code in all the drivers, as well as
> that we get to provide a new interface to userspace without having to
> change ALL drivers at the same time. This decouples the drivers from
> the kernel<->userspace interface.

This has been helped along by serial_core - drivers have helper
functions which they call (along with their min/max baud rate)
which handles all this stuff.

The one thing your idea is missing is how to handle the "user
requested 15mbaud but I can only do 115200baud" case - POSIX
prefers you to report back what you actually selected rather
than error out. If you merely pass an integer to the drivers,
they can't do that.

Note also that some drivers effectively have run-time configurable
max baud rates, so you can't pass a fixed set of capabilities to
the tty layer on driver initialisation.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Sat, 26 Aug 2006 linux@horizon.com wrote:

>> Or we could just add a standardised extra set of speed ioctls, but then
>> we need to decide what occurs if I set the speed and then issue a
>> termios call - does it override or not.
>
> Actually, we're not QUITE out of bits. CBAUDEX | B0 is not taken.

B0 is not a bit (there are no bits in 0). It won't work.

> That would make a reasonable encoding for a custom speed.
> (But I haven't checked glibc... ah, yes, it should work!
> See glibc-2.4/sysdeps/unix/sysv/linux/speed.c; browse at
> http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/unix/sysv/linux/?cvsroot=glibc
> if you don't have a local copy source handy.)
>
> What I'd do is, when converting to the old-style for tcgetattr, if the
> current baud rate is not representable, cache it somewhere and return that
> (or some other magic value). If a tcsetatt call comes in that specifies
> that magic value, use the cached baud rate.
>
> If you make the cache just the current baud rate setting (the magic
> value on set means "don't alter"), that will handle a lot of programs
> that just want to play with handshaking.
>
> If you make the cache separate, you can also survive an
> old-interface-using program switching to a different baud rate and then
> switching back.
>
>
> Also note that if you truly want to support all baud rates in historical
> use, you'll need to include at least one fractional bit for 134.5 baud.
> (Unless you're sure that IBM 2741 terminals are truly dead. :-))
>
> Alternatively, you could observe that asynchronous communications only
> requires agreement withing 5% between sender and receiver, so specifying
> a baud rate to much better than 1% is not too important.
>
> Half-precision floating point would be ideal for the job. :-)
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.24 on an i686 machine (5592.62 BogoMips).
New book: http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
RE: Serial custom speed deprecated? [ In reply to ]
From: On Behalf Of Rogier Wolff
> Note that IMHO, we should have started hiding this mess from /drivers/
> a long time ago. The tty layer should convert the B_9600 thingies to
> "9600", the integer, and then call the set_termios function. The
> driver should be prohibited from looking at how the the baud rate came
> to be 9600, and attempt to approach the requested baud rate as good as
> possible. It might return a flag somewhere: Not exact. In the example
> above, the resulting baud rate is about 1.4 baud off: 9598.6. This is
> not a problem in very many cases.
>
> Once this is in place, you lose a lot of "figure out the baud rate
> integer from the B_xxx settings" code in all the drivers, as well as
> that we get to provide a new interface to userspace without having to
> change ALL drivers at the same time. This decouples the drivers from
> the kernel<->userspace interface.

I'll second the motion. :-)

..Stu

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
Ar Llu, 2006-08-28 am 08:17 -0400, ysgrifennodd linux-os (Dick Johnson):
> On Sat, 26 Aug 2006 linux@horizon.com wrote:
>
> >> Or we could just add a standardised extra set of speed ioctls, but then
> >> we need to decide what occurs if I set the speed and then issue a
> >> termios call - does it override or not.
> >
> > Actually, we're not QUITE out of bits. CBAUDEX | B0 is not taken.
>
> B0 is not a bit (there are no bits in 0). It won't work.

Well that is how it is implemented and everyone else seems happy. If it
violates your personal laws of physics you'll just have to cope.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Mon, 28 Aug 2006, Alan Cox wrote:

> Ar Llu, 2006-08-28 am 08:17 -0400, ysgrifennodd linux-os (Dick Johnson):
>> On Sat, 26 Aug 2006 linux@horizon.com wrote:
>>
>>>> Or we could just add a standardised extra set of speed ioctls, but then
>>>> we need to decide what occurs if I set the speed and then issue a
>>>> termios call - does it override or not.
>>>
>>> Actually, we're not QUITE out of bits. CBAUDEX | B0 is not taken.
>>
>> B0 is not a bit (there are no bits in 0). It won't work.
>
> Well that is how it is implemented and everyone else seems happy. If it
> violates your personal laws of physics you'll just have to cope.

It has nothing to do with 'personal laws of physics'. On all recent
implementations, B0 is 0, i.e., the absence of any bits set. Therefore,
there is no observable difference between CBAUDEX and CBAUDEX | B0,
as shown above. Therefore, as I stated, it won't work.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.24 on an i686 machine (5592.62 BogoMips).
New book: http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
linux-os \(Dick Johnson\) writes:

> On Mon, 28 Aug 2006, Alan Cox wrote:
>
>> Ar Llu, 2006-08-28 am 08:17 -0400, ysgrifennodd linux-os (Dick Johnson):
>>> On Sat, 26 Aug 2006 linux@horizon.com wrote:
>>>
>>>>> Or we could just add a standardised extra set of speed ioctls, but then
>>>>> we need to decide what occurs if I set the speed and then issue a
>>>>> termios call - does it override or not.
>>>>
>>>> Actually, we're not QUITE out of bits. CBAUDEX | B0 is not taken.
>>>
>>> B0 is not a bit (there are no bits in 0). It won't work.
>>
>> Well that is how it is implemented and everyone else seems happy. If it
>> violates your personal laws of physics you'll just have to cope.
>
> It has nothing to do with 'personal laws of physics'. On all recent
> implementations, B0 is 0, i.e., the absence of any bits set. Therefore,
> there is no observable difference between CBAUDEX and CBAUDEX | B0,
> as shown above. Therefore, as I stated, it won't work.

What baud rate does your system define CBAUDEX | B0 to be? On my
AMD64 machine, both the x86-64 and i386 asm/termbits.h files skip
CBAUDEX -- B38400 is 0000017 and B57600 is 0010001 (CBAUDEX | B50).
The headers do not define any baud rate between those two, either by
rate or by c_cflag value.

Michael Poole
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Mon, 28 Aug 2006, Michael Poole wrote:

> linux-os \(Dick Johnson\) writes:
>
>> On Mon, 28 Aug 2006, Alan Cox wrote:
>>
>>> Ar Llu, 2006-08-28 am 08:17 -0400, ysgrifennodd linux-os (Dick Johnson):
>>>> On Sat, 26 Aug 2006 linux@horizon.com wrote:
>>>>
>>>>>> Or we could just add a standardised extra set of speed ioctls, but then
>>>>>> we need to decide what occurs if I set the speed and then issue a
>>>>>> termios call - does it override or not.
>>>>>
>>>>> Actually, we're not QUITE out of bits. CBAUDEX | B0 is not taken.
>>>>
>>>> B0 is not a bit (there are no bits in 0). It won't work.
>>>
>>> Well that is how it is implemented and everyone else seems happy. If it
>>> violates your personal laws of physics you'll just have to cope.
>>
>> It has nothing to do with 'personal laws of physics'. On all recent
>> implementations, B0 is 0, i.e., the absence of any bits set. Therefore,
>> there is no observable difference between CBAUDEX and CBAUDEX | B0,
>> as shown above. Therefore, as I stated, it won't work.
>
> What baud rate does your system define CBAUDEX | B0 to be? On my

B0 is 0 (zero), no bits. If you are trying to play semantic games and
claim B0 is 1, i.e., bit 0, then it would not be written as B0, it
would be written as B(0) or B:0. B0 is defined to be the baud-rate
used to hang up the modem. It is zero in all bits on most all
implementations including my Sun. On most recent Linux distributions,
CBAUDEX is (octal) 0010000. Since B0 is zero, ORing it into CBAUDEX
does nothing.

> AMD64 machine, both the x86-64 and i386 asm/termbits.h files skip
> CBAUDEX -- B38400 is 0000017 and B57600 is 0010001 (CBAUDEX | B50).
> The headers do not define any baud rate between those two, either by
> rate or by c_cflag value.
>
> Michael Poole
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.24 on an i686 machine (5592.62 BogoMips).
New book: http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
Ar Llu, 2006-08-28 am 10:50 -0400, ysgrifennodd linux-os (Dick Johnson):
> It has nothing to do with 'personal laws of physics'. On all recent
> implementations, B0 is 0, i.e., the absence of any bits set. Therefore,
> there is no observable difference between CBAUDEX and CBAUDEX | B0,
> as shown above.

Correct

> Therefore, as I stated, it won't work.

Incorrect


The state

(flag & CBAUD) == (CBAUDEX|0)

is not currently used

CBAUDEX|1 .. CBAUDX|15 are used as are 0-15.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
> The state
>
> (flag & CBAUD) == (CBAUDEX|0)
>
> is not currently used
>
> CBAUDEX|1 .. CBAUDX|15 are used as are 0-15.

a) thank you; I've been wondering why so many people seem unable to see
the obvious.

b) I should mention, on the Alpha, CBAUDEX is defined as 0, and the used
states are 0..30, so the spare state is 31

But again, there *is* a spare state that can be used when a custom
baud rate is queried via the backward-compatible inerface.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
linux-os \(Dick Johnson\) writes:

> On Mon, 28 Aug 2006, Michael Poole wrote:
>
>> What baud rate does your system define CBAUDEX | B0 to be? On my
>
> B0 is 0 (zero), no bits. If you are trying to play semantic games and
> claim B0 is 1, i.e., bit 0, then it would not be written as B0, it
> would be written as B(0) or B:0. B0 is defined to be the baud-rate
> used to hang up the modem. It is zero in all bits on most all
> implementations including my Sun. On most recent Linux distributions,
> CBAUDEX is (octal) 0010000. Since B0 is zero, ORing it into CBAUDEX
> does nothing.

Thanks, Sherlock! Again: What does CBAUDEX, by itself, do on your
system? As Alan Cox obviously thought the rest of the world was
bright enough to notice, and as I tried to explain, the CBAUDEX bit is
currently not defined when set by itself (i.e. as if it were CBAUDEX,
CBAUDEX | B0, CBAUDEX << 0 or however else you want to denote it);
there is always some other low-order (CBAUD) bit associated with it:

>> AMD64 machine, both the x86-64 and i386 asm/termbits.h files skip
>> CBAUDEX -- B38400 is 0000017 and B57600 is 0010001 (CBAUDEX | B50).
>> The headers do not define any baud rate between those two, either by
>> rate or by c_cflag value.

Michael Poole
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Mon, 28 Aug 2006, Michael Poole wrote:

> linux-os \(Dick Johnson\) writes:
>
>> On Mon, 28 Aug 2006, Michael Poole wrote:
>>
>>> What baud rate does your system define CBAUDEX | B0 to be? On my
>>
>> B0 is 0 (zero), no bits. If you are trying to play semantic games and
>> claim B0 is 1, i.e., bit 0, then it would not be written as B0, it
>> would be written as B(0) or B:0. B0 is defined to be the baud-rate
>> used to hang up the modem. It is zero in all bits on most all
>> implementations including my Sun. On most recent Linux distributions,
>> CBAUDEX is (octal) 0010000. Since B0 is zero, ORing it into CBAUDEX
>> does nothing.
>
> Thanks, Sherlock! Again: What does CBAUDEX, by itself, do on your
> system? As Alan Cox obviously thought the rest of the world was
> bright enough to notice, and as I tried to explain, the CBAUDEX bit is
> currently not defined when set by itself (i.e. as if it were CBAUDEX,
> CBAUDEX | B0, CBAUDEX << 0 or however else you want to denote it);
> there is always some other low-order (CBAUD) bit associated with it:
>

Certainly CBAUDEX does not represent a baud-rate itself. It is
a bit that is used to extend the baud-rate setting from the values
that could fit within the (CBAUD & ~CBAUDEX) mask so B50 through
B38400 could become B57600 through B4000000 when this bit is set.

The confusion arises when you use B0 in your argument. CBAUDEX was
the relevant bit, sufficiently defined, without adding a non-existent
bit.

I am sensitive to 'B0' because any new implementation must also
provide for its functionality. There still are modem-controlled
or connected devices that need to secure a line by hanging up.

>>> AMD64 machine, both the x86-64 and i386 asm/termbits.h files skip
>>> CBAUDEX -- B38400 is 0000017 and B57600 is 0010001 (CBAUDEX | B50).
>>> The headers do not define any baud rate between those two, either by
>>> rate or by c_cflag value.
>
> Michael Poole
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.24 on an i686 machine (5592.62 BogoMips).
New book: http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Mon, Aug 28, 2006 at 10:14:30AM -0400, Stuart MacDonald wrote:
> From: On Behalf Of Rogier Wolff
> > Note that IMHO, we should have started hiding this mess from /drivers/
> > a long time ago. The tty layer should convert the B_9600 thingies to
> > "9600", the integer, and then call the set_termios function. The
> > driver should be prohibited from looking at how the the baud rate came
> > to be 9600, and attempt to approach the requested baud rate as good as
> > possible. It might return a flag somewhere: Not exact. In the example
> > above, the resulting baud rate is about 1.4 baud off: 9598.6. This is
> > not a problem in very many cases.
> >
> > Once this is in place, you lose a lot of "figure out the baud rate
> > integer from the B_xxx settings" code in all the drivers, as well as
> > that we get to provide a new interface to userspace without having to
> > change ALL drivers at the same time. This decouples the drivers from
> > the kernel<->userspace interface.
>
> I'll second the motion. :-)

You might do, but it's incompatible with the POSIX standard. As I
explained to Rogier (he took it off list) there's no need for "inexact"
flags.

If we pass a baud rate via tcsetattr() (or ioctl), you should set what
ever settings you can. If you can set _no_ settings, you return an
error. If you can set at least one setting, you do not return an error,
and you only set those settings you can do.

When you subsequently read the settings via tcgetattr(), POSIX requires
that the returned information be what the port is _actually_ doing.

So, this means that if you can only do 9599 baud and not 9600 baud,
maybe you should be returning 9599 baud.

On the same subject, if you don't support RTS/CTS flow control, and
userland requests CRTSCTS, you shouldn't be allowing CRTSCTS to be set.
And indeed, if you don't allow that in the kernel today, stty will
correctly issue a warning that it was "unable to perform all requested
operations".

So, while I whole heartedly agree with passing baud rates numerically,
I do not think we need any of this inexact flagging nonsense provided
we implement something as userland programs expect - iow, the POSIX
behaviour.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Mon, Aug 28, 2006 at 09:09:18PM +0100, Russell King wrote:

> So, while I whole heartedly agree with passing baud rates
> numerically, I do not think we need any of this inexact flagging
> nonsense provided we implement something as userland programs expect
> - iow, the POSIX behaviour.

I fully agree we should implement Posix behaviour. Wether that specifies
what userland programmers expect is where I disagree.

If you happen to change RTS/CTS at the same time as you change baud,
the call will return succes, even though the most important part (for
you) of your call failed. Note that if the succes of the call depends
on the previous state of RTS/CTS. Thus the error will depend on
whatever happened before. This creates difficult-to-diagnose problems
for sysadmins.

Anyway, this would not happen if the programmer had read the full text
of the POSIX spec. IMHO, most programmers have a good idea of the
filosopy, and program against that: If some call fails it returns
error.

Anyway, here I am again rambling against the Posix spec. But again:
we should implement POSIX as good as we can. Alan already did the
most important footwork. Good job!

Roger.

--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement.
Does it sit on the couch all day? Is it unemployed? Please be specific!
Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Serial custom speed deprecated? [ In reply to ]
On Tue, Aug 29, 2006 at 08:20:49AM +0200, Rogier Wolff wrote:
> On Mon, Aug 28, 2006 at 09:09:18PM +0100, Russell King wrote:
> > So, while I whole heartedly agree with passing baud rates
> > numerically, I do not think we need any of this inexact flagging
> > nonsense provided we implement something as userland programs expect
> > - iow, the POSIX behaviour.
>
> I fully agree we should implement Posix behaviour. Wether that specifies
> what userland programmers expect is where I disagree.
>
> If you happen to change RTS/CTS at the same time as you change baud,
> the call will return succes, even though the most important part (for
> you) of your call failed. Note that if the succes of the call depends
> on the previous state of RTS/CTS. Thus the error will depend on
> whatever happened before. This creates difficult-to-diagnose problems
> for sysadmins.

I disagree. POSIX recommends the following sequence when setting termios
modes:

tcgetattr(fd, &termios);
/* modify termios */
if (tcsetattr(fd, &termios) == -1)
/* whatever error handling, none of the modes worked */
tcgetattr(fd, &real_termios);

and in that respect it's the classic negotiation between two differing
sets of code - the application asks for what it wants, and then requests
what it actually got. It can then check real_termios to see if the
settings it actually got are compatible with what it wants to achieve.

For example, if it couldn't enable CRTSCTS, it might decide to use XON/
XOFF flow control instead.

If tcsetattr() were to return an error if _any_ mode failed, then you
wouldn't know if it failed because CRTSCTS wasn't supported, or the
baud rate, or maybe some other mode you asked for. That's multiple
times worse, and it would actually result in lots of programs failing
just because one setting wasn't supported - and will result in more
sysadmins scratching their collective heads.

So, the key idea here is that fiddling with termios is a _negotiation_
between the application and the driver.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

1 2  View All