0

I am reading the data from serial using read system call. It seems that this call is reading only one byte though it given how many bytes to read

bytes_read = read(fp, buffer, 20);

I don't know how much bytes the sender will send. If I know, then I would read that many times. I suspect that, while reading in to serial second bytes didn't arrived, so that it is coming out. Due to this I want to implement timeout. read call should wait for that much of time, read all the bytes till that timeout. I want experts to help me in this.

Drew McGowen
  • 11,471
  • 1
  • 31
  • 57
  • 2
    Possible duplicate of: http://stackoverflow.com/questions/2917881/how-to-implement-a-timeout-in-read-function-call?rq=1 – Igor Pejic Aug 08 '14 at 14:26

1 Answers1

0

You can control the timeouts and line buffer characteristics via the termios(3) library call.