Non blocking read with fixed data in input
<p>I want use serial port to communicate with another device txdev, the problem is that txdev is sending data asynchronously and i don't want the <code>read</code> function to block, the good thing is that txdev is sending data with fixed size but i don't know how to use this trick.
what i'am doing is the following :</p>

<pre><code>fd = open(DEVICE_NAME, O_RDWR | O_NOCTTY);
bzero(&amp;termios_p, sizeof(termios_p));
termios_p.c_cflag = CS8|CSTOPB|CLOCAL|CREAD;
termios_p.c_iflag = IGNPAR;
termios_p.c_oflag  = 0;
termios_p.c_lflag = ~ICANON;
termios_p.c_cc[VMIN]=DATA_LENGTH;
termios_p.c_cc[VTIME]=10;

cfsetispeed(&amp;termios_p, BAUDRATE);
cfsetospeed(&amp;termios_p, BAUDRATE);  

tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&amp;termios_p);
</code></pre>

<p>from <a href="https://stackoverflow.com/questions/18070731/linux-serial-port-blocking-read-with-timeout?lq=1">this post</a> i undrestand that this cause the read to be blocked VTIME = 0 is blocking as well.</p>

<p>Could anyone help me figure out the solution i think i have to use interrupt handler instead of a <code>read</code> do you agree ?</p>

<p>2nd question : Since a sender can't get synchronized with the receiver is there an interrupt handler that stores the received data on specified buffer (i undrestand that this is the case for Canonical mode but not in Non canonical mode)  or this is only done when <code>read</code> function is reached, if i'am wrong please correct me </p>

<p>As usual thanks a lot.</p>