From owner-freebsd-hackers Thu Jul 11 15: 5:32 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C5B9537B400 for ; Thu, 11 Jul 2002 15:05:27 -0700 (PDT) Received: from mail.tinkerbox.org (adsl-64-168-139-138.dsl.snfc21.pacbell.net [64.168.139.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 441E443E4A for ; Thu, 11 Jul 2002 15:05:27 -0700 (PDT) (envelope-from bruno@tinkerbox.org) Received: from duron.bschwand.net (duron.bschwand.net [192.168.137.4]) by mail.tinkerbox.org (Postfix) with ESMTP id 836F719B5; Thu, 11 Jul 2002 15:08:00 -0700 (PDT) Date: Thu, 11 Jul 2002 15:08:00 -0700 (PDT) From: bruno schwander X-Sender: bruno@duron.bschwand.net To: Cyrille Lefevre Cc: hackers@FreeBSD.ORG Subject: Re: termios guru ? In-Reply-To: <20020711215855.GB21234@gits.dyndns.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG thanks, I see the idea but cfmakeraw has some other effects... newlines output by the program are not translated, etc. My main program now is the VMIN/VTIME stuff. The way irit tries to use is, is basically to be able to do async stdin reading, but this does not work. Whenever I try those settings, no input is ever read by the program. It fgetc() constantly returns -1. Any idea why ? bruno On Thu, 11 Jul 2002, Cyrille Lefevre wrote: > On Wed, Jul 10, 2002 at 09:13:18PM -0700, bruno schwander wrote: > > I making a port (not much really) of Irit > > (http://www.cs.technion.ac.il/~irit/) a modelling environment. > > > > I am having some problems with terminal handling, so all termios guru out > > there, please help ! :-) > > > > At stratup, irit does the following > > > > Termio.c_cc[VEOF] = 0; /* MIN = 0, no minimal length to wait for. */ > > Termio.c_cc[VEOL] = 1; /* TIME - 1 tenth of a second as time o > > > > which seems wrong, I think it should be > > > > Termio.c_cc[VMIN] = 0; /* MIN = 0, no minimal length to wait for. */ > > Termio.c_cc[VTIME] = 1; /* TIME - 1 tenth of a second as time o > > VMIN == VEOF and VTIME == VEOL. > > > then later: > > > > Termio.c_lflag &= ~ICANON; > > take a look at cfmakeraw(3) which is BSD specific, but that's > not important since it's a port *to* BSD :) > > more +/cfmakeraw /usr/src/lib/libc/gen/termios.c > > cfmakeraw(t) > struct termios *t; > { > > t->c_iflag &= ~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR); > t->c_iflag |= IGNBRK; > t->c_oflag &= ~OPOST; > t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|TOSTOP|PENDIN); > t->c_cflag &= ~(CSIZE|PARENB); > t->c_cflag |= CS8|CREAD; > t->c_cc[VMIN] = 1; > t->c_cc[VTIME] = 0; > } > > so, a short answer could be, as Bernd Walter suggested : > > int > settty(raw) > int raw; > { > static int init; > static struct termios old; > struct termios buf, *new; > > if (!init) { > if (tcgetattr(STDIN_FILENO, &old) < 0) { > printf("tcgetattr failed: %s\n", strerror(errno)); > return(1); > } > init++; > } > if (raw) { > if (init < 2) { > cfmakeraw(&buf); > init++; > } > new = buf; > } else > new = old; > if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &new) < 0) { > printf("tcsetattr failed: %s\n", strerror(errno)); > return(1); > } > return(0); > } > > Cyrille. > -- > Cyrille Lefevre mailto:cyrille.lefevre@laposte.net > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message