gnuradio.blocks: File Operators

gnuradio.blocks.file_descriptor_sink(size_t itemsize, int fd) → sptr

Write stream to file descriptor.

Constructor Specific Documentation:

Build a file descriptor sink block.

Parameters:
  • itemsize – item size of the incoming data stream.
  • fd – file descriptor (as an integer).
file_descriptor_sink_sptr.active_thread_priority(self) → int
file_descriptor_sink_sptr.set_thread_priority(self, int priority) → int
file_descriptor_sink_sptr.thread_priority(self) → int
gnuradio.blocks.file_descriptor_source(size_t itemsize, int fd, bool repeat) → sptr

Read stream from file descriptor.

Constructor Specific Documentation:

Build a file descriptor source block.

Parameters:
  • itemsize – item size of the incoming data stream.
  • fd – file descriptor (as an integer).
  • repeat – repeat the data stream continuously.
file_descriptor_source_sptr.active_thread_priority(self) → int
file_descriptor_source_sptr.set_thread_priority(self, int priority) → int
file_descriptor_source_sptr.thread_priority(self) → int
gnuradio.blocks.file_meta_sink(size_t itemsize, string filename, double samp_rate = 1, double relative_rate = 1, gr_file_types type = GR_FILE_FLOAT, bool complex = True, size_t max_segment_size = 1000000, string extra_dict = "", bool detached_header = False) → sptr

Write stream to file with meta-data headers.

These files represent data as binary information in between meta-data headers. The headers contain information about the type of data and properties of the data in the next segment of samples. The information includes:

rx_rate (double): sample rate of data. rx_time (uint64_t, double): time stamp of first sample in segment. size (uint32_t): item size in bytes. type (gr_file_types as int32_t): data type. cplx (bool): Is data complex? strt (uint64_t): Starting byte of data in this segment. bytes (uint64_t): Size in bytes of data in this segment.

Tags can be sent to the file to update the information, which will create a new header. Headers are found by searching from the first header (at position 0 in the file) and reading where the data segment starts plus the data segment size. Following will either be a new header or EOF.

Constructor Specific Documentation:

Create a meta-data file sink.

Parameters:
  • itemsize – (size_t): Size of data type.
  • filename – (string): Name of file to write data to.
  • samp_rate – (double): Sample rate of data. If sample rate will be set by a tag, such as rx_tag from a UHD source, this is basically ignored.
  • relative_rate – (double): Rate chance from source of sample rate tag to sink.
  • type – (gr_file_types): Data type (int, float, etc.)
  • complex – (bool): If data stream is complex
  • max_segment_size – (size_t): Length of a single segment before the header is repeated (in items).
  • extra_dict – (string): a serialized PMT dictionary of extra information. Currently not supported.
  • detached_header – (bool): Set to true to store the header info in a separate file (named filename.hdr)
file_meta_sink_sptr.active_thread_priority(self) → int
file_meta_sink_sptr.close(self)
file_meta_sink_sptr.do_update(self)
file_meta_sink_sptr.open(self, string filename) → bool
file_meta_sink_sptr.set_thread_priority(self, int priority) → int
file_meta_sink_sptr.set_unbuffered(self, bool unbuffered)
file_meta_sink_sptr.thread_priority(self) → int
gnuradio.blocks.file_meta_source(string filename, bool repeat = False, bool detached_header = False, string hdr_filename = "") → sptr

Reads stream from file with meta-data headers. Headers are parsed into tags.

The information in the metadata headers includes:

rx_rate (double): sample rate of data. rx_time (uint64_t, double): time stamp of first sample in segment. size (uint32_t): item size in bytes. type (gr_file_types as int32_t): data type. cplx (bool): Is data complex? strt (uint64_t): Starting byte of data in this segment. bytes (uint64_t): Size in bytes of data in this segment.

Any item inside of the extra header dictionary is ready out and made into a stream tag.

Constructor Specific Documentation:

Create a meta-data file source.

Parameters:
  • filename – (string): Name of file to write data to.
  • repeat – (bool): Repeats file when EOF is found.
  • detached_header – (bool): Set to true if header info is stored in a separate file (usually named filename.hdr)
  • hdr_filename – (string): Name of detached header file if used. Defaults to ‘filename.hdr’ if detached_header is true but this field is an empty string.
file_meta_source_sptr.active_thread_priority(self) → int
file_meta_source_sptr.close(self)
file_meta_source_sptr.do_update(self)
file_meta_source_sptr.open(self, string filename, string hdr_filename = "") → bool
file_meta_source_sptr.set_thread_priority(self, int priority) → int
file_meta_source_sptr.thread_priority(self) → int
gnuradio.blocks.file_sink(size_t itemsize, char filename) → sptr

Write stream to file.

Constructor Specific Documentation:

Make a file sink.

Parameters:
  • itemsize – size of the input data items.
  • filename – name of the file to open and write output to.
file_sink_sptr.active_thread_priority(self) → int
file_sink_sptr.close(self)

Close current output file.

Closes current output file and ignores any output until open is called to connect to another file.

file_sink_sptr.do_update(self)

if we’ve had an update, do it now.

file_sink_sptr.open(self, char filename) → bool

Open filename and begin output to it.

file_sink_sptr.set_thread_priority(self, int priority) → int
file_sink_sptr.set_unbuffered(self, bool unbuffered)

turn on unbuffered writes for slower outputs

file_sink_sptr.thread_priority(self) → int
gnuradio.blocks.file_source(size_t itemsize, char filename, bool repeat = False) → sptr

Read stream from file.

Constructor Specific Documentation:

Create a file source.

Opens as a source of items into a flowgraph. The data is expected to be in binary format, item after item. The of the block determines the conversion from bits to items.

If is turned on, the file will repeat the file after it’s reached the end.

Parameters:
  • itemsize – the size of each item in the file, in bytes
  • filename – name of the file to source from
  • repeat – repeat file from start
file_source_sptr.active_thread_priority(self) → int
file_source_sptr.close(self)

Close the file handle.

file_source_sptr.open(self, char filename, bool repeat)

Opens a new file.

file_source_sptr.seek(self, long seek_point, int whence) → bool

seek file to relative to

file_source_sptr.set_thread_priority(self, int priority) → int
file_source_sptr.thread_priority(self) → int
gnuradio.blocks.tagged_file_sink(size_t itemsize, double samp_rate) → sptr

A file sink that uses tags to save files.

The sink uses a tag with the key ‘burst’ to trigger the saving of the burst data to a new file. If the value of this tag is True, it will open a new file and start writing all incoming data to it. If the tag is False, it will close the file (if already opened). The file names are based on the time when the burst tag was seen. If there is an ‘rx_time’ tag (standard with UHD sources), that is used as the time. If no ‘rx_time’ tag is found, the new time is calculated based off the sample rate of the block.

Constructor Specific Documentation:

Build a tagged_file_sink block.

Parameters:
  • itemsize – The item size of the input data stream.
  • samp_rate – The sample rate used to determine the time difference between bursts
tagged_file_sink_sptr.active_thread_priority(self) → int
tagged_file_sink_sptr.set_thread_priority(self, int priority) → int
tagged_file_sink_sptr.thread_priority(self) → int

Previous topic

gnuradio.blocks: Data Type Converters

Next topic

gnuradio.blocks: Message Tools

This Page