1829109 Members
14018 Online
109986 Solutions
New Discussion

set speed tty

 
Luis Lino_1
Advisor

set speed tty

How can set speed to serial port to 9600, by stty commands?.

Thanks for your help

Luis Lino
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: set speed tty

stty 9600 < /dev/ttyXX
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: set speed tty

After looking at your other posting, what you proabaly want to do is actually disable the logins on the port(s) and yet open the port for communication. In that case, what you should do is edit /etc/inittab and replace your "respawn" with "off" for the desired port(s). You then issue an "init q" command to force a reconfiguration of init.

Now what you need is a command that will somehow open the port and keep it open after setting a desired baudrate. This process will not terminate (unless you do a kill -15 pid) so the port will remain open for use by other processes. It fork()'s and the parent process exit so no nohup or start in background is needed.

You compile it like this:
cc holdport.c -o holdport

You use it like this:
holdport -t /dev/ttyXX -s 9600

If you also need to issue additional stty commands, they can follow the holdport because the port is now open and the stty will not hang:

e.g.
stty cs8 -ixany < /dev/ttyXX

You can then send your characters to the port, thusly:

echo "\033[A\c" > /dev/ttyXX

If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: set speed tty

Oh, by the way, holdport.c is intentionally done in K&R C so that the Bundled C Compiler will handle it although it could be converted to ANSI syntax in about 2 minutes.
If it ain't broke, I can fix that.