I have a use case where the C++ application has "ttyAMA0" opened and it read and write data. But I need something like a supervisor who will check if data are receiving or not and if RX is idle for some time period I need to do some action (Reset device on the other end of UART). I can't open uart filestream by another application since it is locked by the first one but I really don't need to open it. I just need to e.g. reset flag to 0 and whatever byte is received this flag will be set to 1 and it can be later reset and confirmed that RX is live. Is there something already implemented in Linux which can help me to solve this problem?
I have an idea that I can wire RX to some GPIO input and handle edges to set the flag to 1 but I don't want to do that before I will check if kernel itself doesn't have some functionality.
Thank you for any advise.