Re: [Discuss-gnuradio] Updating variable by passing message
Hi Mohammad, this sounds like a wise architecture, using a message to update settings. To answer your question: > how i can update a variable block value in python code , is that possible at all ? As you noticed, yes, that's possible, because the GUI sliders etc. do that! However, it only works because these are actually living directly in the top_block python code. What you **can** do is write a python block, which, as a parameter, takes a reference to the top_block (or hier block) which it "lives" in, and stores it in a class member. Then you can call .set_variablename(value) on that in your message handler. I do **not** recommend that, however. It breaks the inherent thread safety of message passing, makes a large detour through python that will cost a lot of copies and unnecessary type conversions "under the hood"... Instead, better simply go and improve the FFT Filter! Add a message port that accepts new taps! I think we'd all love to see that becoming a feature, so if you can, please make that change and contribute it to GNU Radio! Also, it's less work than writing the python block that I mentioned above. Best regards, Marcus On 12.08.2017 11:51, mohammad nejati wrote: > Hi , > I want to update taps in "FFT FILTER" block in run time , i have a > block that can send this taps as a message every 1 secound . i write > an python block witch get this message what i want to do is get this > message and update value of a variable block wich is used in FFT > FILTER . but i dont know how i can update a variable block value in > python code , is that possible at all ? > > ___ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio smime.p7s Description: S/MIME Cryptographic Signature ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Re: [Discuss-gnuradio] Updating variable by passing message
Thanks Brian , But how work QT Range slider ? for example if use a range slider for one of taps value in FFT taps for example [0.1,0.001,0.2,My_range_slider_ID,0.2,...] changing value of slider in run time update FFT filter taps without any problem . i need some thins like that but it get value from message port . On Sat, Aug 12, 2017 at 2:34 PM, Brianwrote: > Mohammed, > > That's good question and I'm working on a project that requires me to do > similar but mine is frequency. > > I believe that once a code is run and your receiver is running that changing > a variable is not possible. > > However I have a workaround, I am using a file as a source which will be > either blank (so no action takes place) or a frequency value, this triggers > a reset of python and then reads in the value as a variable. > > This works quite well in my case but may not suit all applications. My > receiver only needs to be on when I trigger it from the transmitter, it > can't be used if you're looking for a constant FFT plot. > > Hope this helps and if there are any suggestions for a more refined solution > that would be great. > > Brian > > From: mohammad nejati > Sent: 12/08/2017 10:51 > To: discuss-gnuradio@gnu.org > Subject: [Discuss-gnuradio] Updating variable by passing message > > Hi , > I want to update taps in "FFT FILTER" block in run time , i have a > block that can send this taps as a message every 1 secound . i write > an python block witch get this message what i want to do is get this > message and update value of a variable block wich is used in FFT > FILTER . but i dont know how i can update a variable block value in > python code , is that possible at all ? > > ___ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Re: [Discuss-gnuradio] Updating variable by passing message
Mohammed, That's good question and I'm working on a project that requires me to do similar but mine is frequency. I believe that once a code is run and your receiver is running that changing a variable is not possible. However I have a workaround, I am using a file as a source which will be either blank (so no action takes place) or a frequency value, this triggers a reset of python and then reads in the value as a variable. This works quite well in my case but may not suit all applications. My receiver only needs to be on when I trigger it from the transmitter, it can't be used if you're looking for a constant FFT plot. Hope this helps and if there are any suggestions for a more refined solution that would be great. Brian -Original Message- From: "mohammad nejati"Sent: 12/08/2017 10:51 To: "discuss-gnuradio@gnu.org" Subject: [Discuss-gnuradio] Updating variable by passing message Hi , I want to update taps in "FFT FILTER" block in run time , i have a block that can send this taps as a message every 1 secound . i write an python block witch get this message what i want to do is get this message and update value of a variable block wich is used in FFT FILTER . but i dont know how i can update a variable block value in python code , is that possible at all ? ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio