Quantcast

File Sink open/close question

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

File Sink open/close question

Hanz
Hi!
Im using a message queue to count data, while the data is sinked to a file. Then if the counter reaches X i want the old file to be closed and continue sinking in a new file. Then again if reaches X to switch to the old file. So my bottom part code looks like that:

tb = top_block()
        tb.start()
        a=0
       
        while 1:
                if tb.sink_queue.count()>X:
                        tb.gr_file_sink_0.close()
                        tb.sink_queue.flush()
                        if a==0:
                                tb.gr_file_sink_0.open("PLACE_TO_SAVE\two")
                                a=1
                        else:
                                tb.gr_file_sink_0.open("PLACE_TO_SAVE\one")
                                a=0

Right now, it simply closes the first file, but does not begin with the second one. Can anyone help me with that? Thanks in advance
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: File Sink open/close question

Robert McGwier-2
Hans:

Where are you "resetting X"?

On Tuesday, January 22, 2013, Hanz wrote:
Hi!
Im using a message queue to count data, while the data is sinked to a file.
Then if the counter reaches X i want the old file to be closed and continue
sinking in a new file. Then again if reaches X to switch to the old file. So
my bottom part code looks like that:

tb = top_block()
        tb.start()
        a=0

        while 1:
                if tb.sink_queue.count()>X:
                        tb.gr_file_sink_0.close()
                        tb.sink_queue.flush()
                        if a==0:
                                tb.gr_file_sink_0.open("PLACE_TO_SAVE\two")
                                a=1
                        else:
                                tb.gr_file_sink_0.open("PLACE_TO_SAVE\one")
                                a=0

Right now, it simply closes the first file, but does not begin with the
second one. Can anyone help me with that? Thanks in advance



--
View this message in context: http://gnuradio.4.n7.nabble.com/File-Sink-open-close-question-tp39098.html
Sent from the GnuRadio mailing list archive at Nabble.com.

_______________________________________________
Discuss-gnuradio mailing list
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;Discuss-gnuradio@gnu.org&#39;)">Discuss-gnuradio@...
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


--
Bob McGwier
Owner and Technical Director, Allied Communication, LLC
Facebook: N4HYBob
ARS: N4HY


_______________________________________________
Discuss-gnuradio mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: File Sink open/close question

Hanz
I setted X some lines before as 1000. And the tb.sink_queue.count() is resetted by tb.sink_queue.flush() i thought.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: File Sink open/close question

Tom Rondeau-2
In reply to this post by Hanz
On Tue, Jan 22, 2013 at 4:18 AM, Hanz <[hidden email]> wrote:
Hi!
Im using a message queue to count data, while the data is sinked to a file.
Then if the counter reaches X i want the old file to be closed and continue
sinking in a new file. Then again if reaches X to switch to the old file. So
my bottom part code looks like that:

tb = top_block()
        tb.start()
        a=0

        while 1:
                if tb.sink_queue.count()>X:
                        tb.gr_file_sink_0.close()
                        tb.sink_queue.flush()
                        if a==0:
                                tb.gr_file_sink_0.open("PLACE_TO_SAVE\two")
                                a=1
                        else:
                                tb.gr_file_sink_0.open("PLACE_TO_SAVE\one")
                                a=0

Right now, it simply closes the first file, but does not begin with the
second one. Can anyone help me with that? Thanks in advance

Hanz,
This shouldn't make any difference, but the file_sink's 'open' function also closes any previously opened files. Try removing your call to 'close' and just rely on the open to close it, reopen the new file, and then when the work is called the next time, it will run 'do_update' to set up the handles properly.

Also, you can try throwing in some debug prints to make sure both paths are actually being called properly.

Tom


_______________________________________________
Discuss-gnuradio mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Loading...