0

How can I get a value calculated in def work(self, input_items, output_items) and use it in a getter method? Until now, I defined a self.value but it does not change. I attached a capture containing my code.how to pass a to getA?

  • 1
    posting the code inside your answer would help others help you – m1sk Nov 19 '18 at 12:56
  • I'm having trouble understanding exactly what you want to do. Could you name each variable and explain what you want to go where? – m1sk Nov 19 '18 at 13:23
  • Sorry if I am unclear. The objective is to access "a" from work() and use it in getA(). I have tried before your answer the method you proposed but the result was 0 not 100. I think work has local effect, not global. – Friedrich Maar Nov 19 '18 at 13:32
  • I think this has something to do with the way gnuradio blocks are run. I'm unfamiliar with them, but I peeked at their documentation. It could be that this sort of thing is impossible in gnuradio. But I don't really know that area, maybe take a step back and think about what you are trying to accomplish, it might be possible by sending more output parameters? – m1sk Nov 19 '18 at 13:40
  • I thought about that, but I will search a little bit. Thank you! – Friedrich Maar Nov 19 '18 at 13:47

1 Answers1

2

You are storing the value of a in self.b. So you can just return that value:

def getA(self):
  return self.b
m1sk
  • 308
  • 2
  • 10
  • It will not be OK. self.b does not change in work(). I need something to do this change. – Friedrich Maar Nov 19 '18 at 13:11
  • 1
    @FriedrichMaar GNU Radio maintainer here. It does change. If it doesn't, something else is wrong. In this case, you're returning some `a` (which you didn't define anywhere in that scope, so you should be getting an exception); you should be, as m1sk recommends, returning `self.b`. – Marcus Müller Nov 20 '18 at 00:30