[prev in list] [next in list] [prev in thread] [next in thread]
List: gnuradio-discuss
Subject: Re: [Discuss-gnuradio] How to "kill flowgraph" with a custom block
From: Marcus_Müller <marcus.mueller () ettus ! com>
Date: 2016-12-20 15:13:33
Message-ID: bb6ab5e0-0646-ebf2-cac4-2fb7648fe32d () ettus ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi!
I think 3) is your problem: sounds like you spawn a new thread to handle
UDP, and did not include a way to shut that thread down.
Can you share the code?
Cheers,
Marcus
On 20.12.2016 11:15, David Kersh wrote:
> Dear Marcus,
>
> So, I'm very unfamiliar with what /message connections/ are so we'll
> go with a no. I'll describe exactly what I've done and perhaps we can
> workout where I've gone wrong.
>
> I have constructed a flowgraph which contains 5 blocks total. Two of
> them are custom ones I've managed to hack together.
>
> 1) Options block (default)
> 2) Variable block (default)
> 3) An OOT UDP Broadcast block written in Python. No inputs or outputs.
>
> This block has been written to send out a UDP packet to a piece of
> hardware. This block does exactly what I want it to do and does every
> inside of the /__init__/ method. It simply utilises the
> /socket/ library and sends a packet using .sendto(MESSAGE, (UDP_IP,
> UDP_PORT)). I'm quite new to UDP programming work so I wonder if the
> fact I haven't closed the socket is a problem. Another issue I'm
> starting to wonder is that I removed this block's inputs and outputs
> from the XML, but haven't changed anything in the python code. the
> /general_work/ method still takes /(self, input_items, output_items).
> /Is there a name for blocks which have no inputs / outputs? This could
> be an issue.
>
> 4) An OOT UDP Server block written in Python. One output
>
> This block was made with gr_modtool as a source. The purpose of this
> block is to read incoming packets and kill the flowgraph upon
> receiving a "stop" command. In the /__init__/ method,/.bind((UDP_IP,
> UDP_PORT))/ is called, setting up the server. The /work /method gets
> blocked as the block waits for an incoming packet with the
> /.recvfrom/ method (but I don't think this should be an issue). I
> finally have an /if/ statement which returns /-1/ should "stop" be
> received.
>
> 5) A null sink.
>
> I suppose this could be anything.
>
> Hopefully this reply isn't an incoherent mess and you understand what
> I'm trying to accomplish. Having written this, I am wondering if the
> fact that my UDP Broadcast block still wants to take input and output,
> but isn't is the issue.
>
> Many thanks
> David
>
> On Mon, Dec 19, 2016 at 5:34 PM, Marcus Müller
> <marcus.mueller@ettus.com <mailto:marcus.mueller@ettus.com>> wrote:
>
> Hey David,
>
> no, more bleeding edge than 3.7.10.1 wouldn't sound recommendable.
>
> At the moment, I don't have much idea what could be wrong with
> your UDP-based source. What else is in the flow graph, or is it
> just the null sink? Any message connections?
>
> Best regards,
>
> Marcus
>
>
> On 19.12.2016 16:59, David Kersh wrote:
>> Dear Marcus,
>>
>> Excellent news!
>>
>> I've just installed 3.7.10.1 and my flow graph still doesn't
>> appear to end (but my UDP server block stops because it won't
>> receive anymore packets after returning -1). Currently I have a
>> basic flowgraph which has my server block running alongside a
>> symbol noise source and frequency visualisation sink.
>>
>> Do you recommend using one of the bleeding edge releases?
>>
>> Many Thanks
>> David
>>
>> On Mon, Dec 19, 2016 at 1:08 PM, Marcus Müller
>> <marcus.mueller@ettus.com <mailto:marcus.mueller@ettus.com>> wrote:
>>
>> Hi David,
>>
>> that worked :)
>>
>> yep, returning -1 (which is the magical value for "there's
>> nothing coming anymore, you can shut down") would normally
>> end a flow graph.
>>
>> However, we've had (still have) problems with the shutdown
>> logic, but people recently patched a lot of things – so
>> whatever you do, please make sure you're using the current
>> release of GNU Radio. Which is it that you're currently using?
>>
>> Best regards,
>>
>> Marcus
>>
>>
>> On 19.12.2016 12:45, David Kersh wrote:
>>> Hello all,
>>>
>>> I've created a custom out of tree source block which listens
>>> for UDP packets and does different things depending on the
>>> received packet. It is connected to a NULL sink because I
>>> haven't quite worked out how to make a standalone UDP Server
>>> (and I've found the tutorials to be very confusing
>>> unfortunately).
>>>
>>> When the packet is "stop", I would like the flowgraph to be
>>> stopped. I've seen from researching different forums that
>>> if *-1* is returned, the flowgraph is supposed to stop but I
>>> only find that this stops my block from running, the rest of
>>> the flowgraph continues running.
>>>
>>> Is there not a simple command which I can use to kill the
>>> whole flowgraph?
>>>
>>> An alternative solution I tried to implement was to access
>>> these values using a /vector sink/ block and the .data()
>>> method from the top_block.py
>>> This didn't seem to work correctly as Python's UDP calls block.
>>>
>>> Thank you, hopefully I've made this post properly. I'm quite
>>> new to programming with GNURADIO.
>>>
>>> David
>>>
>>>
>>> _______________________________________________
>>> Discuss-gnuradio mailing list
>>> Discuss-gnuradio@gnu.org <mailto:Discuss-gnuradio@gnu.org>
>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>> <https://lists.gnu.org/mailman/listinfo/discuss-gnuradio>
>> _______________________________________________
>> Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org
>> <mailto:Discuss-gnuradio@gnu.org>
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>> <https://lists.gnu.org/mailman/listinfo/discuss-gnuradio>
>>
> _______________________________________________ Discuss-gnuradio
> mailing list Discuss-gnuradio@gnu.org
> <mailto:Discuss-gnuradio@gnu.org>
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> <https://lists.gnu.org/mailman/listinfo/discuss-gnuradio>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[Attachment #5 (text/html)]
<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi! <br>
</p>
<p>I think 3) is your problem: sounds like you spawn a new thread to
handle UDP, and did not include a way to shut that thread down.</p>
<p>Can you share the code?</p>
<p>Cheers,</p>
<p>Marcus<br>
</p>
<div class="moz-cite-prefix">On 20.12.2016 11:15, David Kersh wrote:<br>
</div>
<blockquote
cite="mid:CAFhkv44SzS6=8bBGWTcO6OnjeAZSqYuj9s0MJ4Ofrquapnyrvw@mail.gmail.com"
type="cite">
<div dir="ltr">Dear Marcus,
<div><br>
</div>
<div>So, I'm very unfamiliar with what <i>message connections</i> are
so we'll go with a no. I'll describe exactly what I've done
and perhaps we can workout where I've gone wrong.</div>
<div><br>
</div>
<div>I have constructed a flowgraph which contains 5 blocks
total. Two of them are custom ones I've managed to hack
together.</div>
<div><br>
</div>
<div>1) Options block (default)</div>
<div>2) Variable block (default)</div>
<div>3) An OOT UDP Broadcast block written in Python. No inputs
or outputs.</div>
<div><br>
</div>
<div>This block has been written to send out a UDP packet to a
piece of hardware. This block does exactly what I want it to
do and does every inside of the <i>__init__</i> method. It
simply utilises the <i>socket</i> library and sends a packet
using .sendto(MESSAGE, (UDP_IP, UDP_PORT)). I'm quite new to
UDP programming work so I wonder if the fact I haven't closed
the socket is a problem. Another issue I'm starting to wonder
is that I removed this block's inputs and outputs from the
XML, but haven't changed anything in the python code. the \
<i>general_work</i> method still takes <i>(self, input_items, output_items). </i>Is
there a name for blocks which have no inputs / outputs? This
could be an issue.</div>
<div><br>
</div>
<div>4) An OOT UDP Server block written in Python. One output</div>
<div><br>
</div>
<div>This block was made with gr_modtool as a source. The
purpose of this block is to read incoming packets and kill the
flowgraph upon receiving a "stop" command. In the <i>__init__</i>
method,<i> .bind((UDP_IP, UDP_PORT))</i> is called, setting up
the server. The <i>work </i>method gets blocked as the block
waits for an incoming packet with the <i>.recvfrom</i> method
(but I don't think this should be an issue). I finally have an
<i>if</i> statement which returns <i>-1</i> should "stop" be
received.</div>
<div><br>
</div>
<div>5) A null sink.</div>
<div><br>
</div>
<div>I suppose this could be anything.</div>
<div><br>
</div>
<div>Hopefully this reply isn't an incoherent mess and you
understand what I'm trying to accomplish. Having written this,
I am wondering if the fact that my UDP Broadcast block still
wants to take input and output, but isn't is the issue.</div>
<div><br>
</div>
<div>Many thanks</div>
<div>David</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Dec 19, 2016 at 5:34 PM, Marcus
Müller <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:marcus.mueller@ettus.com" \
target="_blank">marcus.mueller@ettus.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>Hey David,</p>
<p>no, more bleeding edge than 3.7.10.1 wouldn't sound
recommendable.</p>
<p>At the moment, I don't have much idea what could be
wrong with your UDP-based source. What else is in the
flow graph, or is it just the null sink? Any message
connections?</p>
<p>Best regards,</p>
<p>Marcus<br>
</p>
<div>
<div class="h5"> <br>
<div class="m_-5969021576439940436moz-cite-prefix">On
19.12.2016 16:59, David Kersh wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Dear Marcus,
<div><br>
</div>
<div>Excellent news!</div>
<div><br>
</div>
<div>I've just installed 3.7.10.1 and my flow
graph still doesn't appear to end (but my UDP
server block stops because it won't receive
anymore packets after returning -1). Currently I
have a basic flowgraph which has my server block
running alongside a symbol noise source and
frequency visualisation sink.</div>
<div><br>
</div>
<div>Do you recommend using one of the bleeding
edge releases?</div>
<div><br>
</div>
<div>Many Thanks</div>
<div>David</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Dec 19, 2016 at
1:08 PM, Marcus Müller <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:marcus.mueller@ettus.com"
target="_blank">marcus.mueller@ettus.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>Hi David,</p>
<p>that worked :)</p>
<p>yep, returning -1 (which is the magical
value for "there's nothing coming anymore,
you can shut down") would normally end a
flow graph.</p>
<p>However, we've had (still have) problems
with the shutdown logic, but people
recently patched a lot of things – so
whatever you do, please make sure you're
using the current release of GNU Radio.
Which is it that you're currently using?</p>
<p>Best regards,</p>
<p>Marcus<br>
</p>
<div>
<div class="m_-5969021576439940436h5"> <br>
<div
\
class="m_-5969021576439940436m_7144655699435906968moz-cite-prefix">On 19.12.2016 \
12:45, David Kersh wrote:<br> </div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="m_-5969021576439940436h5">
<div dir="ltr"><span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">Hello
all, </span><br
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">
<br
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">
<span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">I've
created a custom out of tree
source block which listens for UDP
packets and does different things
depending on the received packet.
It is connected to a NULL sink
because I haven't quite worked out
how to make a standalone UDP
Server (and I've found the
tutorials to be very confusing
unfortunately). </span><br
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">
<br
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">
<span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">When
the packet is "stop", I would like
the flowgraph to be stopped. I've
seen from researching different
forums that if </span><b
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">-1</b><span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px"> \
is returned, the flowgraph is
supposed to stop but I only find
that this stops my block from
running, the rest of the flowgraph
continues running. </span><br
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">
<br
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">
<span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">Is
there not a simple command which I
can use to kill the whole
flowgraph? </span>
<div><br>
</div>
<div>An alternative solution I tried
to implement was to access these
values using a <i>vector sink</i> block
and the .data() method from the
top_block.py</div>
<div>This didn't seem to work
correctly as Python's UDP calls
block.</div>
<div><br
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">
<span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">Thank
you, hopefully I've made this
post properly. I'm quite new to
programming with GNURADIO.</span></div>
<div><span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px"><br>
</span></div>
<div><span
style="color:rgb(0,0,0);font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px">David</span></div>
</div>
<br>
<fieldset
\
class="m_-5969021576439940436m_7144655699435906968mimeAttachmentHeader"></fieldset> \
<br> </div>
</div>
<span>
\
<pre>______________________________<wbr>_________________ Discuss-gnuradio mailing \
list <a moz-do-not-send="true" \
class="m_-5969021576439940436m_7144655699435906968moz-txt-link-abbreviated" \
href="mailto:Discuss-gnuradio@gnu.org" target="_blank">Discuss-gnuradio@gnu.org</a> \
<a moz-do-not-send="true" \
class="m_-5969021576439940436m_7144655699435906968moz-txt-link-freetext" \
href="https://lists.gnu.org/mailman/listinfo/discuss-gnuradio" \
target="_blank">https://lists.gnu.org/mailman/<wbr>listinfo/discuss-gnuradio</a> \
</pre> </span></blockquote>
</div>
______________________________<wbr>_________________
Discuss-gnuradio mailing list
<a moz-do-not-send="true" href="mailto:Discuss-gnuradio@gnu.org" \
target="_blank">Discuss-gnuradio@gnu.org</a>
<a moz-do-not-send="true" \
href="https://lists.gnu.org/mailman/listinfo/discuss-gnuradio" rel="noreferrer" \
target="_blank">https://lists.gnu.org/mailman/<wbr>listinfo/discuss-gnuradio</a>
</blockquote></div>
</div>
</blockquote>
</div></div></div>
______________________________<wbr>_________________
Discuss-gnuradio mailing list
<a moz-do-not-send="true" \
href="mailto:Discuss-gnuradio@gnu.org">Discuss-gnuradio@gnu.org</a>
<a moz-do-not-send="true" \
href="https://lists.gnu.org/mailman/listinfo/discuss-gnuradio" rel="noreferrer" \
target="_blank">https://lists.gnu.org/mailman/<wbr>listinfo/discuss-gnuradio</a>
</blockquote></div>
</div>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre wrap="">_______________________________________________
Discuss-gnuradio mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:Discuss-gnuradio@gnu.org">Discuss-gnuradio@gnu.org</a> <a \
class="moz-txt-link-freetext" \
href="https://lists.gnu.org/mailman/listinfo/discuss-gnuradio">https://lists.gnu.org/mailman/listinfo/discuss-gnuradio</a>
</pre>
</blockquote>
</body></html>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic