[lug] A Big Red Switch...

Sean Reifschneider jafo at tummy.com
Thu Oct 28 21:07:36 MDT 1999

On Thu, Oct 28, 1999 at 08:00:20PM -0600, socket at peakpeak.com wrote:
>documentation for people familiar with C and the *concepts* of
>hardware I/O handling, so I could learn about creating a Linux
>handler (module, daemon, whatever) for a Big Red Switch?

Connect both BRSs to DTR and DCD.  Then you want a program which does
something like:

	#include <termios.h>
	#include <stdlib.h>
	#include <sys/types.h>
	#include <sys/stat.h>
	#include <fcntl.h>

	int fd = open("/dev/ttyS0", O_RDONLY), ret;
	int state;		//  0 if line is down, 1 if up

	state = 0;
	while (1) {
		ioctl(fd, TIOCMGET, &ret);
		if ((ret & TIOCM_CAR) && !state) {
			state = 0;
		if (!(ret & TIOCM_CAR) && state) {
			state = 1;

 It is far from clear whether "good intentions plus stupidity" or "evil
 intentions plus intelligence" have wrought more harm in the world.
                 --- Domer, The Logic of Failure
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
URL: <http://www.tummy.com/xvscan> HP-UX/Linux/FreeBSD/BSDOS scanning software.

More information about the LUG mailing list