Not able to change baud rate

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi all,

I have a video streaming device running Linux. when i change the baud
rate using the 'stty' command,it changes temporarily for few seconds.
Then again it changes to 115200 automatically.

Please find below the /etc/inittab file & the /etc/init.d/rcS file for
reference.

inittab:
######

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:3:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let
this work."

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# This line provides a nice out-of-box experience.  For regular use,
you
# should replace it with the proper getty lines below.
con:2345:respawn:/sbin/getty console
#ttyS1::respawn:-/bin/sh


# /sbin/getty invocations for the runlevels.
#
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  <id>:<runlevels>:<action>:<process>
#
# Uncomment these for a devfs system
#
#1:2345:respawn:/sbin/getty 38400 vc/1
#2:23:respawn:/sbin/getty 38400 vc/2
#3:23:respawn:/sbin/getty 38400 vc/3
#4:23:respawn:/sbin/getty 38400 vc/4
#5:23:respawn:/sbin/getty 38400 vc/5
#6:23:respawn:/sbin/getty 38400 vc/6
#
# Uncomment these only for non-devfs systems
#
#1:2345:respawn:/sbin/getty 38400 tty1
#2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
# Uncomment these for a devfs system
#
#T0:23:respawn:/sbin/getty -L tts/0 9600 vt100
#T1:23:respawn:/sbin/getty -L tts/1 9600 vt100
#
# Uncomment these only for non-devfs systems
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
#
# Uncomment this for a devfs system
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 tts/3
#
# Uncomment these only for non-devfs systems
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3

rcS
####

#! /bin/sh
#
# rcS        Call all S??* scripts in /etc/rcS.d in
#        numerical/alphabetical order.
#
# Version:    @(#)/etc/init.d/rcS  2.76  19-Apr-1999   snipped-for-privacy@cistron.nl
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel

#
#    See if system needs to be setup. This is ONLY meant to
#    be used for the initial setup after a fresh installation!
#
if [ -x /sbin/unconfigured.sh ]
then
  /sbin/unconfigured.sh
fi

#
#    Source defaults.
#
. /etc/default/rcS
export VERBOSE

#
#    Trap CTRL-C &c only in this shell so we can interrupt subprocesses.
#
trap ":" INT QUIT TSTP

#
#    Call all parts in order.
#
for i in /etc/rc.d/rcS.d/S??*
do
    # Ignore dangling symlinks for now.
    [ ! -f "$i" ] && continue

    case "$i" in
        *.sh)
            # Source shell script for speed.
            (
                trap - INT QUIT TSTP
                set start
                . $i
            )
            ;;
        *)
            # No sh extension, so fork subprocess.
            $i start
            ;;
    esac
done

#      Run /etc/rc.d/rc.local if it exists
[ -x /etc/rc.d/rc.local ] && /etc/rc.d/rc.local

#
#    Finish setup if needed. The comment above about
#    /sbin/unconfigured.sh applies here as well!
#
if [ -x /sbin/setup.sh ]
then
  /sbin/setup.sh
fi

DVEVMDIR=/opt/ipnc

ifconfig lo 127.0.0.1

# Load the dsplink and cmem kernel modules
cd $DVEVMDIR
$DVEVMDIR/loadmodules_ipnc.sh

# Start the demo application
cd $DVEVMDIR
$DVEVMDIR/autorun.sh



Re: Not able to change baud rate
Quoted text here. Click to load it

I don't see the 'stty' line you're asking about.

It cannot be in a subshell since those file descriptors
all vanish when it terminates.

Perhaps it ought to be directed to work on the file descriptor,
such as STDERR
    stty <&2
since that's not normally redirected like STDIN or STDOUT
and group the commands in a subshell like this
    (stty foo bar <&2;cmd1 ;cmd2)

I hope that's the trick, I can't quite remember.

Re: Not able to change baud rate

Quoted text here. Click to load it

No, we've alaready been over this: it doesn't matter.  Baud rate
changes are persistent in Linux using the standard serial port driver.
Baud rate is a device setting.  The device doesn't go away when the
file descriptor is closed.  The device settings persist.

Here's what you do in one terminal window:

$ stty -F /dev/ttyS0
speed 9600 baud; line = 0;
-brkint -imaxbel

$ stty -F /dev/ttyS0 115200

$ stty -F /dev/ttyS0      
speed 115200 baud; line = 0;
-brkint -imaxbel

close that window and open a new one:

$ stty -F /dev/ttyS0
speed 115200 baud; line = 0;
-brkint -imaxbel

set the baud rate in a subshell:

$ (stty -F /dev/ttyS0 4800)

and it's still there in the parent shell.

$ stty -F /dev/ttyS0
speed 4800 baud; line = 0;
-brkint -imaxbel

Quoted text here. Click to load it

It's easier to just using -F.

If you need to keep DTR from toggling, between programs _that_ is when
you need to hold the device open between programs:

(cmd1; cmd2; cmd3) </dev/ttyS0 >/dev/ttyS0

--
Grant




Site Timeline