How bytes received on UART device are stored in some serial Linux devices /dev/ttyS? How to read them?
What is the procedure? Should that device file be closed, when new data is arriving?
From the user space's point of view, they are not stored at all.
If you mean only to read them, simply
cat /dev/ttyS... will do. Some more information as to how to deal with serial interfaces can be seen in multitude of answers and comments in this page and in the internet in general withing seconds of searching. Some ideas:
cutecom and similar tools. This question here is rather interesting.
/dev/ttyS* are character devices, they do not behave as regular files in your file system, and hence you don't need to flush them or close and reopen them to get new information "written" to them. The point of having dev-files is to have a way to communicate between user space and kernel space.
A little bit more detailed, the process is:
Data will come to the hardware, the serial interface, as electrical pulses. The hardware will transform the electrical pulses to digital signals and tranfer them to the HAL (Hardware Abstraction Layer)/Kernel driver or controller in charge to govern the hardware. This will be translated to bytes according to baud rate and protocol used and buffered to further process. The kernel will then empty the buffer into the character device, visible from user space as a node in