/* wake.c - Sample program to wake the TCM2 after is has been put in sleep mode */
/* Wake toggles the RTS line to give the TCM2 a (falling) edge */
/* P Milford 1/10/96 */

/* Usage:  wake 1  - wakes a tcm2 on com port 1 (default) */
/* wake 2 - wakes a tcm2 on com port 2, etc. */

#include <stdio.h>
#include <stdlib.h>	/* for atoi */
#include <conio.h>	/* For inp/out */

/* Addresses in IO space of the serial port base addresses */

#define PORT1 0x3F8
#define PORT2 0x2F8
#define PORT3 0x3E8
#define PORT4 0x2E8

#define MCR 4			/* Offset to the Modem control register */
#define RTS 2			/* RTS is bit 2 of the MCR*/

int main(int argc, char *argv[])
{
int	tmp, port=PORT1;	/* Defaul to serial port 1 */

/* If there are args, look at the first one only */

	if(argc == 2) {		/* Figure out which serial port to use */
	  switch(atoi(argv[1])) {
	    case 1: port = PORT1; break;
	    case 2: port = PORT2; break;
	    case 3: port = PORT3; break;
	    case 4: port = PORT4; break;
	  others: port = PORT1;
	  };
	};
	tmp = inp(port+MCR);	/* Read current line status */
	outp(port+MCR, tmp ^ RTS);	/* Toggle the RTS line */
	outp(port+MCR, tmp);	/* Restore the RTS line */
return 0;
};
