I know SO isn't the right place for theoretical questions, but rather for code exchange. Nevertheless, i can't find a complete solution so once again i'm putting my faith in SO community.
Problem:
As i worked with STM32 before i'm trying to replicate the UART interface. It's working well, but the questions arose.
It is possible to allow the ttyS# port to just ignore read() if the buffer file is empty?
Do i have to set it up by termios params or use Linux libs?
I had this problem, with STM32 ports, but it was solved via the interrupt interface in HAL libs. When it comes to Linux, i`m not sure.
I use:
fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);
fcntl(fd, F_SETFL, 0);
fcntl(fd, F_SETFL, O_NONBLOCK /* | O_ASYNC*/); //> doesn't suit well cause app reads its own data