From owner-freebsd-questions@FreeBSD.ORG Wed Aug 6 04:11:54 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4BD7137B401 for ; Wed, 6 Aug 2003 04:11:54 -0700 (PDT) Received: from ns.webtt.biz (ns.webtt.biz [64.239.29.225]) by mx1.FreeBSD.org (Postfix) with SMTP id 3002343F3F for ; Wed, 6 Aug 2003 04:11:53 -0700 (PDT) (envelope-from rui@ruilopes.com) Received: (qmail 61717 invoked from network); 6 Aug 2003 11:14:06 -0000 Received: from unknown (HELO ?217.129.149.167?) (rui@ruilopes.com@217.129.149.167) by ns.webtt.biz with SMTP; 6 Aug 2003 11:14:06 -0000 From: Rui Lopes To: "J. Seth Henry" In-Reply-To: <1060119004.53095.25.camel@alexandria> References: <1060119004.53095.25.camel@alexandria> Content-Type: text/plain Message-Id: <1060168481.655.23.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.3 Date: 06 Aug 2003 12:14:42 +0100 Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: FreeBSD programming question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Aug 2003 11:11:54 -0000 On Ter, 2003-08-05 at 22:30, J. Seth Henry wrote: > Not sure if this is the right list or not, but I could really use some > pointers. > > How can I code trap serial port interrupts in my C program? You can't attach to interrupts in a userland program, but you can access serial ports by opening any of /dev/cuaaX device files. > For example, I want to read values from a serial device every > user-specified number of seconds, calculate some stuff and then sit for > a while. Should the serial device decide it wants to send some data > unsolicited, I would like to enter an interrupt service routine, handle > the communication, and then return to the previous loop. > > I can get the loop going by using sleep(n), but I don't know how to > write the ISR in C, and (additionally) make it such that it will run on > any *nix like platform. > > Any pointers, HOWTO's, or examples would be greatly appreciated! Take a look at these (in no particular order): - http://www.easysw.com/~mike/serial/ "Serial Programming Guide for POSIX Operating Systems" - http://en.tldp.org/HOWTO/Serial-Programming-HOWTO/index.html "Serial Programming HOWTO" - http://www.freebsd.org/handbook/serialcomms.html "Serial Communications" - sio(4) Good luck! Rui Lopes