Timeout on serial port read

root at MCIRPS2.MED.NYU.EDU root at MCIRPS2.MED.NYU.EDU
Thu May 3 14:34:06 AEST 1990


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.

Code follows:
---
    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;

    ioctl(fd, TCSETA, &new_settings);
-----

A read that has timed out should return with a value of 0. Right ?

dan.
--
+-----------------------------------------------------------------------------+
| karron at nyu.edu                          Dan Karron                          |
| . . . . . . . . . . . . . .             New York University Medical Center  |
| 560 First Avenue           \ \    Pager <1> (212) 397 9330                  |
| New York, New York 10016    \**\        <2> 10896   <3> <your-number-here>  |
| (212) 340 5210               \**\__________________________________________ |
+-----------------------------------------------------------------------------+



More information about the Comp.sys.sgi mailing list