wich condition(events) can produce EOF in serial port in blocked raw mode????
From: cvv (cvv_serial_at_email.zp.ua)
Date: 11/09/05
- Next message: Jo: "Re: Daemon: setgid Operation not permitted"
- Previous message: Teel: "Re: [C++] Creating XML config files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 9 Nov 2005 03:50:36 -0800
OS:linux 2.4.26
sometimes, possible after noise in line, I receive situation when
select() on port return then there are data available for read but
following read() return 0 bytes.
according to man tcsetattr and analogue with socket I understand this
situation as EOF.
All following pair select()/read() return same situation regardless
from data in port.
serial port open/tune via code:
<code>
port->fd = open(devfile, O_RDWR | O_NOCTTY);
if (port->fd == -1) {syslog(LOG_ERR,"watcher_open_port():error
opening '%s': %m", devfile); free(port);return NULL; }
if (tcgetattr(port->fd, &ti) < 0)
{ syslog(LOG_ERR, "%s(%s):error getting terminal line modes:
%m",__func__, devfile); close(port->fd);free(port); return
NULL; }
cfmakeraw(&ti);
cfsetispeed(&ti, WATCHER_PORT_SPEED);
cfsetospeed(&ti, WATCHER_PORT_SPEED);
//c_iflag &=
~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
ti.c_iflag |= IGNBRK;//???возможно имеет смысл
оставить этот флаг снятым а вместо
него поднять BRKINT???
ti.c_iflag |= IGNPAR;//Ignore framing errors and parity errors.
ti.c_iflag &= ~(INPCK | PARMRK);
ti.c_iflag &= ~(IXOFF | IXON | IXANY); /* disable start/stop i/o
flow control*/
//c_oflag &= ~OPOST;
ti.c_cflag &= ~(PARENB | PARODD); /* no parity */
ti.c_cflag &= ~CSTOPB; /* 1 stop bit */
ti.c_cflag &= ~CRTSCTS; /* no i/o rts/cts flow control
*/
ti.c_cflag |= CLOCAL;
ti.c_cflag |= HUPCL;
ti.c_cflag |= CREAD;
//c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
//Disable flushing the input and output queues when
generating the SIGINT, SIGQUIT and SIGSUSP signals.
//ti.c_lflag &= ~(NOFLSH);//???возможно
потребуется установить/снять???
ti.c_cc[VMIN] = 0;
ti.c_cc[VTIME] = 0;
if (tcsetattr(port->fd, TCSANOW, &ti) < 0)
{ syslog(LOG_ERR,"%s(%s):error setting terminal line modes: %m",
__func__, devfile); close(port->fd);free(port); return
NULL; }
</code>
any idea???
- Next message: Jo: "Re: Daemon: setgid Operation not permitted"
- Previous message: Teel: "Re: [C++] Creating XML config files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|