Skip to content

Instantly share code, notes, and snippets.

@gbevan
Last active June 2, 2022 08:47
Show Gist options
  • Save gbevan/8e583b9cf87aa3c58102251454fa48a6 to your computer and use it in GitHub Desktop.
Save gbevan/8e583b9cf87aa3c58102251454fa48a6 to your computer and use it in GitHub Desktop.
Gnuradio 3.8 on Ubuntu 18.04

Installing gnuradio 3.8 (2019-10-09)

from: https://stackoverflow.com/questions/57678068/installing-gnuradio-3-8-on-ubuntu-18-04

Setup PyBOMBS

sudo apt-get install python-pip python-apt
sudo -H pip install PyBOMBS
mkdir ~/sdr
cd ~/sdr
pybombs auto-config
pybombs recipes add gr-recipes git+https://github.com/gnuradio/gr-recipes.git
pybombs recipes add gr-etcetera git+https://github.com/gnuradio/gr-etcetera.git
pybombs prefix init ~/sdr

Edit setup_env.sh for python3

sed -i 's/2\.6/3.6/g' setup_env.sh
sed -i 's/2\.7/3/g' setup_env.sh

Edit gnuradio recipe

  • Edit ~/.pybombs/recipes/gr-recipes/gnuradio.lwr
  • Ensure the "gitbranch" is maint-3.8.
  • In gnuradio.lwr recipe file, add "-DENABLE_CTRLPORT_THRIFT=OFF" in "config_opt".

Install uhd and prereqs

source ~/sdr/setup_env.sh
pybombs install uhd
sudo apt install git cmake g++ libboost-all-dev libgmp-dev \
  swig python3-numpy python3-mako python3-sphinx python3-lxml \
  doxygen libfftw3-dev libcomedi-dev libsdl1.2-dev libgsl-dev \
  libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 liblog4cpp5-dev \
  libzmq3-dev python3-yaml python3-click python3-click-plugins

Install gnuradio 3.8

pybombs install gnuradio

Fix gr-osmosdr and gr-iqbal

gr-iqbal

category: common
depends:
- gnuradio
- libosmo-dsp
description: Gnuradio I/Q balancing
#gitbranch: master
gitbranch: maint-3.8
inherit: cmake
# Let's always build this from source, not binaries
#source: git+https://git.osmocom.org/gr-iqbal
source: git+https://github.com/velichkov/gr-iqbal.git

gr-osmosdr

category: common
depends:
- uhd
- rtl-sdr
- osmo-sdr
- hackrf
- gnuradio
- gr-iqbal
- bladeRF
- airspy
- soapysdr
description: Interface API independent of the underlying radio hardware
#gitbranch: master
gitbranch: maint-3.8
inherit: cmake
# Let's always build this from source, not binaries
#source: git+https://git.osmocom.org/gr-osmosdr
source: git+https://github.com/velichkov/gr-osmosdr.git

Install gr-osmosdr

pybombs install gr-osmosdr

Running gnuradio-companion

source ~/sdr/setup_env.sh
gnuradio-companion
@arildj78
Copy link

arildj78 commented Dec 28, 2019

I was able to follow until "Fix gr-osmosdr and gr-iqbal"
I don't understand what to do here. @gbevan can you elaborate on this paragraph?

@mugichiya
Copy link

mugichiya commented Jan 7, 2020

Hi, @arildj78. (@sheltie03)
It means that you need comment out the default "gitbranch" / "source" and add new to the following two files.

  • ~/.pybombs/recipes/gr-recipes/gr-osmosdr.lwr
  • ~/.pybombs/recipes/gr-recipes/gr-iqbal.lwr

/verifsec

@hackery
Copy link

hackery commented Jan 15, 2020

Is there an alternative to the install commands to be able to keep artifacts in the build directory and test from there, without conflicting with system packages?

@dakota56
Copy link

dakota56 commented Apr 1, 2020

I had a failure when I installed UHD (after pybombs install uhd) . So I followed this advice : https://stackoverflow.com/questions/53176599/troubles-with-gnu-radio-installation-from-source

t seems that the issue happens when you have both python2 and python3 installed. In that case, the cmake script in (UHDSRC)/host/python/CMakeLists.txt erroneously defaults to python3.

I have fixed the issue by replacing the mention of ${PYTHON_EXECUTABLE} around line 68 with ${PYTHON2_EXECUTABLE}

After that everything worked fine

Thanks again

Dimitri

@Clem-acc
Copy link

I am still at a loss on where to fix gr-iqbal and gr-osmosdr. what has to be edited, exactly?

@dakota56
Copy link

edit
~/.pybombs/recipes/gr-recipes/gr-osmosdr.lwr
and
~/.pybombs/recipes/gr-recipes/gr-iqbal.lwr

@beckdac
Copy link

beckdac commented May 8, 2020

Confirmed works. Thank you for this.

@Gm618
Copy link

Gm618 commented May 10, 2020

Hello,

When I try to use the osmocom_sink the following error shows up:

