From owner-freebsd-hackers Mon Nov 11 15: 9:12 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3791437B401 for ; Mon, 11 Nov 2002 15:09:11 -0800 (PST) Received: from conure.mail.pas.earthlink.net (conure.mail.pas.earthlink.net [207.217.120.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id CAF8543E3B for ; Mon, 11 Nov 2002 15:09:10 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0108.cvx40-bradley.dialup.earthlink.net ([216.244.42.108] helo=mindspring.com) by conure.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 18BNff-0002oO-00; Mon, 11 Nov 2002 15:08:43 -0800 Message-ID: <3DD0382E.2C531F72@mindspring.com> Date: Mon, 11 Nov 2002 15:07:26 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: the evil toor Cc: freebsd-hackers@freebsd.org Subject: Re: sio howto References: <20021111171109.P13478-100000@x12.dk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG the evil toor wrote: > I just followed the recent sio thread, but it did not answer my questions. > I have a program that needs to set RTS and DTR and then later set them > again and again.. I could go for the open /dev/io and then the IO adr of > the serial port.. but as far as i've seen it would lock up the kernel, but > is there a good way to this? DTR is set when you open the port. It is reset on last close. RTS is set when the low receive buffer is empty/below the low watermark, and reset when it is full/above the high watermark; RTS follows DTR on open/close (i.e. it is not asserted unless th port is open). To directly control RTS, you must disable CTS/RTS flow control, which is on by defaults (see the "XXX" comment at ~ line 2286 in /sys/isa/sio.c). Assuming you have done this, you may control it using TIOCMSET, a "Terminal I/O Control", using ioctl(). Assuming the port is open, you can control DTR via TIOCSDTR; this assumes you can live with DTR coming high between the time you open the port, and the time you disable it. The same is true of RTS, which follow DTR at initial open, as the default state of the device. There are no protections against RTS state changes when input hardware flow control is enabled: that is, if you have input flow control enabled, and are above the low watermark, and you disable RTS, when the pending data causes the buffer to drop below the low watermark, RTS will be reasserted automatically (this is analogous to trying to use the loop control variable for temporary storage in a "for.." loop). See the serial driver source code for details. If you want to be useful, you can force an interlock on the CTS/RTS behaviour, and hardware flow control state, and add device flags which may be specified on the device in the kernel to control the initial state of these attributes on the device, if it is not open or initialized (e.g. so that they don't go high the moment you open the device, by default). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message