diff --git a/apps/fm_receiver.grc b/apps/fm_receiver.grc index c17180fa14b892b9b725c57d19998d4b8a8ad981..9c6ed09ec99e857c7cdda35200fc6eb683d5f640 100644 --- a/apps/fm_receiver.grc +++ b/apps/fm_receiver.grc @@ -45,15 +45,24 @@ blocks: rotation: 0 state: true - name: freq - id: variable + id: variable_qtgui_range parameters: comment: '' + gui_hint: '' + label: '' + min_len: '200' + orient: QtCore.Qt.Horizontal + rangeType: float + start: 100e6 + step: 100e3 + stop: 110e6 value: 102.9e6 + widget: counter_slider states: bus_sink: false bus_source: false bus_structure: null - coordinate: [592, 12.0] + coordinate: [512, 12.0] rotation: 0 state: true - name: samp_rate @@ -77,7 +86,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [464, 12.0] + coordinate: [416, 4.0] rotation: 0 state: true - name: volume @@ -98,7 +107,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [792, 68.0] + coordinate: [712, 4.0] rotation: 0 state: true - name: analog_fm_demod_cf_0 @@ -120,7 +129,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [576, 140.0] + coordinate: [608, 204.0] rotation: 0 state: true - name: audio_sink_0 @@ -158,7 +167,8 @@ blocks: dc_offset_mode0: '0' dc_offset_mode1: '0' device_id: '0' - fpga_image: test + fpga_image: test123 + fpga_reload: 'True' freq0: freq freq1: 1e8 gain0: '10' @@ -167,24 +177,55 @@ blocks: gain_mode1: 'False' if_gain0: '20' if_gain1: '20' - in_clk: EXTERNAL + in_clk: ONBOARD iq_balance_mode0: '0' iq_balance_mode1: '0' maxoutbuf: '0' minoutbuf: '0' nchan: '1' out_clk: 'False' - power_monitoring: 'False' + power_monitoring: Enable ref_clk: '1000000' sample_rate: samp_rate type: fc32 - verbosity: silent + verbosity: warning xb200: auto3db states: bus_sink: false bus_source: false bus_structure: null - coordinate: [48, 92.0] + coordinate: [88, 100.0] + rotation: 0 + state: true +- name: blocks_message_debug_0 + id: blocks_message_debug + parameters: + affinity: '' + alias: '' + comment: '' + en_uvec: 'True' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [576, 440.0] + rotation: 0 + state: true +- name: blocks_message_strobe_0 + id: blocks_message_strobe + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + msg: pmt.intern("TEST") + period: '1000' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [64, 532.0] rotation: 0 state: true - name: blocks_multiply_const_vxx_0 @@ -222,13 +263,15 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [368, 124.0] + coordinate: [384, 188.0] rotation: 0 state: true connections: - [analog_fm_demod_cf_0, '0', blocks_multiply_const_vxx_0, '0'] - [bladeRF_source_0, '0', rational_resampler_xxx_0, '0'] +- [bladeRF_source_0, pmic_out, blocks_message_debug_0, print] +- [blocks_message_strobe_0, strobe, bladeRF_source_0, pmic_in] - [blocks_multiply_const_vxx_0, '0', audio_sink_0, '0'] - [rational_resampler_xxx_0, '0', analog_fm_demod_cf_0, '0'] diff --git a/grc/gen_bladerf_blocks.py b/grc/gen_bladerf_blocks.py index d4c38c91db51f10e461ecd2fbbc90013201dbca4..746ffc02682857bfb1af48d9194ccd0cb99102f1 100644 --- a/grc/gen_bladerf_blocks.py +++ b/grc/gen_bladerf_blocks.py @@ -76,9 +76,8 @@ parameters: category: Advanced label: 'Power monitoring' dtype: enum - default: False - options: [False, True] - option_labels: ['Disable', 'Enable'] + default: auto + options: ['Disable', 'Enable'] - id: ref_clk category: Advanced @@ -123,8 +122,14 @@ inputs: id: command optional: true % if sourk == 'source': +- domain: message + id: pmic_in + optional: true outputs: +- domain: message + id: pmic_out + optional: true % endif - domain: stream dtype: ${'$'}{type.type} @@ -137,6 +142,8 @@ outputs: optional: true % endif + + templates: imports: |- import bladeRF @@ -149,7 +156,7 @@ templates: + ",verbosity=" + '${'$'}{verbosity}' + ",fpga=" + str(${'$'}{fpga_image}) + ",fpga-reload=" + '${'$'}{fpga_reload}' - + ",power_monitoring=" + str(${'$'}{power_monitoring}) + + ",power_monitoring=" + '${'$'}{power_monitoring}' + ",ref_clk=" + str(${'$'}{ref_clk}) + ",in_clk=" + '${'$'}{in_clk}' + ",out_clk=" + str(${'$'}{out_clk}) diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc index 393522f6a9340350eeb19e2f861abcb8c628e5bd..8615d344d2e9fc088ce26a3a7294c593a7439e93 100644 --- a/lib/bladerf/bladerf_common.cc +++ b/lib/bladerf/bladerf_common.cc @@ -242,6 +242,8 @@ void bladerf_common::init(dict_t const &dict, bladerf_direction direction) } } + + if (bladerf_is_fpga_configured(_dev.get()) != 1) { BLADERF_THROW("The FPGA is not configured! Provide device argument " "fpga=/path/to/the/bitstream.rbf to load it."); diff --git a/lib/bladerf/bladerf_common.h b/lib/bladerf/bladerf_common.h index f2c1b8c980e3201a3011203f926b7ca672639959..86aef27c0d7c7010d3964da30f71c870a7320a55 100644 --- a/lib/bladerf/bladerf_common.h +++ b/lib/bladerf/bladerf_common.h @@ -162,6 +162,18 @@ protected: void set_channel_enable(bladerf_channel ch, bool enable); bool get_channel_enable(bladerf_channel ch); + + template<typename T> + T get_pmic(bladerf_pmic_register reg) + { + T value; + auto status = bladerf_get_pmic_register(_dev.get(),reg,&value); + if (status != 0) { + BLADERF_THROW_STATUS(status, "bladerf_get_pmic_register failed"); + } + return value; + } + /* Set libbladeRF verbosity */ void set_verbosity(std::string const &verbosity); diff --git a/lib/bladerf/bladerf_source_c.cc b/lib/bladerf/bladerf_source_c.cc index 486a00adec69843589a9f7a910911c7450661e99..0481628407ea0f8d5a6c4a1c7cfab2881821c7e0 100644 --- a/lib/bladerf/bladerf_source_c.cc +++ b/lib/bladerf/bladerf_source_c.cc @@ -79,6 +79,14 @@ bladerf_source_c::bladerf_source_c(const std::string &args) : /* Perform src/sink agnostic initializations */ init(dict, BLADERF_RX); + message_port_register_in(pmt::mp("pmic_in")); + message_port_register_out(pmt::mp("pmic_out")); + + set_msg_handler(pmt::mp("pmic_in"),[=](const pmt::pmt_t & msg) + { + message_port_pub(pmt::mp("pmic_out"), msg); + }); + /* Handle setting of sampling mode */ if (dict.count("sampling")) { bladerf_sampling sampling = BLADERF_SAMPLING_UNKNOWN; diff --git a/lib/source_impl.cc b/lib/source_impl.cc index 60d5716697cece56bd95d58e5a121e3906eebd71..8fdc13a3f64b6dfc8b64728ba39f8a75c3b84b93 100644 --- a/lib/source_impl.cc +++ b/lib/source_impl.cc @@ -25,9 +25,8 @@ namespace gr { gr::io_signature::make(0,0,0), args_to_io_signature(args)) { - //in osmocom args for make source is strings, - //therefore all params is strings - //todo: change to vector<bladerf_devinfo> + message_port_register_hier_in(pmt::mp("pmic_in")); + message_port_register_hier_out(pmt::mp("pmic_out")); auto dev_list = bladerf_source_c::get_devices(); if(dev_list.size() == 0) @@ -49,9 +48,14 @@ namespace gr { _iq_opt.push_back( iq_opt.get() ); _iq_fix.push_back( iq_fix.get() ); #else - connect(device_, i, self(), i); + connect(device_, i, self(), i); #endif + msg_connect(self(), pmt::mp("pmic_in"), device_, pmt::mp("pmic_in")); + msg_connect(device_,pmt::mp("pmic_out"), self(), pmt::mp("pmic_out")); } + + + } source_impl::~source_impl()