Hi Kartik,

Well, no I would think there ought not be an error in the tutorial, but the 
fact remains that if I run the ‘if_else_mod.py’ from the 
~/solutions/gr-tutorial/examples/tutorial3/python/ folder I get the exact same 
runtime errors, so it might be something in the build.  I attach my own 
if_else_mod.py file which has been produced by my firstly generating if_else.py 
from the flowgraph which I have built as instructed in the tutorial and then 
doing exactly as instructed in the tutorial the modifications to the def 
_variable_function_probe_0_probe():.

I also attach the ‘solutions’ version of the if_else_mod.py (called 
if_else_mod_orig.py) and a file which summarises investigations made so far and 
the results of Kompare to discover the differences in the code. Clearly the grc 
generates code which differs somewhat from the samples in the ~/python 
directory (which are from an older version, clearly).

I don’t know if it is anything to do with the ‘tb = if_else’ line – I am about 
to test that out.



Thanks

Regards

Jacqueline


From: Kartik Patel [mailto:kartikpatel1...@gmail.com]
Sent: 11 January 2017 21:32
To: Jacqueline.Walker; discuss-gnuradio@gnu.org
Subject: Re: [Discuss-gnuradio] guided tutorials - problem with tutorial 3


Hi Jacqueline,

I don't think there's error in the tutorial. Please send your GRC or Python 
file.

Thank you.

Regards,
Kartik Patel

On 10:54PM, Wed, Jan 11, 2017 Jacqueline.Walker 
<jacqueline.wal...@ul.ie<mailto:jacqueline.wal...@ul.ie>> wrote:
Hello,

Trying the tutorial three – python in gnu radio and the ‘if_else’ mod file. I 
get this run-time error even with the tutorial/solutions file so it might be a 
build thing.

Basically when it runs with the added if val == 1: block it raises an
Attribute error top_block_sptr has no attribute named analog_sig _x1_source 
block – (sorry not correctly copied but you get the idea hopefully) – in other 
words it does not recognise the analog signal source that you have and that you 
are trying to modify the freq and/or amplitude of under control of the simple 
if/else using the probe_signal variable as outlined in the tutorial.
Is there something missing in the build or is it some error in the 
file/instructions in the tutorial?

Thanks
Jacqueline
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org<mailto:Discuss-gnuradio@gnu.org>
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
--

Regards,
Kartik Patel
B.Tech. Final Year
Electronics and Communication Engineering
Indian Institute of Technology, Roorkee
Step 1: 
In my work folder, delete the offending python files: if_else.py and 
if_else_mod.py
Re-generate if_else.py from GRC and if_else.grc (flowgraph) - OK
Execute - OK, it runs, looks like picture in Tutorial 3, no error messages 
produced

Re-do the modifications to the variable_function_probe def as shown in Tutorial 
3.
Save as if_else_mod.py in my work directory.
Run as at the prompt@ python if_else_mod.py
Does not run, you get:
ko
File "if_else_mod.py", line 17
 print "Warning: failed to XInitThreads"

I believe this is an error due to it not conforming to syntax requirments for 
python3 which is "python" under my installation.

Run as at the prompt@ python2.7 if_else_mod.py
It runs and produces the plot with 1000/0.3 until it reaches the if else 
construct when it does the first print val (0.0) then:

Exception in thread Thread-1:
Traceback (most recent call last):
 File "/usr/lib/python2.7/threading.py", line 801, in 
__bootstrap_innerself.run()
 File "/usr/lib/python2.7/threading.py", line 754, in 
runself.__target(*self.__args,**self.__kwargs)
 File "if_else_mod.py", line 94, in 
_variable_function_probe_0_probeself.set_ampl(.3)
 File "if_else_mod.py", line 198, in set_ampl
 File "/usr/lib/python2.7/site-packages/gnuradio/gr/hier/hier_block2.py", line 
92, in __getattr__
  return getattr(self.__impl, name)
AttributeError: 'top_block_sptr' object has no attribute 'analog_sig_source_x_1'

Result of Kompare between 

work/if_else.py and work/if_else_mod.py
The ONLY difference between these two files is the code entered under the 
instructions of the tutorial.

Step 2:
Go to solutions/gr-tutorial/examples/tutorial3/grc_files
Open the if_else.grc example file, re-generate and execute.
Goes exactly as above with mine in step 1.

Result of Kompare between

work/if_else.py and 
solutions/gr-tutorial/examples/tutorial3/grc_files/if_else.py

Only one difference: in

self.qtgui_time_sink_x_0 = qtgui.time_sink_f(1024, #size samp_rate #samp_rate 
"", #name 1 #number of inputs)
 
#name is 'QT GUI Plot' instead of empty string in mine

Step 3:

Go to solutions/gr-tutorial/examples/tutorial3/python
It contains another copy of if_else.py and a copy of if_else_mod.py both 
provided from the github clone.

Result of Kompare
~/grc_files/if_else.py and ~/python/if_else.py

There is a whole if __name__ == '__main__' block at top of the generated file

in the methods self.freq_line_edit.returnPressed.connect() and 
self.ampl_line_edit.returnPressed.connect()
in the parameters passed in connect() the type is cast to int(self....) in the 
'original' code  and str(self....) in the generated code e.g.

self.freq_line_edit.returnPressed.connect(lambda: 
self.set_freq(int/str(self.freq_line_edit.text().toAsci())))

single quotes vs double quotes for the #name of QT gui time sink 
There are some extra settings of labels, grid etc. in the QT Gui Time Sink in 
the generated code, slightly different ordering of some statements in the files 
etc.

Big difference: in the generated code there is a def main block which has 
parameters top_block_cls = if_else and lower down sets tb = top_block_cls()
In the 'original' code the if __name__ == '__main__' block the same as at top 
of the generated file appears here at the bottom and 
tb = if_else()
There is a final if __name__ == '__main__' main() at the very end of the 
generated file.

Step 4:
If you run 'if_else_mod.py' from ~/python in the solutions folder, you get the 
exact same runtime errors as in step 1.
Go Figure!
Differences (again using Kompare) between my 'if_else_mod.py' and theirs are 
the same as between the generated SOLUTIONS if_else.py and the 'original' (in 
the solutions/python folder) if_else.py.

Attachment: if_else_mod.py
Description: if_else_mod.py

Attachment: if_else_mod_orig.py
Description: if_else_mod_orig.py

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to