discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] How to "kill flowgraph" with a custom block


From: Marcus Müller
Subject: Re: [Discuss-gnuradio] How to "kill flowgraph" with a custom block
Date: Wed, 4 Jan 2017 11:40:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

Hi David,

did you write these blocks "free-standing" or generated them from with in an OOT with gr_modtool?

Really, I want to locally reproduce your problem, but I'm not overly eager to first manually fiddle your xml files into my system, place the python files in a directory where python looks for them, then note down what I'd have to clean up later, just to be able to run your example. That's why I asked for the *whole* module.

Best regards,
Marcus

On 04.01.2017 11:28, David Kersh wrote:
Hi Marcus,

I've attached the python source for the two blocks I made, their respective .xml files, the .grc file for the flow graph, and the top_block.py

Many thanks,
David

On Wed, Jan 4, 2017 at 10:19 AM, Marcus Müller <address@hidden> wrote:

Can you really share your whole Out-Of-Tree module including an example .grc or python flow graph?


Best regards,

Marcus


On 04.01.2017 10:53, David Kersh wrote:
Hi Marcus,

The 'stop' comparison definitely triggers as the appropriate text is printed to the GRC console.

I think you're right about my UDP broadcaster. I want it to be one of those types of blocks similar to the two default blocks in a flowgraph: Options and Variable. I think the way I've created it is wrong as I essentially just removed the input and output terminals in the .xml file and added arguments for IP address, port and message packet. So actually I plan not to use the inputs and outputs later on, I just don't really know what I'm doing / don't know how to remove the input / output related code from the python file.

Apart, from the two blocks I mentioned earlier and the Options and Variable blocks, the serverSource blocks outputs to the pre-defined Vector Sink block.

Thank you
David



On Wed, Jan 4, 2017 at 12:34 AM, Marcus Müller <address@hidden> wrote:
Hi David,

are you sure the 'stop' comparison ever triggers?

I'm not quite sure your UDP broadcaster /should/ be a GNU Radio block –
it doesn't have any in- or outputs (but I presume you plan to add these
later on).

What's the whole Flow graph you're using?


Best regards,

Marcus

On 03.01.2017 09:53, davidk wrote:
> Dear Marcus, Happy new year!
>
> Here is my UDP Server Block Python Code:
>
> /import numpy
> import socket
> from gnuradio import gr
> from gnuradio import blocks
>
> UDP_IP = "192.168.10.2"
> UDP_PORT = 58
>
> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>
> class serverSource(gr.sync_block):
>     def __init__(self):
>
> gr.sync_block.__init__(self,name="serverSource",in_sig=None,out_sig=[numpy.float32])
>         print "Setting up server"
>         sock.bind((UDP_IP, UDP_PORT))
>
>     def work(self, input_items, output_items):
>         out = output_items[0]
>         data, addr = sock.recvfrom(1024)
>         packetString = repr(data)
>
>         packetString = packetString.replace('\\x00','')
>         packetString = packetString.replace('\'','')
>
>         print "message received: ", packetString
>         print "address: ", addr
>
>         if packetString == 'stop':
>             return -1
>
>         return len(output_items[0])/
>
> and here is my UDP Broadcast block:
>
> /import numpy
> import socket
> from gnuradio import gr
>
> class udpBroadcast(gr.basic_block):
>     def __init__(self, ip, port, message):
>
> gr.basic_block.__init__(self,name="udpBroadcast",in_sig=[numpy.float32],out_sig=[numpy.float32])
>         print "Setting up UDP Message"
>
>         UDP_IP = ip
>         UDP_PORT = port
>         MESSAGE = message
>
>         sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>         sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))/
>
> Hopefully you can make out what I'm aiming for here.
>
> Many thanks
> David
>
>
>
> --
> View this message in context: http://gnuradio.4.n7.nabble.com/How-to-kill-flowgraph-with-a-custom-block-tp62332p62402.html
> Sent from the GnuRadio mailing list archive at Nabble.com.
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio






reply via email to

[Prev in Thread] Current Thread [Next in Thread]