Hello Ayaz,

If you are getting 'Template error' messages, you will have to check the XML 
file of your block (in grc directory).


Also, 'input' is not a valid variable name in Python, as it is used for other 
purposes. You will have to re-name that variable to something else.


Finally, "out[0][:] = self.input" should become "out[:] = self.input" as you 
already selected output port and you are not outputting vectors.


Regards,

Kyeong Su Shin


________________________________
보낸 사람: Ayaz Mahmud <ayazmah...@hotmail.com> 대신 Discuss-gnuradio 
<discuss-gnuradio-bounces+ksshin=postech.ac...@gnu.org>
보낸 날짜: 2018년 7월 31일 화요일 오전 2:22:35
받는 사람: discuss-gnuradio@gnu.org
제목: [Discuss-gnuradio] OOT sourcec block in python error


Hi,



I am trying to build a source block in python. Below is my code. After using 
the block I am getting a syntax error: self.Span_SourceBlock_0 = Template 
error: Span.SourceBlock($input)



My block should take input from user(int/float), and output the same. Though 
these are available blocks in GnuRadio but I am trying to learn on building it. 
Can you please check if my way of writing the code is correct?



import numpy

from gnuradio import gr



class SourceBlock(gr.sync_block):

    """

    docstring for block SourceBlock

    """

    def __init__(self, input):

        self.input = input

        gr.sync_block.__init__(self,

            name="SourceBlock",

            in_sig=None,

            out_sig=[numpy.float32])





    def work(self, input_items, output_items):

        out = output_items[0]

        out[0][:] = self.input

        return len(output_items[0])



Thanks,

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

Reply via email to