Gnuradio: Can I create a block parameter update after instantiation? - gnuradio

This tutorial on the GNURadio website shows that you can add a parameter to an OOT block by adding something like:
d_grey_code(grey_code)
to the block constructor after the output parameters, and adding
bool d_grey_code;
to the header file.
Doing this works fine, however, if I instantiate this block in a GR flowgraph and start a program, then "grey_code" is only updated at the start of the program.
If I set "grey code" to a variable and change it after the program starts, this change is not recongnized within the block.
Is there a method to create a parameter for an OOT block which will respond to changes in its value after a block is initialized?

Yes,
This is done via a callback. There are many examples of blocks that have callbacks. A quick look at gr-blocks and I found blocks_add_const_vxx.xml has a callback to set the constant. I suggest you look at the source for that block and understand how the "set_k" callback is defined, then try to replicate for your needs. Good luck.

Related

Can I override a method's return value in a breakpoint?

- (BOOL)mySetting
{
return [myObject returnYes];
}
For a method such as the above, is it possible to add a breakpoint with a debugger command so that the -mySetting method automatically returns a different value (such as NO) when the breakpoint is enabled?
I'm looking for an option where the debugger doesn't have to interrupt execution of the app, (a.k.a. has "Automatically continue after evaluating actions" turned on).
While zylenv's answer will work, it'll require you to create a temporary variable and recompile/launch.
The proper way to do this would be to use lldb's thread return command. It is used like this:
A good blog post explaining its usage (and a bunch of other cool LLDB stuff) is here.
You can use lldb debugger to change the return value of the method.
Just did like below.

lldb skip objc_msgSend

I'm trying to determine how a method Apple exposes on NSWorkspace works internally, in order to try and work around an unfortunate side effect of the method (it writes to disk, every time you call it). I can attach lldb to my executable and set a breakpoint when the method is called, and step in with si into objc_msgSend and on, but I'd prefer to just skip ahead until I get to the method body, is there any way to set a breakpoint for the beginning of the method body, or the instruction in objc_msgSend immediately before the jump to the method body?
You can set a breakpoint to the actual method body itself via something like this
br s -n "-[NSWorkspace openURL:]"
lldb's source-level step command will always pass through the objc_msgSend trampoline code for you, stopping in the target implementation, regardless of where the implementation lives.
However, lldb will also by default automatically step back out of methods with no debug info. That is for the most part the behavior people want, but is in this case NOT what you want. Fortunately, you can turn off this latter behavior, either for a given step by doing:
(lldb) step -a 0
or generally by setting the global default that controls this:
(lldb) set set target.process.thread.step-in-avoid-nodebug 0

Get pointer to self in LLDB?

I want to create a breakpoint in xCode which uses LLDB and checks the current object class in condition section.
The problem is LLDB doesn't allow to use self to get a class. How to solve this problem? Maybe through other commands? For example, bt command output contains correct classname but it seems it is not allowed in LLDB too.
I presume this is related to:
Using of symbolic breakpoints for child classes in Xcode?
The problem comes if your breakpoint is in code with no debug information (like in system libraries.) The debugger knows nothing about self in this context, and you have to give it more help. In the case of self, you know that it was passed into a method call as the first argument, so you can use $arg1 to get at the value.

Can I call a method without triggering its event listeners?

Is there any sort of flag or way to call a method without triggering any event handlers?
FOR EXAMPLE
I'm handling a controlTextDidChange method and checking to see if the character returned by a keystroke is valid. If it's not, I remove it; if it is, I append a word. The problem is that when I change the text while in controlTextDidChange, controlTextDidChange is called again and the program will loop indefinitely. I know I can use an instance variable to get around this, but is there any sort of flag or way to call a method without triggering any event handlers?
To expand the comment into a quick answer.
You have a method that issues a notification by design. You want it to not issue that notification. You don't have an alternative available that does the same thing w/o the notification. If you want it to never issue that notification, and you have access to the code for the method, you could swizzle the method to a version where you've just commented out the notification. Of course, if you had the code, you could just add another method, and call that one. So you don't have the code, and all that's moot.
Can't you just bracket that invocation in code that removes the listener and then restores the listener? In other words, psuedocode like this:
[self.controlThingy removeObserver:self]
[self.controlThingy myMethod]
[self.controlThingy addObserver:self]
You've then made self deaf to notifications for that one invocation of myMethod. I've done similar things with bindings and KVO.

Why is the value of variable different when using CCLog and using print in debug mode?

The strengthbar in my game doesn't work well after playing at least once of the level. So I wrote a method using CCLog to log out some variables and call this method in update: method. And I also set a breakpoint, when this problem appears it gets into debug mode of Xcode, then I use print to check the variables. However it appears that the values are different between using CCLog and using print command. Here's a screenshot that explains everything.
Here is my screenshot:
Does it have something to do with Multithreads(which I know nothing about)? I've checked the declaration of each logged variables, to make sure they're not declared several times using the same name.
OK, problem is solved.
When I wrote some delegate I used "Strong" which causes some retain cycles. Now I changed them all to Weak, and also changed the deployment settings to iOS 5 (or above).
The reason that the values of the variable are different is because in CCLog, the value belongs to the new scene, however there're more than one scene at the same time receiving my touches because of the retain cycles. Nothing wrong about XCode or Cocos2d, or CCBReader :-p
Hope this answer would help others. And many thanks to #Cy-4AH.
Because it was changed after it was printed. In the breakpoint you are lookng at new value.