On Sun, 23 Mar 2014 16:32:12 EDT erik quanstrom <[email protected]> wrote:
> On Sun Mar 23 15:56:52 EDT 2014, [email protected] wrote:
> > On Sun, Mar 23, 2014 at 8:47 PM, Gorka Guardiola <[email protected]> wrote:
> >
> > >
> > > if(!setonce){
> > > setonce = 1;
> > > serialctl(p, "l8 i1"); /* default line parameters */
> > > }
> >
> > And setonce needs to live in the interface, and it needs to be locked, etc.
>
> another idea: since this is only needed by some hardware. and then only in i
> nit.
> why not make it the responsibility of such hardware to do this in the init
> fn. then the problem can be addressed without any special cases like
> !setonce.
On FreeBSD:
The sio driver also supports an initial-state and a lock-state control
device for each of the callin and the callout "data" devices. The
termios settings of a data device are copied from those of the corre-
sponding initial-state device on first opens and are not inherited from
previous opens. Use stty(1) in the normal way on the initial-state
devices to program initial termios states suitable for your setup.
A similar idea here would be to have a "default" command to
for default settings. When a device is opened, it is
initialized with these settings. The reason I like this is
because then I don't need to teach every serial IO program
what setting to use (often the other end is a dumb device
requiring its own fixed and peculiar settings).