From mboxrd@z Thu Jan 1 00:00:00 1970 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-reply-to: Your message of "Sun, 23 Mar 2014 16:32:12 EDT." <590d4ca16a9d61afc0bdc6b4d16862af@brasstown.quanstro.net> References: <40707a306f2cb1caf97b21f639f8a9f5@brasstown.quanstro.net> <590d4ca16a9d61afc0bdc6b4d16862af@brasstown.quanstro.net> Date: Sun, 23 Mar 2014 14:32:08 -0700 From: Bakul Shah Message-Id: <20140323213208.A38E8B827@mail.bitblocks.com> Subject: Re: [9fans] usb/serial control open Topicbox-Message-UUID: cec1b308-ead8-11e9-9d60-3106f5b1d025 On Sun, 23 Mar 2014 16:32:12 EDT erik quanstrom wrote: > On Sun Mar 23 15:56:52 EDT 2014, paurea@gmail.com wrote: > > On Sun, Mar 23, 2014 at 8:47 PM, Gorka Guardiola 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).