I'm trying this way but still no success:
struct termios options;
int nBytesRead = 0;
char buffer[20];
int fd = open(SERIAL_PORT,O_RDONLY | O_NOCTTY);
if(fd == -1){
perror("unable to open serial port");
return -1;
}
//setting baud rate
tcgetattr(fd, &options);
cfsetispeed(&options,B9600);
cfsetospeed(&options,B9600);
options.c_cflag |= (CLOCAL | CREAD);
tcsetattr(fd,TCSANOW,&options);
fcntl(fd,F_SETFL,0); //setting blocking read
nBytesRead = read(fd,buffer,20);
now it just immediately returns from read with 0 bytes read...but read() should be blocking.