I have two high-speed sampling devices that can use UDP (through 1G Ethernet) and PCIe to transmmit their samples, respectively. They are used to record signals I interested. These devices are made by myself so the data format and the software running on OS are easy to be modified. Now I want to use GNU radio to demodulate some signals from the devices in real-time but I don't now the interface and format of GNU Radio. Is it possible to do that? Is it necessary to read or even modify its source code? And which document should I read?



2 Answers 2


Here are several different approaches you can take.

  • You can write a GNU Radio source block which knows how to interact with your particular device. This does not require modifying GNU Radio's source code: you can compile your block separately, in which case it is known as an out of tree module; here's a tutorial.

    This custom source block would be written in C++ (or Python, though there are some restrictions in that case) and gets a thread of its own in which it can do whatever is necessary to obtain samples from the hardware.

    The advantage of this method is that you can write methods on the source to control the device and handle special events using stream tags and message ports. The disadvantage is that you're writing more custom code, including the application that uses your block.

  • You can use one of the existing general-purpose source blocks.

    • The UDP source block simply takes the content of UDP datagrams and puts them into the GR flow graph. You can use this immediately with your UDP-based device if it has no high-level protocol carried within the datagrams.

    • You could also have your application open a connection to the device in whatever way, before the flow graph is started, and then use the file descriptor source; this works if you have some way to open your device as a file (/dev/something or a pipe from another process/thread doing the reading). If you use stdin (file descriptor 0) then you don't need extra code inside the process, so you can use GNU Radio Companion, and set up a pipe like ./my-device-reader | ./my-grc-flowgraph.py.

    • If your PCIe device can be made to look like a standard audio device, then you could use the audio source block. I suspect that you would find that audio driver systems aren't designed to work well at the sample rates you want; I just mention this to give another example of ways to use existing source blocks.

    The advantage of this method is that you don't have to write as much code, and you might find the generic interfaces useful (e.g. piping your samples into something that's not written in GNU Radio instead). The disadvantage is that you can't control the device or use any particular features beyond the stream of samples, because the generic source block doesn't know about the features of your device.

  • If your hardware is mostly like typical software radio peripherals, you could modify gr-osmosdr to support it. This is of comparable difficulty to writing a custom source block, but has the advantage that your hardware can be used with existing applications that use gr-osmosdr as their generic hardware interface. The disadvantage is that you are limited to gr-osmosdr's interface for controlling the device.

  • Since you say you can change the hardware's protocols, you can also simply change them to use the same protocol as an existing radio peripheral. This is excellent for compatibility, since no new “driver” software is required at all, but runs the risk of your reimplementation being subtly incompatible (if there is no formal protocol documentation) and may not allow you to add features that the device you are imitating does not have.


GNU Radio does not implement any interface or format itself. That would be the responsibility of some block.

There are any number of blocks you might choose. There is a very simple udp_source which could work.

You could also try to make your SDR compatible with an existing ethernet SDR. A couple you might consider:

Alternately, you can always implement your own GNU Radio block, using whatever network format you want.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .