transmitting BREAK

scw%ucla-locus at cepu.UUCP scw%ucla-locus at cepu.UUCP
Sat Feb 18 02:28:00 AEST 1984


From:  Steve Woods <cepu!scw at ucla-locus>


	From:  RMark.MINITAB at 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 <TSO loses>. 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 <it says here in the fine
print> 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 at ucla-locus
location: N 34 06'37" W 118 25'43"



More information about the Comp.unix mailing list