[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] filename using time-stamp in GRC
From: |
ematlis |
Subject: |
Re: [Discuss-gnuradio] filename using time-stamp in GRC |
Date: |
Thu, 20 Jan 2011 08:41:07 -0800 (PST) |
--- On Wed, 1/19/11, address@hidden <address@hidden> wrote:
> From: address@hidden <address@hidden>
> Subject: [Discuss-gnuradio] filename using time-stamp in GRC
> To: address@hidden
> Date: Wednesday, January 19, 2011, 12:47 PM
> He all-
>
> is there a way to implement a button controlling a
> record-to-file function where the filename is generated
> instantly from the current time stamp? I can do this
> manually in python as follows (taken from a previously
> existing gnuradio code):
>
> #
> # Recording file, in case we
> ever need to record baseband data
> #
> self.recording =
> gr.file_sink(gr.sizeof_float, "/dev/null")
> self.recording_state = False
> # Filename prefix for recording
> file
> self.prefix = options.prefix
>
> # We come up with recording
> turned off, but the user may
> # request recording later
> on
> self.recording.close()
>
> .
> .
> .
>
> self.connect (self.source,
> self.recording)
>
> .
> .
> .
>
> # Data recording control
> buttonbox =
> wx.BoxSizer(wx.HORIZONTAL)
> self.record_control =
> form.button_with_callback(self.panel,
>
> label="Recording Data: Off
>
>
>
> ",
>
> callback=self.toggle_recording)
>
>
> buttonbox.Add(self.record_control, 0, wx.CENTER)
>
> .
> .
> .
>
> #
> # Turn recording on/off
> # Called-back by "Recording" button
> #
> def toggle_recording(self):
> # Pick up localtime, for
> generating filenames
> timestamp = time.localtime()
>
> # Generate filenames for both
> data and header file
> filename =
> "%04d_%02d_%02d_%02d:%02d:%02d.dat" % (timestamp.tm_year,
> timestamp.tm_mon,
> timestamp.tm_mday,
> timestamp.tm_hour, timestamp.tm_min,timestamp.tm_sec)
>
> # Current recording? Flip
> state
> if (self.recording_state ==
> True):
> self.recording_state =
> False
>
> self.record_control.SetLabel("Recording Data: Off
>
>
>
> ")
> self.recording.close()
> # Not recording?
> else:
> self.recording_state =
> True
>
> self.record_control.SetLabel("Recording Data to:
> "+filename)
>
> # Cause gr_file_sink
> object to accept new filename
> # note
> use of self.prefix--filename prefix from
>
> # command line (defaults to ./)
> #
> self.recording.open
> (self.prefix+filename)
>
>
> Thanks!
> eric
>
Following up on this, I found this site that had some useful
suggestions:http://www.oz9aec.net/index.php/gnu-radio/grc-examples
A grc example is provided that implements a dynamic time stamp, but NOT a
button to control it. So I am trying to use a Variable Chooser to select
between "/dev/null" and the filename that is based on the time-stamp. However,
nothing is generated. In particular, I have:
A file sink with File: recfile
A Variable with ID prefix with Value "./"
A Variable Chooser with ID: recfile, Default Value: "/dev/null" and
Choices of "/dev/null" or "prefix +
datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".bin"
I was hoping this would dynamically create a file with the current time stamp
for the name, but no files are actually being generated. Could this be and
issue related to a bug that is described in the link below?
http://lists.gnu.org/archive/html/discuss-gnuradio/2011-01/msg00080.html
If so, will this approach work if I upgrade via git?
Thanks!
eric
>
>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>