Forum: GNU Radio Timers

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
558c40b97bd1af8d912424757714bda9?d=identicon&s=25 Marcus D. Leech (Guest)
on 2009-02-24 23:58
(Received via mailing list)
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 Leech
Principal Investigator, Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-02-25 01:17
(Received via mailing list)
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
558c40b97bd1af8d912424757714bda9?d=identicon&s=25 Marcus D. Leech (Guest)
on 2009-02-25 15:04
(Received via mailing list)
Eric Blossom 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 Leech
Principal Investigator, Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org
This topic is locked and can not be replied to.