Generating: '/home/ubuntu18/sdr/share/gnuradio/examples/digital/ofdm/tx_ofdm.py'
Generate Error: (NameError("'dc_offset_mode20' is not defined",), 'osmosdr.sink(\n args="numchan=" + str(${nchan}) + " " + ${args}\n)\n% if context.get('num_mboards')() > 0:\n% if context.get('clock_source0')():\nself.${id}.set_clock_source(${clock_source0}, 0)\n% endif\n% if context.get('time_source0')():\nself.${id}.set_time_source(${time_source0}, 0)\n% endif\n% endif\n% if context.get('num_mboards')() > 1:\n% if context.get('clock_source1')():\nself.${id}.set_clock_source(${clock_source1}, 1)\n% endif\n% if context.get('time_source1')():\nself.${id}.set_time_source(${time_source1}, 1)\n% endif\n% endif\n% if context.get('num_mboards')() > 2:\n% if context.get('clock_source2')():\nself.${id}.set_clock_source(${clock_source2}, 2)\n% endif\n% if context.get('time_source2')():\nself.${id}.set_time_source(${time_source2}, 2)\n% endif\n% endif\n% if context.get('num_mboards')() > 3:\n% if context.get('clock_source3')():\nself.${id}.set_clock_source(${clock_source3}, 3)\n% endif\n% if context.get('time_source3')():\nself.${id}.set_time_source(${time_source3}, 3)\n% endif\n% endif\n% if context.get('num_mboards')() > 4:\n% if context.get('clock_source4')():\nself.${id}.set_clock_source(${clock_source4}, 4)\n% endif\n% if context.get('time_source4')():\nself.${id}.set_time_source(${time_source4}, 4)\n% endif\n% endif\n% if context.get('num_mboards')() > 5:\n% if context.get('clock_source5')():\nself.${id}.set_clock_source(${clock_source5}, 5)\n% endif\n% if context.get('time_source5')():\nself.${id}.set_time_source(${time_source5}, 5)\n% endif\n% endif\n% if context.get('num_mboards')() > 6:\n% if context.get('clock_source6')():\nself.${id}.set_clock_source(${clock_source6}, 6)\n% endif\n% if context.get('time_source6')():\nself.${id}.set_time_source(${time_source6}, 6)\n% endif\n% endif\n% if context.get('num_mboards')() > 7:\n% if context.get('clock_source7')():\nself.${id}.set_clock_source(${clock_source7}, 7)\n% endif\n% if context.get('time_source7')():\nself.${id}.set_time_source(${time_source7}, 7)\n% endif\n% endif\n% if sync == 'sync':\nself.${id}.set_time_unknown_pps(osmosdr.time_spec_t())\n% elif sync == 'pc_clock':\nself.${id}.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS)\n% endif\nself.${id}.set_sample_rate(${sample_rate})\n% if context.get('nchan')() > 0:\nself.${id}.set_center_freq(${freq0}, 0)\nself.${id}.set_freq_corr(${corr0}, 0)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode0}, 0)\nself.${id}.set_iq_balance_mode(${iq_balance_mode0}, 0)\nself.${id}.set_gain_mode(${gain_mode0}, 0)\n% endif\nself.${id}.set_gain(${gain0}, 0)\nself.${id}.set_if_gain(${if_gain0}, 0)\nself.${id}.set_bb_gain(${bb_gain0}, 0)\nself.${id}.set_antenna(${ant0}, 0)\nself.${id}.set_bandwidth(${bw0}, 0)\n% endif\n% if context.get('nchan')() > 1:\nself.${id}.set_center_freq(${freq1}, 1)\nself.${id}.set_freq_corr(${corr1}, 1)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode1}, 1)\nself.${id}.set_iq_balance_mode(${iq_balance_mode1}, 1)\nself.${id}.set_gain_mode(${gain_mode1}, 1)\n% endif\nself.${id}.set_gain(${gain1}, 1)\nself.${id}.set_if_gain(${if_gain1}, 1)\nself.${id}.set_bb_gain(${bb_gain1}, 1)\nself.${id}.set_antenna(${ant1}, 1)\nself.${id}.set_bandwidth(${bw1}, 1)\n% endif\n% if context.get('nchan')() > 2:\nself.${id}.set_center_freq(${freq2}, 2)\nself.${id}.set_freq_corr(${corr2}, 2)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode2}, 2)\nself.${id}.set_iq_balance_mode(${iq_balance_mode2}, 2)\nself.${id}.set_gain_mode(${gain_mode2}, 2)\n% endif\nself.${id}.set_gain(${gain2}, 2)\nself.${id}.set_if_gain(${if_gain2}, 2)\nself.${id}.set_bb_gain(${bb_gain2}, 2)\nself.${id}.set_antenna(${ant2}, 2)\nself.${id}.set_bandwidth(${bw2}, 2)\n% endif\n% if context.get('nchan')() > 3:\nself.${id}.set_center_freq(${freq3}, 3)\nself.${id}.set_freq_corr(${corr3}, 3)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode3}, 3)\nself.${id}.set_iq_balance_mode(${iq_balance_mode3}, 3)\nself.${id}.set_gain_mode(${gain_mode3}, 3)\n% endif\nself.${id}.set_gain(${gain3}, 3)\nself.${id}.set_if_gain(${if_gain3}, 3)\nself.${id}.set_bb_gain(${bb_gain3}, 3)\nself.${id}.set_antenna(${ant3}, 3)\nself.${id}.set_bandwidth(${bw3}, 3)\n% endif\n% if context.get('nchan')() > 4:\nself.${id}.set_center_freq(${freq4}, 4)\nself.${id}.set_freq_corr(${corr4}, 4)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode4}, 4)\nself.${id}.set_iq_balance_mode(${iq_balance_mode4}, 4)\nself.${id}.set_gain_mode(${gain_mode4}, 4)\n% endif\nself.${id}.set_gain(${gain4}, 4)\nself.${id}.set_if_gain(${if_gain4}, 4)\nself.${id}.set_bb_gain(${bb_gain4}, 4)\nself.${id}.set_antenna(${ant4}, 4)\nself.${id}.set_bandwidth(${bw4}, 4)\n% endif\n% if context.get('nchan')() > 5:\nself.${id}.set_center_freq(${freq5}, 5)\nself.${id}.set_freq_corr(${corr5}, 5)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode5}, 5)\nself.${id}.set_iq_balance_mode(${iq_balance_mode5}, 5)\nself.${id}.set_gain_mode(${gain_mode5}, 5)\n% endif\nself.${id}.set_gain(${gain5}, 5)\nself.${id}.set_if_gain(${if_gain5}, 5)\nself.${id}.set_bb_gain(${bb_gain5}, 5)\nself.${id}.set_antenna(${ant5}, 5)\nself.${id}.set_bandwidth(${bw5}, 5)\n% endif\n% if context.get('nchan')() > 6:\nself.${id}.set_center_freq(${freq6}, 6)\nself.${id}.set_freq_corr(${corr6}, 6)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode6}, 6)\nself.${id}.set_iq_balance_mode(${iq_balance_mode6}, 6)\nself.${id}.set_gain_mode(${gain_mode6}, 6)\n% endif\nself.${id}.set_gain(${gain6}, 6)\nself.${id}.set_if_gain(${if_gain6}, 6)\nself.${id}.set_bb_gain(${bb_gain6}, 6)\nself.${id}.set_antenna(${ant6}, 6)\nself.${id}.set_bandwidth(${bw6}, 6)\n% endif\n% if context.get('nchan')() > 7:\nself.${id}.set_center_freq(${freq7}, 7)\nself.${id}.set_freq_corr(${corr7}, 7)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode7}, 7)\nself.${id}.set_iq_balance_mode(${iq_balance_mode7}, 7)\nself.${id}.set_gain_mode(${gain_mode7}, 7)\n% endif\nself.${id}.set_gain(${gain7}, 7)\nself.${id}.set_if_gain(${if_gain7}, 7)\nself.${id}.set_bb_gain(${bb_gain7}, 7)\nself.${id}.set_antenna(${ant7}, 7)\nself.${id}.set_bandwidth(${bw7}, 7)\n% endif\n% if context.get('nchan')() > 8:\nself.${id}.set_center_freq(${freq8}, 8)\nself.${id}.set_freq_corr(${corr8}, 8)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode8}, 8)\nself.${id}.set_iq_balance_mode(${iq_balance_mode8}, 8)\nself.${id}.set_gain_mode(${gain_mode8}, 8)\n% endif\nself.${id}.set_gain(${gain8}, 8)\nself.${id}.set_if_gain(${if_gain8}, 8)\nself.${id}.set_bb_gain(${bb_gain8}, 8)\nself.${id}.set_antenna(${ant8}, 8)\nself.${id}.set_bandwidth(${bw8}, 8)\n% endif\n% if context.get('nchan')() > 9:\nself.${id}.set_center_freq(${freq9}, 9)\nself.${id}.set_freq_corr(${corr9}, 9)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode9}, 9)\nself.${id}.set_iq_balance_mode(${iq_balance_mode9}, 9)\nself.${id}.set_gain_mode(${gain_mode9}, 9)\n% endif\nself.${id}.set_gain(${gain9}, 9)\nself.${id}.set_if_gain(${if_gain9}, 9)\nself.${id}.set_bb_gain(${bb_gain9}, 9)\nself.${id}.set_antenna(${ant9}, 9)\nself.${id}.set_bandwidth(${bw9}, 9)\n% endif\n% if context.get('nchan')() > 10:\nself.${id}.set_center_freq(${freq10}, 10)\nself.${id}.set_freq_corr(${corr10}, 10)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode10}, 10)\nself.${id}.set_iq_balance_mode(${iq_balance_mode10}, 10)\nself.${id}.set_gain_mode(${gain_mode10}, 10)\n% endif\nself.${id}.set_gain(${gain10}, 10)\nself.${id}.set_if_gain(${if_gain10}, 10)\nself.${id}.set_bb_gain(${bb_gain10}, 10)\nself.${id}.set_antenna(${ant10}, 10)\nself.${id}.set_bandwidth(${bw10}, 10)\n% endif\n% if context.get('nchan')() > 11:\nself.${id}.set_center_freq(${freq11}, 11)\nself.${id}.set_freq_corr(${corr11}, 11)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode11}, 11)\nself.${id}.set_iq_balance_mode(${iq_balance_mode11}, 11)\nself.${id}.set_gain_mode(${gain_mode11}, 11)\n% endif\nself.${id}.set_gain(${gain11}, 11)\nself.${id}.set_if_gain(${if_gain11}, 11)\nself.${id}.set_bb_gain(${bb_gain11}, 11)\nself.${id}.set_antenna(${ant11}, 11)\nself.${id}.set_bandwidth(${bw11}, 11)\n% endif\n% if context.get('nchan')() > 12:\nself.${id}.set_center_freq(${freq12}, 12)\nself.${id}.set_freq_corr(${corr12}, 12)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode12}, 12)\nself.${id}.set_iq_balance_mode(${iq_balance_mode12}, 12)\nself.${id}.set_gain_mode(${gain_mode12}, 12)\n% endif\nself.${id}.set_gain(${gain12}, 12)\nself.${id}.set_if_gain(${if_gain12}, 12)\nself.${id}.set_bb_gain(${bb_gain12}, 12)\nself.${id}.set_antenna(${ant12}, 12)\nself.${id}.set_bandwidth(${bw12}, 12)\n% endif\n% if context.get('nchan')() > 13:\nself.${id}.set_center_freq(${freq13}, 13)\nself.${id}.set_freq_corr(${corr13}, 13)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode13}, 13)\nself.${id}.set_iq_balance_mode(${iq_balance_mode13}, 13)\nself.${id}.set_gain_mode(${gain_mode13}, 13)\n% endif\nself.${id}.set_gain(${gain13}, 13)\nself.${id}.set_if_gain(${if_gain13}, 13)\nself.${id}.set_bb_gain(${bb_gain13}, 13)\nself.${id}.set_antenna(${ant13}, 13)\nself.${id}.set_bandwidth(${bw13}, 13)\n% endif\n% if context.get('nchan')() > 14:\nself.${id}.set_center_freq(${freq14}, 14)\nself.${id}.set_freq_corr(${corr14}, 14)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode14}, 14)\nself.${id}.set_iq_balance_mode(${iq_balance_mode14}, 14)\nself.${id}.set_gain_mode(${gain_mode14}, 14)\n% endif\nself.${id}.set_gain(${gain14}, 14)\nself.${id}.set_if_gain(${if_gain14}, 14)\nself.${id}.set_bb_gain(${bb_gain14}, 14)\nself.${id}.set_antenna(${ant14}, 14)\nself.${id}.set_bandwidth(${bw14}, 14)\n% endif\n% if context.get('nchan')() > 15:\nself.${id}.set_center_freq(${freq15}, 15)\nself.${id}.set_freq_corr(${corr15}, 15)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode15}, 15)\nself.${id}.set_iq_balance_mode(${iq_balance_mode15}, 15)\nself.${id}.set_gain_mode(${gain_mode15}, 15)\n% endif\nself.${id}.set_gain(${gain15}, 15)\nself.${id}.set_if_gain(${if_gain15}, 15)\nself.${id}.set_bb_gain(${bb_gain15}, 15)\nself.${id}.set_antenna(${ant15}, 15)\nself.${id}.set_bandwidth(${bw15}, 15)\n% endif\n% if context.get('nchan')() > 16:\nself.${id}.set_center_freq(${freq16}, 16)\nself.${id}.set_freq_corr(${corr16}, 16)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode16}, 16)\nself.${id}.set_iq_balance_mode(${iq_balance_mode16}, 16)\nself.${id}.set_gain_mode(${gain_mode16}, 16)\n% endif\nself.${id}.set_gain(${gain16}, 16)\nself.${id}.set_if_gain(${if_gain16}, 16)\nself.${id}.set_bb_gain(${bb_gain16}, 16)\nself.${id}.set_antenna(${ant16}, 16)\nself.${id}.set_bandwidth(${bw16}, 16)\n% endif\n% if context.get('nchan')() > 17:\nself.${id}.set_center_freq(${freq17}, 17)\nself.${id}.set_freq_corr(${corr17}, 17)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode17}, 17)\nself.${id}.set_iq_balance_mode(${iq_balance_mode17}, 17)\nself.${id}.set_gain_mode(${gain_mode17}, 17)\n% endif\nself.${id}.set_gain(${gain17}, 17)\nself.${id}.set_if_gain(${if_gain17}, 17)\nself.${id}.set_bb_gain(${bb_gain17}, 17)\nself.${id}.set_antenna(${ant17}, 17)\nself.${id}.set_bandwidth(${bw17}, 17)\n% endif\n% if context.get('nchan')() > 18:\nself.${id}.set_center_freq(${freq18}, 18)\nself.${id}.set_freq_corr(${corr18}, 18)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode18}, 18)\nself.${id}.set_iq_balance_mode(${iq_balance_mode18}, 18)\nself.${id}.set_gain_mode(${gain_mode18}, 18)\n% endif\nself.${id}.set_gain(${gain18}, 18)\nself.${id}.set_if_gain(${if_gain18}, 18)\nself.${id}.set_bb_gain(${bb_gain18}, 18)\nself.${id}.set_antenna(${ant18}, 18)\nself.${id}.set_bandwidth(${bw18}, 18)\n% endif\n% if context.get('nchan')() > 19:\nself.${id}.set_center_freq(${freq19}, 19)\nself.${id}.set_freq_corr(${corr19}, 19)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode19}, 19)\nself.${id}.set_iq_balance_mode(${iq_balance_mode19}, 19)\nself.${id}.set_gain_mode(${gain_mode19}, 19)\n% endif\nself.${id}.set_gain(${gain19}, 19)\nself.${id}.set_if_gain(${if_gain19}, 19)\nself.${id}.set_bb_gain(${bb_gain19}, 19)\nself.${id}.set_antenna(${ant19}, 19)\nself.${id}.set_bandwidth(${bw19}, 19)\n% endif\n% if context.get('nchan')() > 20:\nself.${id}.set_center_freq(${freq20}, 20)\nself.${id}.set_freq_corr(${corr20}, 20)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode20}, 20)\nself.${id}.set_iq_balance_mode(${iq_balance_mode20}, 20)\nself.${id}.set_gain_mode(${gain_mode20}, 20)\n% endif\nself.${id}.set_gain(${gain20}, 20)\nself.${id}.set_if_gain(${if_gain20}, 20)\nself.${id}.set_bb_gain(${bb_gain20}, 20)\nself.${id}.set_antenna(${ant20}, 20)\nself.${id}.set_bandwidth(${bw20}, 20)\n% endif\n% if context.get('nchan')() > 21:\nself.${id}.set_center_freq(${freq21}, 21)\nself.${id}.set_freq_corr(${corr21}, 21)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode21}, 21)\nself.${id}.set_iq_balance_mode(${iq_balance_mode21}, 21)\nself.${id}.set_gain_mode(${gain_mode21}, 21)\n% endif\nself.${id}.set_gain(${gain21}, 21)\nself.${id}.set_if_gain(${if_gain21}, 21)\nself.${id}.set_bb_gain(${bb_gain21}, 21)\nself.${id}.set_antenna(${ant21}, 21)\nself.${id}.set_bandwidth(${bw21}, 21)\n% endif\n% if context.get('nchan')() > 22:\nself.${id}.set_center_freq(${freq22}, 22)\nself.${id}.set_freq_corr(${corr22}, 22)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode22}, 22)\nself.${id}.set_iq_balance_mode(${iq_balance_mode22}, 22)\nself.${id}.set_gain_mode(${gain_mode22}, 22)\n% endif\nself.${id}.set_gain(${gain22}, 22)\nself.${id}.set_if_gain(${if_gain22}, 22)\nself.${id}.set_bb_gain(${bb_gain22}, 22)\nself.${id}.set_antenna(${ant22}, 22)\nself.${id}.set_bandwidth(${bw22}, 22)\n% endif\n% if context.get('nchan')() > 23:\nself.${id}.set_center_freq(${freq23}, 23)\nself.${id}.set_freq_corr(${corr23}, 23)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode23}, 23)\nself.${id}.set_iq_balance_mode(${iq_balance_mode23}, 23)\nself.${id}.set_gain_mode(${gain_mode23}, 23)\n% endif\nself.${id}.set_gain(${gain23}, 23)\nself.${id}.set_if_gain(${if_gain23}, 23)\nself.${id}.set_bb_gain(${bb_gain23}, 23)\nself.${id}.set_antenna(${ant23}, 23)\nself.${id}.set_bandwidth(${bw23}, 23)\n% endif\n% if context.get('nchan')() > 24:\nself.${id}.set_center_freq(${freq24}, 24)\nself.${id}.set_freq_corr(${corr24}, 24)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode24}, 24)\nself.${id}.set_iq_balance_mode(${iq_balance_mode24}, 24)\nself.${id}.set_gain_mode(${gain_mode24}, 24)\n% endif\nself.${id}.set_gain(${gain24}, 24)\nself.${id}.set_if_gain(${if_gain24}, 24)\nself.${id}.set_bb_gain(${bb_gain24}, 24)\nself.${id}.set_antenna(${ant24}, 24)\nself.${id}.set_bandwidth(${bw24}, 24)\n% endif\n% if context.get('nchan')() > 25:\nself.${id}.set_center_freq(${freq25}, 25)\nself.${id}.set_freq_corr(${corr25}, 25)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode25}, 25)\nself.${id}.set_iq_balance_mode(${iq_balance_mode25}, 25)\nself.${id}.set_gain_mode(${gain_mode25}, 25)\n% endif\nself.${id}.set_gain(${gain25}, 25)\nself.${id}.set_if_gain(${if_gain25}, 25)\nself.${id}.set_bb_gain(${bb_gain25}, 25)\nself.${id}.set_antenna(${ant25}, 25)\nself.${id}.set_bandwidth(${bw25}, 25)\n% endif\n% if context.get('nchan')() > 26:\nself.${id}.set_center_freq(${freq26}, 26)\nself.${id}.set_freq_corr(${corr26}, 26)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode26}, 26)\nself.${id}.set_iq_balance_mode(${iq_balance_mode26}, 26)\nself.${id}.set_gain_mode(${gain_mode26}, 26)\n% endif\nself.${id}.set_gain(${gain26}, 26)\nself.${id}.set_if_gain(${if_gain26}, 26)\nself.${id}.set_bb_gain(${bb_gain26}, 26)\nself.${id}.set_antenna(${ant26}, 26)\nself.${id}.set_bandwidth(${bw26}, 26)\n% endif\n% if context.get('nchan')() > 27:\nself.${id}.set_center_freq(${freq27}, 27)\nself.${id}.set_freq_corr(${corr27}, 27)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode27}, 27)\nself.${id}.set_iq_balance_mode(${iq_balance_mode27}, 27)\nself.${id}.set_gain_mode(${gain_mode27}, 27)\n% endif\nself.${id}.set_gain(${gain27}, 27)\nself.${id}.set_if_gain(${if_gain27}, 27)\nself.${id}.set_bb_gain(${bb_gain27}, 27)\nself.${id}.set_antenna(${ant27}, 27)\nself.${id}.set_bandwidth(${bw27}, 27)\n% endif\n% if context.get('nchan')() > 28:\nself.${id}.set_center_freq(${freq28}, 28)\nself.${id}.set_freq_corr(${corr28}, 28)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode28}, 28)\nself.${id}.set_iq_balance_mode(${iq_balance_mode28}, 28)\nself.${id}.set_gain_mode(${gain_mode28}, 28)\n% endif\nself.${id}.set_gain(${gain28}, 28)\nself.${id}.set_if_gain(${if_gain28}, 28)\nself.${id}.set_bb_gain(${bb_gain28}, 28)\nself.${id}.set_antenna(${ant28}, 28)\nself.${id}.set_bandwidth(${bw28}, 28)\n% endif\n% if context.get('nchan')() > 29:\nself.${id}.set_center_freq(${freq29}, 29)\nself.${id}.set_freq_corr(${corr29}, 29)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode29}, 29)\nself.${id}.set_iq_balance_mode(${iq_balance_mode29}, 29)\nself.${id}.set_gain_mode(${gain_mode29}, 29)\n% endif\nself.${id}.set_gain(${gain29}, 29)\nself.${id}.set_if_gain(${if_gain29}, 29)\nself.${id}.set_bb_gain(${bb_gain29}, 29)\nself.${id}.set_antenna(${ant29}, 29)\nself.${id}.set_bandwidth(${bw29}, 29)\n% endif\n% if context.get('nchan')() > 30:\nself.${id}.set_center_freq(${freq30}, 30)\nself.${id}.set_freq_corr(${corr30}, 30)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode30}, 30)\nself.${id}.set_iq_balance_mode(${iq_balance_mode30}, 30)\nself.${id}.set_gain_mode(${gain_mode30}, 30)\n% endif\nself.${id}.set_gain(${gain30}, 30)\nself.${id}.set_if_gain(${if_gain30}, 30)\nself.${id}.set_bb_gain(${bb_gain30}, 30)\nself.${id}.set_antenna(${ant30}, 30)\nself.${id}.set_bandwidth(${bw30}, 30)\n% endif\n% if context.get('nchan')() > 31:\nself.${id}.set_center_freq(${freq31}, 31)\nself.${id}.set_freq_corr(${corr31}, 31)\n% if context.get('sourk') == 'source':\nself.${id}.set_dc_offset_mode(${dc_offset_mode31}, 31)\nself.${id}.set_iq_balance_mode(${iq_balance_mode31}, 31)\nself.${id}.set_gain_mode(${gain_mode31}, 31)\n% endif\nself.${id}.set_gain(${gain31}, 31)\nself.${id}.set_if_gain(${if_gain31}, 31)\nself.${id}.set_bb_gain(${bb_gain31}, 31)\nself.${id}.set_antenna(${ant31}, 31)\nself.${id}.set_bandwidth(${bw31}, 31)\n% endif\n')

