[ale] Configure serial port settings at boot

Alex Carver agcarver+ale at acarver.net
Sat Dec 6 17:17:56 EST 2014


Ok, thanks to Jim, JD and Chris, rc.local appears to be the way to go
and is relatively easy.

I'm not using a script.  This is for lpd with a label printer attached
to the serial port so technically the port is always in use.  The
problem is that a cooked mode serial port will eat some of the bitmap
data and cause much confusion for the printer when its bitmap suddenly
vanishes.  Eight bit raw mode is all the printer needs to make sure the
labels print properly.  I can't configure the port within lpd other than
the baud rate so I have to change the mode externally with stty.

On 2014-12-06 09:06, Chris Fowler wrote:
> 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
> 
> 
> 
> _______________________________________________
> 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
> 



More information about the Ale mailing list