How to port sgttyb in BSD4.3 application to termio in sysV rel 2

Gerard Strijdveen gerards at econ.vu.nl
Mon Jul 23 19:33:52 AEST 1990


The application I try to port has to read in ascii lines at 1200baud,
7 databits, 1 stopbit even parity. The lines all end with 'Carriage Return'.
What is de sysV rel 2 code for the underneath routine (used in BSD4.3)?
------------------------------------------------------
/* set speed etc. of communication line */

open_line()
{
	struct	sgttyb	ttybuf;

	close(0);
	if(fdc = open("/dev/ttyd0", 0) < 0) return(0);
	if(ioctl(0, TIOCEXCL, (char *)0) < 0 ||
		ioctl(0, TIOCGETP, (char *)&ttybuf) < 0) return(0);
	ttybuf.sg_ispeed = B1200;
	ttybuf.sg_flags = 0;
	ttybuf.sg_flags |= XTABS|ECHO|FF1|CRMOD;
	if(ioctl(0, TIOCSETP, (char *)&ttybuf) < 0) return(0);
	return(1);
}
------------------------------------------------------

AS you will expect, I am not an experienced C programmer and certainly not
when serial lines handling is the topic.

Please email directly to me:    gerards at econ.vu.nl



More information about the Comp.unix.wizards mailing list