Reading Binary Files: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:


==File Source Block==
==File Source Block==
The File Source block reads from a binary file and then sends the samples to the output port. Drag the File Source block into a flowgraph. The block by default uses the complex data type (32-bit floats), represented by the '''<span style="color:blue">blue</span>''' output port:
The '''File Source''' block reads from a binary file and then sends the samples to the output port. Drag the '''File Source''' block into a flowgraph. The block by default uses the complex data type (32-bit floats), represented by the '''<span style="color:blue">blue</span>''' output port:


[[File:Reading_binary_files_add_complex_float_file_source.png]]
[[File:Reading_binary_files_add_complex_float_file_source.png]]




Double clicking the File Source block brings up the properties and the ability to select different data types.
Double clicking the '''File Source''' block brings up the properties and the ability to select different data types.


[[File:Reading_binary_files_file_source_data_types.png]]
[[File:Reading_binary_files_file_source_data_types.png]]
Line 28: Line 28:




Also note that the '''File Sink''' has the ''Repeat'' field enabled as ''Yes'', which will continually and repeatedly play back the same file. Once the last sample is received in the file it skips back to the first sample in the file and continues cycling through the file.
Also note that the '''File Source''' has the ''Repeat'' field enabled as ''Yes'', which will continually and repeatedly play back the same file. Once the last sample is received in the file it skips back to the first sample in the file and continues cycling through the file.


[[File:Reading_binary_files_repeat_yes.png]]
[[File:Reading_binary_files_repeat_yes.png]]

Revision as of 14:36, 20 April 2024

This tutorial describes how to read binary files using the File Source block along side how to diagnose potential errors.

Please review the Writing Binary Files tutorial before continuing. A series of binary files were created with different formats that will be needed for this tutorial:

Reading binary files all formats.png


File Source Block

The File Source block reads from a binary file and then sends the samples to the output port. Drag the File Source block into a flowgraph. The block by default uses the complex data type (32-bit floats), represented by the blue output port:

Reading binary files add complex float file source.png


Double clicking the File Source block brings up the properties and the ability to select different data types.

Reading binary files file source data types.png


A binary file of real floating point data requires the float data type to be selected, which outputs real floating point samples, denoted by an orange output port.

Reading binary files file sink real float.png


A binary file of 16-bit signed integers requires the short data type to be selected, which outputs 16-bit integers of either real or interleaved I and Q samples (more on this later in the tutorial), denoted by a yellow output port.

Reading binary files file sink real short.png


Also note that the File Source has the Repeat field enabled as Yes, which will continually and repeatedly play back the same file. Once the last sample is received in the file it skips back to the first sample in the file and continues cycling through the file.

Reading binary files repeat yes.png


Reading Complex Float Binary File

Add a File Source block, open the properties and begin by selecting the complex type.