UART Read function getting fail

Dear ,
please help me to resolve this issue .

If I run below program in beagle board as ./filename /dev/ttyO2 115200 8 0 0
even the data transmission is happening here,but read function is getting fail.

cat /proc/tty/driver/OMAP-SERIAL
serinfo:1.0 driver revision:
0: uart:OMAP UART0 mmio:0x44E09000 irq:72 tx:817 rx:5 RTS|CTS|DTR|DSR
1: uart:OMAP UART1 mmio:0x48022000 irq:73 tx:0 rx:0 CTS|DSR|CD|RI
2: uart:OMAP UART2 mmio:0x48024000 irq:74 tx:120 rx:120 CTS|DSR
3: uart:OMAP UART3 mmio:0x481A6000 irq:44 tx:0 rx:0 CTS|DSR
4: uart:OMAP UART4 mmio:0x481A8000 irq:45 tx:0 rx:0 CTS|DSR
5: uart:OMAP UART5 mmio:0x481AA000 irq:46 tx:0 rx:0 CTS|DSR

#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>

int main(int argc, char *argv[])
{
int chkin;
unsigned char input[]=“hellol”;
unsigned char msg[1024];
unsigned char serport[100];
long Baud_Rate,BAUD,STOPBITS,PARITYON,PARITY,DATABITS;
unsigned int Data_Bits,count,Stop_Bits,Parity ;
struct termios options;
char *deviceName = argv[1];
int fd;

fd= open(deviceName, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd <= 0)
{
printf(msg, “open_port: Unable to open %s.\n”, serport);
}
else
fcntl(fd, F_SETFL, FNDELAY);
Baud_Rate=argv[2];

switch (Baud_Rate)
{
case 115200:
BAUD = B115200;
break;
case 38400:
BAUD = B38400;
break;
case 19200:
BAUD = B19200;
break;
case 9600:
BAUD = B9600;
break;
case 4800:
BAUD = B4800;
break;
}
Data_Bits=argv[3];

switch (Data_Bits)
{
case 8:
default:
DATABITS = CS8;
break;
case 7:
DATABITS = CS7;
break;
case 6:
DATABITS = CS6;
break;
case 5:
DATABITS = CS5;
break;
}

Stop_Bits=argv[4];

switch (Stop_Bits)
{
case 1:
default:
STOPBITS = 0;
break;
case 2:
STOPBITS = CSTOPB;
break;
}

Parity =argv[5];
switch (Parity)
{
case 0:
default: //none
PARITYON = 0;
PARITY = 0;
break;
case 1: //odd
PARITYON = PARENB;
PARITY = PARODD;
break;
case 2: //even
PARITYON = PARENB;
PARITY = 0;
break;
}

printf(“Writing input data:%d\n”,fd);

chkin=write(fd,input,sizeof(input));
if (chkin<0)
{
printf(“cannot write to port\n”);
fcntl(fd, F_SETFL, 0);

}
printf(“input data:%d\n”,chkin);
tcdrain(fd);
chkin=read(fd,msg,sizeof(msg));
if(chkin<0) {
printf(“read() bytes failed!\n”);
}
printf("%s\n",msg);
close(fd);
return 0;
}