Just call set_gain() from the thread context of the USRP sink, i.e., the top_block. Use a semaphore: the thread doing the calling sets a semaphore in the top_block, and then the top_block runs a loop which looks for that semaphore to be set and then calls set_gain.
Nick On Wed, Jun 17, 2020 at 1:04 PM Guy Marino <g...@comsat-architects.com> wrote: > Hello, > > I'm currently working on a multithreaded application which needs to set > the gain value of a USRP sink at runtime. The only thing I've found that > works so far is: > > stop() -> wait() -> lock() -> set_gain() -> unlock() -> start() > > I tried using just lock/unlock, but this causes the SDR to freeze > completely. As it is, the current setup causes stability issues and crashes > after only a few minutes at best. I've heard about sending commands to the > USRP Sink, though I couldn't find any documentation on the subject and the > one page I found has been removed (and was never archived). Here's the > message I keep receiving from the flowgraph: > > gr::log :FATAL: tagged_stream_mux0 - Missing a required length tag on port > 1 at item #100 > thread[thread-per-block[10]: <block tagged_stream_mux(14)>]: Missing > length tag. > > It seems to happen at random with any tagged block in the flowgraph (the > point of failure typically changes every time we run it). While we could > theoretically just catch the error and restart the flowgraph, I would > rather find a more permanent solution. We're using two Ettus B200 SDRs for > our current tests. > > If anyone has any information on proper dataflow control for blocks or the > USRP sink message passing API, I'd really appreciate it. > > Thanks, > Guy Marino >