serial port question

Gary Jennejohn garyj at jennejohn.org
Sun Oct 2 03:49:41 PDT 2005


Divacky Roman writes:
> Hi,
> 
> I need to set serial port to given parity/speed/etc. and then cat from it...
> 
> when I: stty -f /dev/cuaa0 speed 1200
> its still at 9600 (the default setting)
> 
> how do I alter speed of serial port? minicom/cu is able to do it but I want t
> o
> do it via stty.
> 
> how can this be done?
> 

See discussion of the initial-state and lock-state devices in the sio
manual page.

Another, hacky way to do it is like this:

sleep 1000 < /dev/cuaa0&
stty -f /dev/cuaa0 speed 1200

The sleep holds the device open so that the values set using stty remain
effective. Without the sleep the stty values are only effective while
the command is being executed because stty opens the device and then,
once stty exits, the device is closed and all the new settings are lost.

---
Gary Jennejohn / garyjATjennejohnDOTorg gjATfreebsdDOTorg garyjATdenxDOTde



More information about the freebsd-hackers mailing list