It failed during read/write. Below is setup routine for baudrate=B115200
int SerialPortSetup(int port, int baudRate)
{
tcgetattr(SerialUart_FD[port], &SerialPortSettings); // Get the current attributes of the Serial port
/* Setting the Baud rate */
//
cfsetispeed(&SerialPortSettings,baudRate); // Set Read Speed
cfsetospeed(&SerialPortSettings,baudRate); // Set Write Speed
/* 8N1 Mode */
SerialPortSettings.c_cflag &= ~PARENB; /* Disables the Parity Enable bit(PARENB),So No Parity */
SerialPortSettings.c_cflag &= ~CSTOPB; /* CSTOPB = 2 Stop bits,here it is cleared so 1 Stop bit */
SerialPortSettings.c_cflag &= ~CSIZE; /* Clears the mask for setting the data size */
SerialPortSettings.c_cflag |= CS8; /* Set the data bits = 8 */
SerialPortSettings.c_cflag &= ~CRTSCTS; /* No Hardware flow Control */
SerialPortSettings.c_cflag |= CREAD | CLOCAL; /* Enable receiver,Ignore Modem Control lines */
SerialPortSettings.c_iflag &= ~(IXON | IXOFF | IXANY); /* Disable XON/XOFF flow control both i/p and o/p */
SerialPortSettings.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /* Non Cannonical mode */
/* put terminal in raw mode - see termio(7I) for modes */
/* input modes - clear indicated ones giving: no break, no CR to NL,
no parity check, no strip char, no start/stop output (sic) control */
SerialPortSettings.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
/* local modes - clear giving: echoing off, canonical off (no erase with
backspace, ^U,...), no extended functions, no signal chars (^Z,^C) */
SerialPortSettings.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
SerialPortSettings.c_oflag &= ~OPOST; /*No Output Processing*/
/* Setting Time outs */
SerialPortSettings.c_cc[VMIN] = 0; /* Read at least num of characters */
SerialPortSettings.c_cc[VTIME] = 1; /* Wait 100ms */
/* Set the attributes to the termios structure*/
//
if(tcsetattr(SerialUart_FD[port], TCSANOW, &SerialPortSettings))
return ERROR;
else
return OK;
}