Timers


#1

What’s the best way to setup a timer routine that has access to the bits
of the flowgraph?

I’m using an external process (UI) to set dynamic values for certain
USRP attributes, and one of the mechanisms
I’m thinking of using is to trigger a regular timer to see if the
values in an external control file have changed, and if
so, update the USRP settings.

I know that there’s gr_local_signal_sighandler()–does the handler
function have access to the flowgraph?


Marcus L.
Principal Investigator, Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org


#2

On Tue, Feb 24, 2009 at 05:57:35PM -0500, Marcus D. Leech wrote:

function have access to the flowgraph?
No. In general it’s virtually impossible to safely uses threads and
signals together. If you need a timer, one way to get it is to use a
dedicated thread that manages the timer queue, then send messages to
those who want them when the timer expires.

[I’ll be implementing something like this in the next few months]

Eric


#3

Eric B. wrote:

No. In general it’s virtually impossible to safely uses threads and
signals together. If you need a timer, one way to get it is to use a
dedicated thread that manages the timer queue, then send messages to
those who want them when the timer expires.

[I’ll be implementing something like this in the next few months]

Eric

Actually, it turned out to be remarkably easy. With gr-generated code,
the main program is just:

    topblock.start()
    raw_input()
    topbloack.stop()

Which means that main runs in a separate thread. So, I simply replaced
raw_input() with a loop that goes to
sleep for 250msec, then checks the control file, then goes to sleep
again. A bit in the control file asks the
Python flowgraph to exit. Simple.

Wish there was an easy way to merge grc-generated code with stuff like
this.


Marcus L.
Principal Investigator, Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org