Failure

I realized that this comes from the .yml file of osmocom_sink block, but I don't know how to solve it since the osmocom_source block works fine, and it doesn't even generate the .py file.

@Gm618
Copy link

Gm618 commented May 11, 2020

The block started to sink when I removed from .block.yml file the channels, now it only works for 1 channel.
Is there any available solution without this procedure?

@glyphx
Copy link

glyphx commented Jun 28, 2020

This worked excellently for me, thank you!

@nicklansley
Copy link

The block started to sink when I removed from .block.yml file the channels, now it only works for 1 channel.
Is there any available solution without this procedure?

Yes, there was a bug in the python source code that generators this block's YML which has now been fixed.
The bug partially generated the source YML within the SINK YML, causing the error.

Fix:

  1. Download the block generator python script for Osmocom from:

  2. Execute the python file with the full block name after it:
    python gen_osmosdr_blocks.py osmosdr_sink.block.yml

  3. Copy the resulting osmosdr_sink.block.yml file to (the default installation on Ubuntu 20.04):
    /usr/share/gnuradio/grc/blocks
    ...overwriting the original file.

I get a another bug with 'no destructor found' when running the flowgraph script, but at least GRC generates the flowgraph script now!

@RASM17
Copy link

RASM17 commented Mar 29, 2021

