Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!ucsd!ucbvax!BRL.MIL!moss From: moss@BRL.MIL ("Gary S. Moss", VLD/VMB) Newsgroups: comp.sys.sgi Subject: Re: Timeout on serial port read Message-ID: <9005030929.aa08086@VMB.BRL.MIL> Date: 3 May 90 13:29:59 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 33 < I am trying to set the ioctl call so that a raw read from a < serial port will time out after a few seconds. No matter what I < set the TIME value for in the control structure, the machine < still hangs waiting for characters. What am I doing wrong, if anything. < new_settings.c_iflag = IGNBRK | IGNPAR; < new_settings.c_oflag = NULL; < new_settings.c_cflag = B9600 | CS8 | CREAD | CLOCAL; < new_settings.c_lflag = ICANON; < new_settings.c_line = NULL; < new_settings.c_cc[0] = NULL; < new_settings.c_cc[1] = NULL; < new_settings.c_cc[2] = NULL; < new_settings.c_cc[3] = NULL; < new_settings.c_cc[4] = NULL; < new_settings.c_cc[5] = TIMEOUT; For one thing, if you set ICANON, you will not get RAW input; do the following instead. Also, if you want to get 1 character at a time without blocking, set the VMIN (element 4) of c_cc to 1, and set TIMEOUT to 0. new_settings.c_lflag &= ~ICANON; /* Canonical input OFF. */ new_settings.c_cc[VMIN] = 1; new_settings.c_cc[VTIME] = 0; Other indices for c_cc should be written using their mnemonics as defined in /usr/include/sys/termio.h for portability if nothing else. CAVIAT: the VMIN/VTIME mechanism is intended for reading DMA bursts, and does not really work for general timeouts. What you probably need to use poll(2) or select(2) rather than ioctl(2) (if I understand your question).