lansd@eecg.toronto.edu (Robert Lansdale) (07/24/89)
While porting my 3d graphics package from a SUN to an IRIS/4D several weeks ago I came across a minor compatibility problem between SUN's BSD Unix and the IRIX System V Unix; namely that the sgtty structure does not have the CBREAK bit. Since this was my first port to SYS V, I was stuck. Eventually I came across the cbreak() function in the curses library, but it seems that I have to open a window (and use the usual window I/O) just so I can call this routine - I don't want to have to use curses just to set the tty to cbreak! My question: is the SYS V 'raw' bit in the sgtty struct functionally similar to putting the tty into cbreak on a BSD system? From experience, 'raw' mode under BSD Unix bypasses all terminal translation routines and in some cases returns unexpected data (ie: on IBM terminals). Are there other ways to achieve cbreak()? ---------------------------------------------------------------------------- CSNET: lansd%eecg.toronto.edu, ARPA: lansd%eecg.toronto.edu@relay.cs.net Electrical Engineering Computer Group, University of Toronto. From postnews Sun Jul 23 21:20:42 1989 Subject: Achieving CBREAK without Curses Newsgroups: comp.sys.sgi Distribution: na While porting my 3d graphics package from a SUN to an IRIS/4D several weeks ago I came across a minor compatibility problem between SUN's BSD Unix and the IRIX System V Unix; namely that the sgtty structure does not have the CBREAK bit. Since this was my first port to SYS V, I was stuck. Eventually I came across the cbreak() function in the curses library, but it seems that I have to open a window (and use the usual window I/O) just so I can call this routine - I don't want to have to use curses just to set the tty to cbreak! My question: is the SYS V 'raw' bit in the sgtty struct functionally similar to putting the tty into cbreak on a BSD system? From experience, 'raw' mode under BSD Unix bypasses all terminal translation routines and in some cases returns unexpected data (ie: on IBM terminals). Are there other ways to achieve cbreak()? ---------------------------------------------------------------------------- CSNET: lansd%eecg.toronto.edu, ARPA: lansd%eecg.toronto.edu@relay.cs.net Electrical Engineering Computer Group, University of Toronto.
moss@BRL.MIL ("Gary S. Moss", VLD/VMB) (07/24/89)
Under System V, you should be using the termio structure rather than sgtty. The way to simulate CBREAK mode would be to turn canonical input processing OFF, and set up the VMIN and VTIME flags to 1 and zero respectively. Below is an excerpt from a library of mine which works on both BSD and SYSV, I have stripped out the BSD stuff for this example, and it is incomplete, but you should get the idea. The library is part of BRL CAD (libtermio), but if you don't have it and want just the library, send me a note, it is only a few pages of sources. -moss #include <termio.h> struct termio tio; /* clrCbreak() -- turn CBREAK mode off */ clrCbreak() { tio.c_lflag |= ICANON; /* Canonical input ON. */ tio.c_cc[VEOF] = 4; /* Defaults! Best we can do.... */ tio.c_cc[VEOL] = 0; (void) ioctl( 0, TCSETA, &tio ); } /* setCbreak() -- turn CBREAK mode on */ setCbreak() { tio.c_lflag &= ~ICANON; /* Canonical input OFF. */ tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 0; (void) ioctl( 0, TCSETA, &tio ); }