Path: utzoo!attcan!uunet!van-bc!sl From: sl@van-bc.UUCP (pri=-10 Stuart Lynne) Newsgroups: comp.dcom.modems Subject: Re: Solution to Problems with UUCP/modems. Keywords: modems ACU driver Message-ID: <1876@van-bc.UUCP> Date: 16 Sep 88 07:15:44 GMT References: <14170@comp.vuw.ac.nz> <323@uncle.UUCP> <37899@pyramid.pyramid.com> <324@telly.UUCP> <310@impch.UUCP> <1260@moscom.UUCP> Reply-To: sl@van-bc.UUCP (pri=-10 Stuart Lynne) Organization: Wimsey Associates, Vancouver, BC. Lines: 127 In article <1260@moscom.UUCP> jgp@moscom.UUCP (Jim Prescott) writes: >In article <310@impch.UUCP> boxdiger@impch.UUCP (Patrick Guelat) writes: >>In article <324@telly.UUCP> evan@telly.UUCP (Evan Leibovitch) writes: >>% In article <37899@pyramid.pyramid.com>, csg@pyramid.pyramid.com (Carl S. Gutekunst) writes: >>%> Standard OSx does not provide acucntrl. The 4.3BSD version is highly VAX... >>% There is also a System V acucntrl which does the same thing, but not as >>% .... >There sure are a lot of complex solutions that perform the same function >as the so called Sun hacks which work as follows: > - a modem gets 2 names, /dev/ttyd0 (for getty) and /dev/cua0 (for > dialout with uucp, kermit, tip or whatever). > - an open on ttyd0 blocks until DCD gets raised. getty spends > most of it's life waiting for someone to call in and raise > DCD so it can complete the open. > - an open on cua0 succeeds without DCD > - the kernel ensures that only 1 of ttyd0 and cua0 can be open at > the same time. If someone is logged in then an open of cua0 > fails. If cua0 gets opened by someone then getty won't see > DCD until cua0 gets closed. > >This isolates all the changes in the tty driver. No changes to any programs >are required and it works with both modems and direct connections. The only >disadvantage that I've heard about it is that since it can be done in user >mode it shouldn't be in the kernel. Since it came with our 9/84 release >of HCR V7 for a pdp-11 I don't think that it can add all that much code. > What I do is define *three* virtual devices for each serial port, for local, modem and getty use. Each has their own name and minor device for example: mknod tty0al c 0 0 mknod tty0am c 0 128 mknod tty0ag c 0 192 You simply treat each of these as a separate physical device when doing your configuration. I.e. you make entries in inittab for tty0ag if you have an incoming modem and L-devices for tty0am for dialing out. When something attempts to use the device the driver simply ensures that some simple rules are followed to prevent more than one virtual device accessing the physical device at a time. These changes are fairly easy to add to a serial driver, and can be encapsulated into about three different procedures that are called from the serial open and close routines. The following rules work well. They seem to work well and allow a wide variation of standard unix software to work well. I.e. cu, uucico, getty. A few variations such as forcing HUPCL and not allowing CLOCAL for the getty devices help keep your system a bit more secure. I havn't figured out what to use the last set of minor device numbers for (64-127) but one suggestion is to support a printer attached to a terminal on that port. Local Virtual Device (LVD) ========================== The LVD is generally used for direct connect terminals, where you do not want the line to disconnect when if it is unplugged, or if you wish to use a three wire (GND, TD, RD) connection. - an LVD cannot be opened if the MVD is open or waiting to open; or if the GVD is open. - CLOCAL and CARR_ON are set for each successful open (i.e. a second open will set them again). - CLOCAL can be turned of enabling the use of modem controls. Modem Virtual Device (MVD) ========================== The MVD is generally used with any device which supports modem controls, and when you have software which can utilize the signals appropriately. - a MVD cannot be opened if the LVD is open or waiting to open; or if the GVD is open. - when opened a MVD will wait for carrier if FNDELAY is specified. - CLOCAL can be turned on to disable the use of modem controls. Getty Virtual Device (GVD) ========================== The GVD is designed specifically to allow a modem to be used for both incoming and outgoing calls without having to disable / enable the getty waiting for incoming calls. It does this by only allowing the getty to wake up for carrier when no other virtual device is open and wants to respond to the carrier. - when opened a GVD will always wait for carrier, even if the LVD or MVD is open, or the MVD is waiting for carrier. - CLOCAL is not allowed to be set for a GVD. - HUPCL is not allowed to be reset for a GVD. - a GVD waits two seconds after seeing carrier, checks that no other virtual device completed an open, flush's the incoming data before completing the open. - a GVD will wait two seconds, re-init the serial chip and raise DTR after a different virtual device closes and drops DTR if waiting for carrier. Carrier Detect ============== Changes in Carrier Detect are monitored iff a virtual device is open, waiting to open (MVD or GVD) and CLOCAL is not set. If Carrier is lost then the drivers buffers are flushed and a SIGHUP signal is sent to the process group which opened the device regardless of what type of virtual device is open (if CLOCAL is not set). If Carrier becomes true, any processes waiting for carrier are restarted (usually a MVD or GVD waiting to open). Error Codes =========== ENXIO invalid channel, no serial device associated with this minor device. EBUSY all ready open with XCLUDE flag, or different virtual device -- Stuart.Lynne@wimsey.bc.ca {ubc-cs,uunet}!van-bc!sl Vancouver,BC,604-937-7532