Writing Binary Files
The File Sink block takes incoming samples and saves them to local storage.
Block Options for Data Types
By default the File Sink block uses a 32-bit float format for saving interleaved I and Q:
Opening the block's properties, other formats can be selected from the drop down menu:
Another common type is float, represented by orange, which stores real samples as 32-bit floats.
Data may also be stored as 16-bit integers using the short type represented by yellow. Both real and complex samples may be stored with this type, which will be discussed later in this tutorial.
The File Sink also has a File parameter which needs to be defined. Click on the three dots:
On Ubuntu a window will appear which will allows navigation to different directories so the file can be saved. The file can be saved anywhere, including the home directory although for this example it is saved in /opt/tutorials and the output filename is binary_file.
The path can also be entered directly as a text string:
Note that by default a file sink uses the Overwrite function, meaning each time the flowgraph is run the binary file in that location will be replaced by all of the new samples. The Append function is described later in this tutorial.
Storing Complex 32-bit Floats
Add a Signal Source block, connect it to the File Sink and run the flowgraph for a second or two and then stop the flowgraph:
The flowgraph will not start running and will pop up a QT GUI window, but it is not populated because there are no plot blocks in the flowgraph. Data is continually being written to the file as the flowgraph is running. Close the QT GUI window to stop the flowgraph: