[ale] Configure serial port settings at boot

Chris Fowler cfowler at outpostsentinel.com
Sat Dec 6 12:06:57 EST 2014


Set the port in raw mode and then dump that out. 

stty -gF /dev/ttyS0 

In /etc/rc.local apply those settings 

stty -F /dev/ttyS0 XXXXX 

The g option will dump the settings in a form that can be used to set the settings. 

cfowler at cfowler-desktop:/tmp$ stty -gF /dev/ttyS0 
0:0:80001cb1:0:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 
cfowler at cfowler-desktop:/tmp$ 

Note that proper behavior of programs is to set the tty back to the way they found it. Other programs may change your settings and not set them back. 
If this concerns you then you can write a cron job that would apply settings if there is no /var/lock/LCK..ttySO. 

I sense you are using a script that writes to the port, but has no intelligence to set termios. If so, you could simply do this: 

OLD_TERM=`stty -gF /dev/ttyS0`; 
# Set what I want 
stty -F /dev/ttyS0 XXXXX 
# Now reset back to orig 
stty -F /dev/ttyS0 ${OLD_TERM} 
# Exit 
exit 0 

----- Original Message -----

> From: "Alex Carver" <agcarver+ale at acarver.net>
> To: "Atlanta Linux Enthusiasts" <ale at ale.org>
> Sent: Friday, December 5, 2014 8:32:35 PM
> Subject: [ale] Configure serial port settings at boot

> Does anyone happen to know if there's a way to set up the default state
> of a serial port at boot? I want to switch the port into raw mode
> instead of cooked. When everything is running I just use "stty -F
> /dev/ttyS0 raw" but that will not survive a reboot.

> setserial as far as I can tell only handles the base configuration
> (address, IRQ, etc.)
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20141206/0f3415f9/attachment.html>


More information about the Ale mailing list