*BSD News Article 3351


Return to BSD News archive

Path: sserve!manuel!munnari.oz.au!mips!mips!sdd.hp.com!usc!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!agate!cgd
From: cgd@agate.berkeley.edu (Chris G. Demetriou)
Newsgroups: comp.unix.bsd
Subject: Re: com woes
Date: 11 Aug 92 22:57:35
Organization: Kernel Hackers 'r' Us
Lines: 74
Message-ID: <CGD.92Aug11225735@agate.berkeley.edu>
References: <1992Aug9.085755.6237@news.tu-graz.ac.at>
NNTP-Posting-Host: agate.berkeley.edu
In-reply-to: chmr@fstgds01.tu-graz.ac.at's message of Sun, 9 Aug 92 08:57:55 GMT

In article <1992Aug9.085755.6237@news.tu-graz.ac.at> chmr@fstgds01.tu-graz.ac.at (Christoph Robitschko) writes:
= I had the problem with select() not working on com ports. I got no
= response from a post regarding this one, so I started to look into it 
= myself. I found out that the com driver calculates unit = minor(dev) -1;

Yup, tis (sad but) true...  Bill Decided to make the serial driver
work this way to mollify the DOS-weinies who don't understand that
devices (in unix) are numbered starting at zero.  <sigh> (As you might be
able to tell, i don't really approve, but it doesn't really effect me,
because once my /etc/remote file is set up... 8-)

= This has the following implications:
=	/dev/com1 corresponds to COM0, /dev/com2 to COM1 (very confusing
=		in kernel messages)

actually, /dev/com1 corresponds to COM1, /dev/com2 corresponds to COM2...
(the COMn notation really should be reserved for the DOS devices...)
Yes, intenally /dev/com1 -> com0, and /dev/com2 -> com1... and that makes
the error messages "amusing".

=	It is incompatible with the config file entries com1 at..., com2 at...

Like i mentioned above -- i think it's silly to have unix devices numbered
starting at one... however, since "com1" in the config file corresponds
to /dev/com1, etc, i see no problem in that...  the prinfs have to be fixed
though...

=	Unpredictible results will occur if someone puts a com0 at.. in
=		his config file.

That's why you don't *DO* that 8-)  actually, if you put com0 in,
you'll end up with negative array indices in the driver... and that's
*bad*...

=	It is incompatible with the DOS usage of COM1, COM2 (But who cares 8-)

actually, this is the one place where you're not correct (as stated above).

=	ttselect() calculates unit = minor(dev), and uses this as an index in
=		com_tty. Because this index is different from that used
=		in the com driver, select() on /dev/com1 looks at
=		/dev/com2 and select() on /dev/com2 looks at an undefined
=		entry in com_tty and returns always true.

This, to me, is a good enough reason to change to the zero-based
notation... I'll put up a new version of my driver later this evening
which works that way...

= I include a patch to the stock 0.1 com driver. It simply corrects
= "unit = minor(dev) - 1" to "unit = minor(dev)"
= If you are running cgd's driver and you need select working (I don't think 
= this applies to many people, since I got NO response to my request), there
= is a *ugly* workaround: In the initialisation of cdevsw in
= /sys/i386/i386/conf.c, replace com_tty with (com_tty -1).
=
= To Chris Demetriou:  Please fix your driver. I could not do it because 
= I currently have no ftp connection to agate.

As i said above, will do...  Just as long as you don't try to blame me
for the original lunacy... 8-) (although "lunacy" would be better applied
to the SCSI driver... 8-)

= [ ... patch deleted ... ]
=
= As usual, use at your own risk.
=
=							Christoph

Chris
--
Chris G. Demetriou                                 cgd@agate.berkeley.edu

"Sometimes it is better to have twenty million instructions by
        Friday than twenty million instructions per second." -- Wes Clark