Skip to content

GNRC Tutorial Wiki Part 3: GNRC "blocks"

tandersn edited this page Nov 26, 2022 · 8 revisions

Blocks

Everything in GNRC relies on "blocks" and connecting them together. There are lots of different types of blocks ranging from very simple, to extremely complex. I'm going to go over some information about "blocks" here.

Sometimes you "know" the block you need, like "file source" (a simple and common block). You can click the magnifying glass symbol to open a search box, and just start typing that in the search and a list of matching blocks will be shown. If you hover the mouse over an item in the list, it will give you details:

If you "don't know" what block you need, you can search for similar terms, like if you want some kind of GUI control, but don't know the name, you can search for "QT" in the search box (provided you are in a QT GUI project, which is the default) and it will show you a list. As a last resort, you just read through all the blocks until you find the one you need. Or google can help sometimes...

Throttle Block

The throttle block is useful when you need to limit the rate at which the signal is processed, this is usually used to simply limit CPU utilized, but has a special purpose in relation to the Video SDL Sink block (we'll address this later).


Rail Block

When converting ranges to prepare for output data types (like to convert u16 float values to u8 Video SDL values as we will do in the first graph creation exercise), it's always a good idea to incorporate a rail block and set the values for the target data type (0 - 255 for uchar). When doing the maths, sometimes the resultant values will be outside the desired range, and will cause clipping, which will distort the signal.

Things to know about blocks:

  • Some blocks can have their input and output types changed if you double click them and look at their properties, changing the data type will change the color of the connectors. E.g., a File Sink block can have the input be set to the following types:
    • Byte (purple)
    • Short (yellow)
    • Int (green)
    • Float (orange)
    • Complex (blue)
  • Blocks that end in source are input or generating blocks.
    • Signal source generates a signal.
    • File Source inputs data from a file.
  • Blocks that end in sink are output or destinations blocks.
    • Null Sink inputs samples and sends them to oblivion (like /dev/null).
    • File Sink sends data out to a file.
  • Blocks that have QT in the name have some kind of visual component in the GUI.
    • QT Waterfall Sink is a visual spectrogram.
    • QT range is a slider that allows changing values during run time.
  • Blocks will only connect if their color connector is the same.
    • uchar to float will only connect to purple blocks on the input, and orange blocks on the output.
    • float to uchar will only connect to orange blocks on the input, and `purple blocks on the output.
  • You can use the UP and DOWN arrow keys as a shortcut to change the block data type.
  • You can use the RIGHT and LEFT arrow keys to rotate blocks adjusting where their input and output connectors are.