DanielLazar
Posts: 1
Joined: Fri Oct 11, 2019 6:46 am

UART supervisor for RX

Fri Oct 11, 2019 7:04 am

Hello,

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.


dickon
Posts: 569
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: UART supervisor for RX

Fri Oct 11, 2019 8:58 am

You could tie the UART RX pin to another GPIO pin and monitor that with a second process.

scotty101
Posts: 3753
Joined: Fri Jun 08, 2012 6:03 pm

Re: UART supervisor for RX

Fri Oct 11, 2019 9:02 am

I'd have a timer inside my main application which is reset each time a byte of data is received.
If the timer counts up beyond a certain point then it would raise a flag which allows any external interfaces to be reset.
Don't see any need for a second program to monitor it.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

dickon
Posts: 569
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: UART supervisor for RX

Fri Oct 11, 2019 9:05 am

If all you have is a blob to drive the UART -- or simply don't want to maintain patches to a bit of open source -- a physical bit of wire might well be a lot easier to manage.

Return to “General discussion”