Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!linus!decvax!harpo!seismo!hao!hplabs!sri-unix!cepu!scw@ucla-locus
From: scw%ucla-locus@cepu.UUCP
Newsgroups: net.unix
Subject: transmitting BREAK
Message-ID: <16810@sri-arpa.UUCP>
Date: Fri, 17-Feb-84 11:28:00 EST
Article-I.D.: sri-arpa.16810
Posted: Fri Feb 17 11:28:00 1984
Date-Received: Mon, 20-Feb-84 01:26:50 EST
Lines: 82

From:  Steve Woods 


	From:  RMark.MINITAB@denver
	>I am running Xenix on a TRS Model 16B.  There appears to be no stty
	>control call to send out a BREAK.   Anybody have any other ideas?
Here is some code that I put into our version of cu.c (we needed to
send break to talk to a IBM system . Note that you need to
be able to switch speeds on the line for this to work.  An 'official'
break is supposed to be 250 Milliseconds long  but almost any UART reports the same thing when it gets a
framing error (12 bit times with no stop bit).

**************near  the top (a discription)***********************
/*
 *	~Bn	uucico sytle break (at 150 baud send n(1) nulls)
 *	~b	same as ~B3
 *	~@	attempt a real break (1 null at 1/2 speed)
 */
***********further on (the actuall code)*****************
/* this is on a switch on the character after the '~'*/
		case '@':
			{
			    int speed,stat,newspeed;
			    struct sgttyb stbuf;
			    struct sgttyb *st;
			    st = &stbuf;
			    ioctl(ln,TIOCGETP,st);
			    speed=stbuf.sg_ispeed; 
			    switch(speed){
				case B9600:
				case B4800:
				case B1200:
				case B600:
					newspeed= speed-1;
					break;
				default:
					newspeed = speed-2;
					break;
			    }
			    stbuf.sg_ispeed=stbuf.sg_ospeed=newspeed;
			    ioctl( ln,TIOCSETP, st);
			    write(ln,"\0",1);
			    stbuf.sg_ispeed=stbuf.sg_ospeed = speed;
			    ioctl( ln,TIOCSETP, st);
			}
			break;

		case 'B':
		case 'b':
			/* do a uucico style break 
			 * 'B' at 150 baud 1 null
			 *     or if Bn n nulls
			 * 'b' at 150 baud 3 null (real uucico style).
			 */
			{
			    int speed,stat,newspeed,nbreaks;
			    struct sgttyb stbuf;
			    struct sgttyb *st;
			    st = &stbuf;
			    ioctl(ln,TIOCGETP,st);
			    speed=stbuf.sg_ispeed; 
			    newspeed=B150;
			    if( b[1] == 'B'){
				if(b[2] > '0' && b[2] <= '9')nbreaks=b[2]-'0';
				else nbreaks=1;
			    }
			    else nbreaks=3;
			    stbuf.sg_ispeed=stbuf.sg_ospeed=newspeed;
			    ioctl( ln,TIOCSETP, st);
			    write(ln,"\0\0\0\0\0\0\0\0\0",nbreaks);
			    stbuf.sg_ispeed=stbuf.sg_ospeed = speed;
			    ioctl( ln,TIOCSETP, st);
			}
			break;

The switch on the sg_ispeed depends on the 'standard' available speeds
and values for them being in the standard order.
--
Stephen C. Woods (VA Wadsworth Med Ctr./UCLA Dept. of Neurology)
uucp:	...{ hao, trwrb, sdcsvax!bmcg}!cepu!scw   ARPA: cepu!scw@ucla-locus
location: N 34 06'37" W 118 25'43"