I want to use serial com port for communication and I want to implement a timeout every time I call the read() function call.
int filedesc = open( "dev/ttyS0", O_RDWR );
read( filedesc, buff, len );
EDIT:
I’m using Linux OS. How to implement using select function call?
select()
takes 5 parameters, first the highest file descriptor + 1, then a fd_set for read, one for write and one for exceptions. The last parameter is a struct timeval, used for timeout. It return -1 on error, 0 on timeout or the number of file descriptors in the sets that are set.