Hello,
So I started with:

Generate Error: (NameError("'gain_mode31' is not defined",)

Did what nick said:

Fix:

  1. Download the block generator python script for Osmocom from:
  2. Execute the python file with the full block name after it:
    python gen_osmosdr_blocks.py osmosdr_sink.block.yml
  3. Copy the resulting osmosdr_sink.block.yml file to (the default installation on Ubuntu 20.04):
    /usr/share/gnuradio/grc/blocks
    ...overwriting the original file.

but now I have the following:

Generate Error: (NameError("'iq_balance_mode26' is not defined",), 'osmosdr.sink(\n    args="numchan=" + str(${nchan}) + " " + ${args}\n)\n% if context.get(\'num_mboards\')() > 0:\n% if context.get(\'clock_source0\')():\nself.${id}.set_clock_source(${clock_source0}, 0)\n% endif\n% if context.get(\'time_source0\')():\nself.${id}.set_time_source(${time_source0}, 0)\n% endif\n% endif\n% if context.get(\'num_mboards\')() > 1:\n% if context.get(\'clock_source1\')():\nself.${id}.set_clock_source(${clock_source1}, 1)\n% endif\n% if context.get(\'time_source1\')():\nself.${id}.set_time_source(${time_source1}, 1)\n% endif\n% endif\n% if context.get(\'num_mboards\')() > 2:\n% if context.get(\'clock_source2\')():\nself.${id}.set_clock_source(${clock_source2}, 2)\n% endif\n% if context.get(\'time_source2\')():\nself.${id}.set_time_source(${time_source2}, 2)\n% endif\n% endif\n% if context.get(\'num_mboards\')() > 3:\n% if context.get(\'clock_source3\')():\nself.${id}.set_clock_source(${clock_source3}, 3)\n% endif\n% if context.get(\'time_source3\')():\nself.${id}.set_time_source(${time_source3}, 3)\n% endif\n% endif\n% if context.get(\'num_mboards\')() > 4:\n% if context.get(\'clock_source4\')():\nself.${id}.set_clock_source(${clock_source4}, 4)\n% endif\n% if context.get(\'time_source4\')():\nself.${id}.set_time_source(${time_source4}, 4)\n% endif\n% endif\n% if context.get(\'num_mboards\')() > 5:\n% if context.get(\'clock_source5\')():\nself.${id}.set_clock_source(${clock_source5}, 5)\n% endif\n% if context.get(\'time_source5\')():\nself.${id}.set_time_source(${time_source5}, 5)\n% endif\n% endif\n% if context.get(\'num_mboards\')() > 6:\n% if context.get(\'clock_source6\')():\nself.${id}.set_clock_source(${clock_source6}, 6)\n% endif\n% if context.get(\'time_source6\')():\nself.${id}.set_time_source(${time_source6}, 6)\n% endif\n% endif\n% if context.get(\'num_mboards\')() > 7:\n% if context.get(\'clock_source7\')():\nself.${id}.set_clock_source(${clock_source7}, 7)\n% endif\n% if context.get(\'time_source7\')():\nself.${id}.set_time_source(${time_source7}, 7)\n% endif\n% endif\n% if sync == \'sync\':\nself.${id}.set_time_unknown_pps(osmosdr.time_spec_t())\n% elif sync == \'pc_clock\':\nself.${id}.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS)\n% endif\nself.${id}.set_sample_rate(${sample_rate})\n% if context.get(\'nchan\')() > 0:\nself.${id}.set_center_freq(${freq0}, 0)\nself.${id}.set_freq_corr(${corr0}, 0)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode0}, 0)\nself.${id}.set_iq_balance_mode(${iq_balance_mode0}, 0)\nself.${id}.set_gain_mode(${gain_mode0}, 0)\n% endif\nself.${id}.set_gain(${gain0}, 0)\nself.${id}.set_if_gain(${if_gain0}, 0)\nself.${id}.set_bb_gain(${bb_gain0}, 0)\nself.${id}.set_antenna(${ant0}, 0)\nself.${id}.set_bandwidth(${bw0}, 0)\n% endif\n% if context.get(\'nchan\')() > 1:\nself.${id}.set_center_freq(${freq1}, 1)\nself.${id}.set_freq_corr(${corr1}, 1)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode1}, 1)\nself.${id}.set_iq_balance_mode(${iq_balance_mode1}, 1)\nself.${id}.set_gain_mode(${gain_mode1}, 1)\n% endif\nself.${id}.set_gain(${gain1}, 1)\nself.${id}.set_if_gain(${if_gain1}, 1)\nself.${id}.set_bb_gain(${bb_gain1}, 1)\nself.${id}.set_antenna(${ant1}, 1)\nself.${id}.set_bandwidth(${bw1}, 1)\n% endif\n% if context.get(\'nchan\')() > 2:\nself.${id}.set_center_freq(${freq2}, 2)\nself.${id}.set_freq_corr(${corr2}, 2)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode2}, 2)\nself.${id}.set_iq_balance_mode(${iq_balance_mode2}, 2)\nself.${id}.set_gain_mode(${gain_mode2}, 2)\n% endif\nself.${id}.set_gain(${gain2}, 2)\nself.${id}.set_if_gain(${if_gain2}, 2)\nself.${id}.set_bb_gain(${bb_gain2}, 2)\nself.${id}.set_antenna(${ant2}, 2)\nself.${id}.set_bandwidth(${bw2}, 2)\n% endif\n% if context.get(\'nchan\')() > 3:\nself.${id}.set_center_freq(${freq3}, 3)\nself.${id}.set_freq_corr(${corr3}, 3)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode3}, 3)\nself.${id}.set_iq_balance_mode(${iq_balance_mode3}, 3)\nself.${id}.set_gain_mode(${gain_mode3}, 3)\n% endif\nself.${id}.set_gain(${gain3}, 3)\nself.${id}.set_if_gain(${if_gain3}, 3)\nself.${id}.set_bb_gain(${bb_gain3}, 3)\nself.${id}.set_antenna(${ant3}, 3)\nself.${id}.set_bandwidth(${bw3}, 3)\n% endif\n% if context.get(\'nchan\')() > 4:\nself.${id}.set_center_freq(${freq4}, 4)\nself.${id}.set_freq_corr(${corr4}, 4)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode4}, 4)\nself.${id}.set_iq_balance_mode(${iq_balance_mode4}, 4)\nself.${id}.set_gain_mode(${gain_mode4}, 4)\n% endif\nself.${id}.set_gain(${gain4}, 4)\nself.${id}.set_if_gain(${if_gain4}, 4)\nself.${id}.set_bb_gain(${bb_gain4}, 4)\nself.${id}.set_antenna(${ant4}, 4)\nself.${id}.set_bandwidth(${bw4}, 4)\n% endif\n% if context.get(\'nchan\')() > 5:\nself.${id}.set_center_freq(${freq5}, 5)\nself.${id}.set_freq_corr(${corr5}, 5)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode5}, 5)\nself.${id}.set_iq_balance_mode(${iq_balance_mode5}, 5)\nself.${id}.set_gain_mode(${gain_mode5}, 5)\n% endif\nself.${id}.set_gain(${gain5}, 5)\nself.${id}.set_if_gain(${if_gain5}, 5)\nself.${id}.set_bb_gain(${bb_gain5}, 5)\nself.${id}.set_antenna(${ant5}, 5)\nself.${id}.set_bandwidth(${bw5}, 5)\n% endif\n% if context.get(\'nchan\')() > 6:\nself.${id}.set_center_freq(${freq6}, 6)\nself.${id}.set_freq_corr(${corr6}, 6)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode6}, 6)\nself.${id}.set_iq_balance_mode(${iq_balance_mode6}, 6)\nself.${id}.set_gain_mode(${gain_mode6}, 6)\n% endif\nself.${id}.set_gain(${gain6}, 6)\nself.${id}.set_if_gain(${if_gain6}, 6)\nself.${id}.set_bb_gain(${bb_gain6}, 6)\nself.${id}.set_antenna(${ant6}, 6)\nself.${id}.set_bandwidth(${bw6}, 6)\n% endif\n% if context.get(\'nchan\')() > 7:\nself.${id}.set_center_freq(${freq7}, 7)\nself.${id}.set_freq_corr(${corr7}, 7)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode7}, 7)\nself.${id}.set_iq_balance_mode(${iq_balance_mode7}, 7)\nself.${id}.set_gain_mode(${gain_mode7}, 7)\n% endif\nself.${id}.set_gain(${gain7}, 7)\nself.${id}.set_if_gain(${if_gain7}, 7)\nself.${id}.set_bb_gain(${bb_gain7}, 7)\nself.${id}.set_antenna(${ant7}, 7)\nself.${id}.set_bandwidth(${bw7}, 7)\n% endif\n% if context.get(\'nchan\')() > 8:\nself.${id}.set_center_freq(${freq8}, 8)\nself.${id}.set_freq_corr(${corr8}, 8)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode8}, 8)\nself.${id}.set_iq_balance_mode(${iq_balance_mode8}, 8)\nself.${id}.set_gain_mode(${gain_mode8}, 8)\n% endif\nself.${id}.set_gain(${gain8}, 8)\nself.${id}.set_if_gain(${if_gain8}, 8)\nself.${id}.set_bb_gain(${bb_gain8}, 8)\nself.${id}.set_antenna(${ant8}, 8)\nself.${id}.set_bandwidth(${bw8}, 8)\n% endif\n% if context.get(\'nchan\')() > 9:\nself.${id}.set_center_freq(${freq9}, 9)\nself.${id}.set_freq_corr(${corr9}, 9)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode9}, 9)\nself.${id}.set_iq_balance_mode(${iq_balance_mode9}, 9)\nself.${id}.set_gain_mode(${gain_mode9}, 9)\n% endif\nself.${id}.set_gain(${gain9}, 9)\nself.${id}.set_if_gain(${if_gain9}, 9)\nself.${id}.set_bb_gain(${bb_gain9}, 9)\nself.${id}.set_antenna(${ant9}, 9)\nself.${id}.set_bandwidth(${bw9}, 9)\n% endif\n% if context.get(\'nchan\')() > 10:\nself.${id}.set_center_freq(${freq10}, 10)\nself.${id}.set_freq_corr(${corr10}, 10)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode10}, 10)\nself.${id}.set_iq_balance_mode(${iq_balance_mode10}, 10)\nself.${id}.set_gain_mode(${gain_mode10}, 10)\n% endif\nself.${id}.set_gain(${gain10}, 10)\nself.${id}.set_if_gain(${if_gain10}, 10)\nself.${id}.set_bb_gain(${bb_gain10}, 10)\nself.${id}.set_antenna(${ant10}, 10)\nself.${id}.set_bandwidth(${bw10}, 10)\n% endif\n% if context.get(\'nchan\')() > 11:\nself.${id}.set_center_freq(${freq11}, 11)\nself.${id}.set_freq_corr(${corr11}, 11)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode11}, 11)\nself.${id}.set_iq_balance_mode(${iq_balance_mode11}, 11)\nself.${id}.set_gain_mode(${gain_mode11}, 11)\n% endif\nself.${id}.set_gain(${gain11}, 11)\nself.${id}.set_if_gain(${if_gain11}, 11)\nself.${id}.set_bb_gain(${bb_gain11}, 11)\nself.${id}.set_antenna(${ant11}, 11)\nself.${id}.set_bandwidth(${bw11}, 11)\n% endif\n% if context.get(\'nchan\')() > 12:\nself.${id}.set_center_freq(${freq12}, 12)\nself.${id}.set_freq_corr(${corr12}, 12)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode12}, 12)\nself.${id}.set_iq_balance_mode(${iq_balance_mode12}, 12)\nself.${id}.set_gain_mode(${gain_mode12}, 12)\n% endif\nself.${id}.set_gain(${gain12}, 12)\nself.${id}.set_if_gain(${if_gain12}, 12)\nself.${id}.set_bb_gain(${bb_gain12}, 12)\nself.${id}.set_antenna(${ant12}, 12)\nself.${id}.set_bandwidth(${bw12}, 12)\n% endif\n% if context.get(\'nchan\')() > 13:\nself.${id}.set_center_freq(${freq13}, 13)\nself.${id}.set_freq_corr(${corr13}, 13)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode13}, 13)\nself.${id}.set_iq_balance_mode(${iq_balance_mode13}, 13)\nself.${id}.set_gain_mode(${gain_mode13}, 13)\n% endif\nself.${id}.set_gain(${gain13}, 13)\nself.${id}.set_if_gain(${if_gain13}, 13)\nself.${id}.set_bb_gain(${bb_gain13}, 13)\nself.${id}.set_antenna(${ant13}, 13)\nself.${id}.set_bandwidth(${bw13}, 13)\n% endif\n% if context.get(\'nchan\')() > 14:\nself.${id}.set_center_freq(${freq14}, 14)\nself.${id}.set_freq_corr(${corr14}, 14)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode14}, 14)\nself.${id}.set_iq_balance_mode(${iq_balance_mode14}, 14)\nself.${id}.set_gain_mode(${gain_mode14}, 14)\n% endif\nself.${id}.set_gain(${gain14}, 14)\nself.${id}.set_if_gain(${if_gain14}, 14)\nself.${id}.set_bb_gain(${bb_gain14}, 14)\nself.${id}.set_antenna(${ant14}, 14)\nself.${id}.set_bandwidth(${bw14}, 14)\n% endif\n% if context.get(\'nchan\')() > 15:\nself.${id}.set_center_freq(${freq15}, 15)\nself.${id}.set_freq_corr(${corr15}, 15)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode15}, 15)\nself.${id}.set_iq_balance_mode(${iq_balance_mode15}, 15)\nself.${id}.set_gain_mode(${gain_mode15}, 15)\n% endif\nself.${id}.set_gain(${gain15}, 15)\nself.${id}.set_if_gain(${if_gain15}, 15)\nself.${id}.set_bb_gain(${bb_gain15}, 15)\nself.${id}.set_antenna(${ant15}, 15)\nself.${id}.set_bandwidth(${bw15}, 15)\n% endif\n% if context.get(\'nchan\')() > 16:\nself.${id}.set_center_freq(${freq16}, 16)\nself.${id}.set_freq_corr(${corr16}, 16)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode16}, 16)\nself.${id}.set_iq_balance_mode(${iq_balance_mode16}, 16)\nself.${id}.set_gain_mode(${gain_mode16}, 16)\n% endif\nself.${id}.set_gain(${gain16}, 16)\nself.${id}.set_if_gain(${if_gain16}, 16)\nself.${id}.set_bb_gain(${bb_gain16}, 16)\nself.${id}.set_antenna(${ant16}, 16)\nself.${id}.set_bandwidth(${bw16}, 16)\n% endif\n% if context.get(\'nchan\')() > 17:\nself.${id}.set_center_freq(${freq17}, 17)\nself.${id}.set_freq_corr(${corr17}, 17)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode17}, 17)\nself.${id}.set_iq_balance_mode(${iq_balance_mode17}, 17)\nself.${id}.set_gain_mode(${gain_mode17}, 17)\n% endif\nself.${id}.set_gain(${gain17}, 17)\nself.${id}.set_if_gain(${if_gain17}, 17)\nself.${id}.set_bb_gain(${bb_gain17}, 17)\nself.${id}.set_antenna(${ant17}, 17)\nself.${id}.set_bandwidth(${bw17}, 17)\n% endif\n% if context.get(\'nchan\')() > 18:\nself.${id}.set_center_freq(${freq18}, 18)\nself.${id}.set_freq_corr(${corr18}, 18)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode18}, 18)\nself.${id}.set_iq_balance_mode(${iq_balance_mode18}, 18)\nself.${id}.set_gain_mode(${gain_mode18}, 18)\n% endif\nself.${id}.set_gain(${gain18}, 18)\nself.${id}.set_if_gain(${if_gain18}, 18)\nself.${id}.set_bb_gain(${bb_gain18}, 18)\nself.${id}.set_antenna(${ant18}, 18)\nself.${id}.set_bandwidth(${bw18}, 18)\n% endif\n% if context.get(\'nchan\')() > 19:\nself.${id}.set_center_freq(${freq19}, 19)\nself.${id}.set_freq_corr(${corr19}, 19)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode19}, 19)\nself.${id}.set_iq_balance_mode(${iq_balance_mode19}, 19)\nself.${id}.set_gain_mode(${gain_mode19}, 19)\n% endif\nself.${id}.set_gain(${gain19}, 19)\nself.${id}.set_if_gain(${if_gain19}, 19)\nself.${id}.set_bb_gain(${bb_gain19}, 19)\nself.${id}.set_antenna(${ant19}, 19)\nself.${id}.set_bandwidth(${bw19}, 19)\n% endif\n% if context.get(\'nchan\')() > 20:\nself.${id}.set_center_freq(${freq20}, 20)\nself.${id}.set_freq_corr(${corr20}, 20)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode20}, 20)\nself.${id}.set_iq_balance_mode(${iq_balance_mode20}, 20)\nself.${id}.set_gain_mode(${gain_mode20}, 20)\n% endif\nself.${id}.set_gain(${gain20}, 20)\nself.${id}.set_if_gain(${if_gain20}, 20)\nself.${id}.set_bb_gain(${bb_gain20}, 20)\nself.${id}.set_antenna(${ant20}, 20)\nself.${id}.set_bandwidth(${bw20}, 20)\n% endif\n% if context.get(\'nchan\')() > 21:\nself.${id}.set_center_freq(${freq21}, 21)\nself.${id}.set_freq_corr(${corr21}, 21)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode21}, 21)\nself.${id}.set_iq_balance_mode(${iq_balance_mode21}, 21)\nself.${id}.set_gain_mode(${gain_mode21}, 21)\n% endif\nself.${id}.set_gain(${gain21}, 21)\nself.${id}.set_if_gain(${if_gain21}, 21)\nself.${id}.set_bb_gain(${bb_gain21}, 21)\nself.${id}.set_antenna(${ant21}, 21)\nself.${id}.set_bandwidth(${bw21}, 21)\n% endif\n% if context.get(\'nchan\')() > 22:\nself.${id}.set_center_freq(${freq22}, 22)\nself.${id}.set_freq_corr(${corr22}, 22)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode22}, 22)\nself.${id}.set_iq_balance_mode(${iq_balance_mode22}, 22)\nself.${id}.set_gain_mode(${gain_mode22}, 22)\n% endif\nself.${id}.set_gain(${gain22}, 22)\nself.${id}.set_if_gain(${if_gain22}, 22)\nself.${id}.set_bb_gain(${bb_gain22}, 22)\nself.${id}.set_antenna(${ant22}, 22)\nself.${id}.set_bandwidth(${bw22}, 22)\n% endif\n% if context.get(\'nchan\')() > 23:\nself.${id}.set_center_freq(${freq23}, 23)\nself.${id}.set_freq_corr(${corr23}, 23)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode23}, 23)\nself.${id}.set_iq_balance_mode(${iq_balance_mode23}, 23)\nself.${id}.set_gain_mode(${gain_mode23}, 23)\n% endif\nself.${id}.set_gain(${gain23}, 23)\nself.${id}.set_if_gain(${if_gain23}, 23)\nself.${id}.set_bb_gain(${bb_gain23}, 23)\nself.${id}.set_antenna(${ant23}, 23)\nself.${id}.set_bandwidth(${bw23}, 23)\n% endif\n% if context.get(\'nchan\')() > 24:\nself.${id}.set_center_freq(${freq24}, 24)\nself.${id}.set_freq_corr(${corr24}, 24)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode24}, 24)\nself.${id}.set_iq_balance_mode(${iq_balance_mode24}, 24)\nself.${id}.set_gain_mode(${gain_mode24}, 24)\n% endif\nself.${id}.set_gain(${gain24}, 24)\nself.${id}.set_if_gain(${if_gain24}, 24)\nself.${id}.set_bb_gain(${bb_gain24}, 24)\nself.${id}.set_antenna(${ant24}, 24)\nself.${id}.set_bandwidth(${bw24}, 24)\n% endif\n% if context.get(\'nchan\')() > 25:\nself.${id}.set_center_freq(${freq25}, 25)\nself.${id}.set_freq_corr(${corr25}, 25)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode25}, 25)\nself.${id}.set_iq_balance_mode(${iq_balance_mode25}, 25)\nself.${id}.set_gain_mode(${gain_mode25}, 25)\n% endif\nself.${id}.set_gain(${gain25}, 25)\nself.${id}.set_if_gain(${if_gain25}, 25)\nself.${id}.set_bb_gain(${bb_gain25}, 25)\nself.${id}.set_antenna(${ant25}, 25)\nself.${id}.set_bandwidth(${bw25}, 25)\n% endif\n% if context.get(\'nchan\')() > 26:\nself.${id}.set_center_freq(${freq26}, 26)\nself.${id}.set_freq_corr(${corr26}, 26)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode26}, 26)\nself.${id}.set_iq_balance_mode(${iq_balance_mode26}, 26)\nself.${id}.set_gain_mode(${gain_mode26}, 26)\n% endif\nself.${id}.set_gain(${gain26}, 26)\nself.${id}.set_if_gain(${if_gain26}, 26)\nself.${id}.set_bb_gain(${bb_gain26}, 26)\nself.${id}.set_antenna(${ant26}, 26)\nself.${id}.set_bandwidth(${bw26}, 26)\n% endif\n% if context.get(\'nchan\')() > 27:\nself.${id}.set_center_freq(${freq27}, 27)\nself.${id}.set_freq_corr(${corr27}, 27)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode27}, 27)\nself.${id}.set_iq_balance_mode(${iq_balance_mode27}, 27)\nself.${id}.set_gain_mode(${gain_mode27}, 27)\n% endif\nself.${id}.set_gain(${gain27}, 27)\nself.${id}.set_if_gain(${if_gain27}, 27)\nself.${id}.set_bb_gain(${bb_gain27}, 27)\nself.${id}.set_antenna(${ant27}, 27)\nself.${id}.set_bandwidth(${bw27}, 27)\n% endif\n% if context.get(\'nchan\')() > 28:\nself.${id}.set_center_freq(${freq28}, 28)\nself.${id}.set_freq_corr(${corr28}, 28)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode28}, 28)\nself.${id}.set_iq_balance_mode(${iq_balance_mode28}, 28)\nself.${id}.set_gain_mode(${gain_mode28}, 28)\n% endif\nself.${id}.set_gain(${gain28}, 28)\nself.${id}.set_if_gain(${if_gain28}, 28)\nself.${id}.set_bb_gain(${bb_gain28}, 28)\nself.${id}.set_antenna(${ant28}, 28)\nself.${id}.set_bandwidth(${bw28}, 28)\n% endif\n% if context.get(\'nchan\')() > 29:\nself.${id}.set_center_freq(${freq29}, 29)\nself.${id}.set_freq_corr(${corr29}, 29)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode29}, 29)\nself.${id}.set_iq_balance_mode(${iq_balance_mode29}, 29)\nself.${id}.set_gain_mode(${gain_mode29}, 29)\n% endif\nself.${id}.set_gain(${gain29}, 29)\nself.${id}.set_if_gain(${if_gain29}, 29)\nself.${id}.set_bb_gain(${bb_gain29}, 29)\nself.${id}.set_antenna(${ant29}, 29)\nself.${id}.set_bandwidth(${bw29}, 29)\n% endif\n% if context.get(\'nchan\')() > 30:\nself.${id}.set_center_freq(${freq30}, 30)\nself.${id}.set_freq_corr(${corr30}, 30)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode30}, 30)\nself.${id}.set_iq_balance_mode(${iq_balance_mode30}, 30)\nself.${id}.set_gain_mode(${gain_mode30}, 30)\n% endif\nself.${id}.set_gain(${gain30}, 30)\nself.${id}.set_if_gain(${if_gain30}, 30)\nself.${id}.set_bb_gain(${bb_gain30}, 30)\nself.${id}.set_antenna(${ant30}, 30)\nself.${id}.set_bandwidth(${bw30}, 30)\n% endif\n% if context.get(\'nchan\')() > 31:\nself.${id}.set_center_freq(${freq31}, 31)\nself.${id}.set_freq_corr(${corr31}, 31)\n% if context.get(\'sourk\') == \'source\':\nself.${id}.set_dc_offset_mode(${dc_offset_mode31}, 31)\nself.${id}.set_iq_balance_mode(${iq_balance_mode31}, 31)\nself.${id}.set_gain_mode(${gain_mode31}, 31)\n% endif\nself.${id}.set_gain(${gain31}, 31)\nself.${id}.set_if_gain(${if_gain31}, 31)\nself.${id}.set_bb_gain(${bb_gain31}, 31)\nself.${id}.set_antenna(${ant31}, 31)\nself.${id}.set_bandwidth(${bw31}, 31)\n% endif\n')
>>> Failure
Traceback (most recent call last):
  File "memory:0x7ffa4b7c82e8", line 24, in render_body
  File "/usr/lib/python3/dist-packages/mako/runtime.py", line 101, in __getitem__
    return compat_builtins.__dict__[key]
KeyError: 'iq_balance_mode26'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/sdr/lib/python3/dist-packages/gnuradio/grc/core/blocks/_templates.py", line 75, in render
    return template.render(**namespace)
  File "/usr/lib/python3/dist-packages/mako/template.py", line 462, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/python3/dist-packages/mako/runtime.py", line 838, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/python3/dist-packages/mako/runtime.py", line 873, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/python3/dist-packages/mako/runtime.py", line 899, in _exec_template
    callable_(context, *args, **kwargs)
  File "memory:0x7ffa4b7c82e8", line 26, in render_body
NameError: 'iq_balance_mode26' is not defined

@gorgiaxx
Copy link

gorgiaxx commented Apr 7, 2021

The block started to sink when I removed from .block.yml file the channels, now it only works for 1 channel.
Is there any available solution without this procedure?

Yes, there was a bug in the python source code that generators this block's YML which has now been fixed.
The bug partially generated the source YML within the SINK YML, causing the error.

Fix:

  1. Download the block generator python script for Osmocom from:
  2. Execute the python file with the full block name after it:
    python gen_osmosdr_blocks.py osmosdr_sink.block.yml
  3. Copy the resulting osmosdr_sink.block.yml file to (the default installation on Ubuntu 20.04):
    /usr/share/gnuradio/grc/blocks
    ...overwriting the original file.

I get a another bug with 'no destructor found' when running the flowgraph script, but at least GRC generates the flowgraph script now!

This worked excellently for me, thanks!

@tonytd48
Copy link

Also having problems using gr-osmosdr sink

I Tried what Nick suggested and when I ran;

python gen_osmosdr_blocks.py osmosdr_sink.block.yml

the following error appears
Traceback (most recent call last):
File "gen_osmosdr_blocks.py", line 388, in
params = ''.join([
File "gen_osmosdr_blocks.py", line 389, in
parse_tmpl(PARAMS_TMPL, n=n, sourk=sourk)
File "gen_osmosdr_blocks.py", line 350, in parse_tmpl
from mako.template import Template
ModuleNotFoundError: No module named 'mako'

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment