I've two application software running (sender and receiver) on 2 different booard comunicating beetween then via rs232 links The rs232 port on boths side has been configuarte in same way and sender side I've 2 second sleep between 2 trasmission. The data send is a simple counter and the sender increase its value every 2 seconds
What happens? it happens that after few packets recived the read() on receiver side return 0 with errno set to "Success" and none error on sender side. When the trasmission delay is 1 second, the read() return 0 after 9 or 10 messages and when set at 2 seconds this delay, the number of events before return 0 is around 4 or 5
Below the settings :
int Set_RS232_Params(int fd, speed_t speed)
{
int error = 0;
int v_ret = -1;
struct termios attribs;
/*get attributes */
v_ret = tcgetattr(fd, &attribs);
if (v_ret != 0)
{
error = 1;
printf("ERROR\n");
}
else
{
error = 0;
}
/*set output baudrate */
if (error == 0)
{
v_ret = -1;
v_ret = cfsetospeed(&attribs, speed);
if (v_ret != 0)
{
error = 1;
printf("ERROR\n");
}
}
/*set input baudrate */
if (error == 0)
{
v_ret = -1;
v_ret = cfsetispeed(&attribs, speed);
if (v_ret != 0)
{
error = 1;
printf("ERROR\n");
}
}
/*modify and save attributes */
if (error == 0)
{
/*CFLAG */
attribs.c_cflag &= ~PARENB;
attribs.c_cflag &= ~CSTOPB;
attribs.c_cflag &= ~CSIZE;
attribs.c_cflag |= CS8;
attribs.c_cflag &= ~CRTSCTS;
attribs.c_cflag |= CREAD;
attribs.c_cflag |= CLOCAL;
/*LFLAG */
attribs.c_lflag &= ~ECHO;
attribs.c_lflag &= ~ECHOE;
attribs.c_lflag &= ~ECHONL;
attribs.c_lflag &= ~ICANON;
attribs.c_lflag &= ~ISIG;
/*IFLAG */
attribs.c_iflag &= ~(IXON | IXOFF | IXANY);
attribs.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL);
/*OFLAG */
attribs.c_oflag &= ~OPOST;
attribs.c_oflag &= ~ONLCR;
/*VMIN and VTIME */
attribs.c_cc[VMIN] = 0;
attribs.c_cc[VTIME] = 0;
/*save attributes */
v_ret = -1;
v_ret = tcsetattr(fd, TCSANOW, &attribs);
if (v_ret != 0)
{
error = 1;
printf("ERROR\n");
}
}
return error;
}
Thanks