Skip site navigation (1)Skip section navigation (2)
Date:      06 Aug 2003 12:14:42 +0100
From:      Rui Lopes <rui@ruilopes.com>
To:        "J. Seth Henry" <jshamlet@comcast.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: FreeBSD programming question
Message-ID:  <1060168481.655.23.camel@localhost>
In-Reply-To: <1060119004.53095.25.camel@alexandria>
References:  <1060119004.53095.25.camel@alexandria>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1060168481.655.23.camel>