diff options
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/examples/grc/uhd_fft.grc | 707 | ||||
-rw-r--r-- | gr-uhd/include/gr_uhd_usrp_source.h | 13 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_source.cc | 14 | ||||
-rw-r--r-- | gr-uhd/swig/uhd_swig.i | 2 |
4 files changed, 629 insertions, 107 deletions
diff --git a/gr-uhd/examples/grc/uhd_fft.grc b/gr-uhd/examples/grc/uhd_fft.grc index 29c375065..2582b5e3b 100644 --- a/gr-uhd/examples/grc/uhd_fft.grc +++ b/gr-uhd/examples/grc/uhd_fft.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sat Oct 8 10:26:30 2011</timestamp> + <timestamp>Mon Jun 18 14:20:11 2012</timestamp> <block> <key>options</key> <param> @@ -13,7 +13,7 @@ </param> <param> <key>title</key> - <value>UHD FFT Plotter</value> + <value>UHD FFT</value> </param> <param> <key>author</key> @@ -21,7 +21,7 @@ </param> <param> <key>description</key> - <value>FFT waveform plot</value> + <value>UHD FFT Waveform Plotter</value> </param> <param> <key>window_size</key> @@ -44,12 +44,16 @@ <value>True</value> </param> <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> <key>realtime_scheduling</key> <value></value> </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(15, 15)</value> </param> <param> <key>_rotation</key> @@ -57,34 +61,22 @@ </param> </block> <block> - <key>parameter</key> + <key>import</key> <param> <key>id</key> - <value>gain</value> + <value>import_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Default Gain</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>type</key> - <value>eng_float</value> - </param> - <param> - <key>short_id</key> - <value>g</value> + <key>import</key> + <value>import numpy</value> </param> <param> <key>_coordinate</key> - <value>(633, 17)</value> + <value>(15, 121)</value> </param> <param> <key>_rotation</key> @@ -95,7 +87,7 @@ <key>parameter</key> <param> <key>id</key> - <value>freq</value> + <value>param_samp_rate</value> </param> <param> <key>_enabled</key> @@ -103,11 +95,11 @@ </param> <param> <key>label</key> - <value>Default Frequency</value> + <value>Sample Rate</value> </param> <param> <key>value</key> - <value>2.45e9</value> + <value>1e6</value> </param> <param> <key>type</key> @@ -115,11 +107,11 @@ </param> <param> <key>short_id</key> - <value>f</value> + <value>s</value> </param> <param> <key>_coordinate</key> - <value>(485, 18)</value> + <value>(358, 14)</value> </param> <param> <key>_rotation</key> @@ -130,7 +122,7 @@ <key>parameter</key> <param> <key>id</key> - <value>address</value> + <value>param_freq</value> </param> <param> <key>_enabled</key> @@ -138,23 +130,23 @@ </param> <param> <key>label</key> - <value>IP Address</value> + <value>Default Frequency</value> </param> <param> <key>value</key> - <value>addr=192.168.11.2</value> + <value>2.45e9</value> </param> <param> <key>type</key> - <value>string</value> + <value>eng_float</value> </param> <param> <key>short_id</key> - <value>a</value> + <value>f</value> </param> <param> <key>_coordinate</key> - <value>(205, 16)</value> + <value>(508, 14)</value> </param> <param> <key>_rotation</key> @@ -165,7 +157,7 @@ <key>parameter</key> <param> <key>id</key> - <value>samp_rate</value> + <value>param_gain</value> </param> <param> <key>_enabled</key> @@ -173,11 +165,11 @@ </param> <param> <key>label</key> - <value>Sample Rate</value> + <value>Default Gain</value> </param> <param> <key>value</key> - <value>1e6</value> + <value>0</value> </param> <param> <key>type</key> @@ -185,11 +177,11 @@ </param> <param> <key>short_id</key> - <value>s</value> + <value>g</value> </param> <param> <key>_coordinate</key> - <value>(359, 18)</value> + <value>(672, 13)</value> </param> <param> <key>_rotation</key> @@ -197,10 +189,10 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>wxgui_scopesink2</key> <param> <key>id</key> - <value>wxgui_fftsink2_0</value> + <value>wxgui_scopesink2_0</value> </param> <param> <key>_enabled</key> @@ -212,55 +204,35 @@ </param> <param> <key>title</key> - <value>FFT Plot</value> + <value>Scope Plot</value> </param> <param> <key>samp_rate</key> <value>samp_rate</value> </param> <param> - <key>baseband_freq</key> - <value>tun_freq</value> - </param> - <param> - <key>y_per_div</key> - <value>10</value> - </param> - <param> - <key>y_divs</key> - <value>10</value> - </param> - <param> - <key>ref_level</key> - <value>10</value> - </param> - <param> - <key>ref_scale</key> - <value>2.0</value> + <key>v_scale</key> + <value>0</value> </param> <param> - <key>fft_size</key> - <value>1024</value> + <key>v_offset</key> + <value>0</value> </param> <param> - <key>fft_rate</key> - <value>30</value> + <key>t_scale</key> + <value>0</value> </param> <param> - <key>peak_hold</key> + <key>ac_couple</key> <value>False</value> </param> <param> - <key>average</key> + <key>xy_mode</key> <value>False</value> </param> <param> - <key>avg_alpha</key> - <value>0</value> - </param> - <param> - <key>win</key> - <value>None</value> + <key>num_inputs</key> + <value>1</value> </param> <param> <key>win_size</key> @@ -272,11 +244,19 @@ </param> <param> <key>notebook</key> - <value></value> + <value>nb0, 2</value> + </param> + <param> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> + </param> + <param> + <key>y_axis_label</key> + <value>Counts</value> </param> <param> <key>_coordinate</key> - <value>(479, 176)</value> + <value>(314, 250)</value> </param> <param> <key>_rotation</key> @@ -295,7 +275,15 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>fc32</value> + </param> + <param> + <key>otw</key> + <value></value> + </param> + <param> + <key>stream_args</key> + <value></value> </param> <param> <key>dev_addr</key> @@ -314,7 +302,11 @@ <value>1</value> </param> <param> - <key>ref_source0</key> + <key>clock_source0</key> + <value></value> + </param> + <param> + <key>time_source0</key> <value></value> </param> <param> @@ -322,7 +314,11 @@ <value></value> </param> <param> - <key>ref_source1</key> + <key>clock_source1</key> + <value></value> + </param> + <param> + <key>time_source1</key> <value></value> </param> <param> @@ -330,7 +326,11 @@ <value></value> </param> <param> - <key>ref_source2</key> + <key>clock_source2</key> + <value></value> + </param> + <param> + <key>time_source2</key> <value></value> </param> <param> @@ -338,7 +338,11 @@ <value></value> </param> <param> - <key>ref_source3</key> + <key>clock_source3</key> + <value></value> + </param> + <param> + <key>time_source3</key> <value></value> </param> <param> @@ -346,7 +350,11 @@ <value></value> </param> <param> - <key>ref_source4</key> + <key>clock_source4</key> + <value></value> + </param> + <param> + <key>time_source4</key> <value></value> </param> <param> @@ -354,7 +362,11 @@ <value></value> </param> <param> - <key>ref_source5</key> + <key>clock_source5</key> + <value></value> + </param> + <param> + <key>time_source5</key> <value></value> </param> <param> @@ -362,7 +374,11 @@ <value></value> </param> <param> - <key>ref_source6</key> + <key>clock_source6</key> + <value></value> + </param> + <param> + <key>time_source6</key> <value></value> </param> <param> @@ -370,7 +386,11 @@ <value></value> </param> <param> - <key>ref_source7</key> + <key>clock_source7</key> + <value></value> + </param> + <param> + <key>time_source7</key> <value></value> </param> <param> @@ -387,19 +407,19 @@ </param> <param> <key>center_freq0</key> - <value>tun_freq</value> + <value>freq</value> </param> <param> <key>gain0</key> - <value>tun_gain</value> + <value>gain</value> </param> <param> <key>ant0</key> - <value></value> + <value>ant</value> </param> <param> <key>bw0</key> - <value>0</value> + <value>samp_rate</value> </param> <param> <key>center_freq1</key> @@ -899,7 +919,7 @@ </param> <param> <key>_coordinate</key> - <value>(212, 216)</value> + <value>(37, 394)</value> </param> <param> <key>_rotation</key> @@ -907,34 +927,505 @@ </param> </block> <block> - <key>variable_slider</key> + <key>variable_function_probe</key> <param> <key>id</key> - <value>tun_freq</value> + <value>chan0_lo_locked</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>value</key> + <value>uhd.sensor_value("", False, "")</value> + </param> + <param> + <key>block_id</key> + <value>uhd_usrp_source_0</value> + </param> + <param> + <key>function_name</key> + <value>get_sensor</value> + </param> + <param> + <key>function_args</key> + <value>"'lo_locked'"</value> + </param> + <param> + <key>poll_rate</key> + <value>10</value> + </param> + <param> + <key>_coordinate</key> + <value>(583, 432)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>notebook</key> + <param> + <key>id</key> + <value>nb0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>style</key> + <value>wx.NB_TOP</value> + </param> + <param> + <key>labels</key> + <value>['FFT', 'Waterfall', 'Scope']</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 0, 1, 8</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(15, 172)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_chooser</key> + <param> + <key>id</key> + <value>ant_xcvr</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> <key>label</key> - <value>UHD Freq (Hz)</value> + <value>Antenna</value> </param> <param> <key>value</key> + <value>"J2"</value> + </param> + <param> + <key>choices</key> + <value>["J2","J1"]</value> + </param> + <param> + <key>labels</key> + <value>["J2","J1"]</value> + </param> + <param> + <key>type</key> + <value>radio_buttons</value> + </param> + <param> + <key>style</key> + <value>wx.RA_HORIZONTAL</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(830, 278)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_static_text</key> + <param> + <key>id</key> + <value>lo_locked_probe</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>LO Locked</value> + </param> + <param> + <key>value</key> + <value>chan0_lo_locked.to_bool()</value> + </param> + <param> + <key>converver</key> + <value>str_converter</value> + </param> + <param> + <key>formatter</key> + <value>lambda x: x and "True" or "False"</value> + </param> + <param> + <key>grid_pos</key> + <value>1, 7, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(583, 314)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_chooser</key> + <param> + <key>id</key> + <value>ant</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Antenna</value> + </param> + <param> + <key>value</key> + <value>"RX2"</value> + </param> + <param> + <key>choices</key> + <value>["RX2","TX/RX"]</value> + </param> + <param> + <key>labels</key> + <value>["RX2","TX/RX"]</value> + </param> + <param> + <key>type</key> + <value>radio_buttons</value> + </param> + <param> + <key>style</key> + <value>wx.RA_HORIZONTAL</value> + </param> + <param> + <key>grid_pos</key> + <value>1, 4, 1, 2</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(830, 130)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>address</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>IP Address</value> + </param> + <param> + <key>value</key> + <value></value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>a</value> + </param> + <param> + <key>_coordinate</key> + <value>(190, 15)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>fft</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>FFT Plot</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>freq</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>15</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value>(-1, 400)</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value>nb0, 0</value> + </param> + <param> + <key>freqvar</key> + <value>None</value> + </param> + <param> + <key>_coordinate</key> + <value>(314, 359)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_waterfallsink2</key> + <param> + <key>id</key> + <value>wxgui_waterfallsink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Waterfall Plot</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>dynamic_range</key> + <value>100</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>512</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value>(-1, 400)</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value>nb0, 1</value> + </param> + <param> + <key>freqvar</key> + <value>None</value> + </param> + <param> + <key>_coordinate</key> + <value>(313, 573)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_text_box</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Sample Rate</value> + </param> + <param> + <key>value</key> + <value>param_samp_rate</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>formatter</key> + <value>None</value> + </param> + <param> + <key>grid_pos</key> + <value>1, 0, 1, 3</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(358, 129)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> <value>freq</value> </param> <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>RX Tune Frequency</value> + </param> + <param> + <key>value</key> + <value>param_freq</value> + </param> + <param> <key>min</key> - <value>2.4e9</value> + <value>50e6</value> </param> <param> <key>max</key> - <value>2.5e9</value> + <value>6e9</value> </param> <param> <key>num_steps</key> - <value>100</value> + <value>1000</value> </param> <param> <key>style</key> @@ -946,7 +1437,7 @@ </param> <param> <key>grid_pos</key> - <value></value> + <value>3, 0, 1, 8</value> </param> <param> <key>notebook</key> @@ -954,7 +1445,7 @@ </param> <param> <key>_coordinate</key> - <value>(36, 376)</value> + <value>(510, 128)</value> </param> <param> <key>_rotation</key> @@ -965,7 +1456,7 @@ <key>variable_slider</key> <param> <key>id</key> - <value>tun_gain</value> + <value>gain</value> </param> <param> <key>_enabled</key> @@ -973,11 +1464,11 @@ </param> <param> <key>label</key> - <value>UHD Gain</value> + <value>RX Gain</value> </param> <param> <key>value</key> - <value>gain</value> + <value>param_gain</value> </param> <param> <key>min</key> @@ -985,11 +1476,11 @@ </param> <param> <key>max</key> - <value>20</value> + <value>31.5</value> </param> <param> <key>num_steps</key> - <value>100</value> + <value>63</value> </param> <param> <key>style</key> @@ -1001,7 +1492,7 @@ </param> <param> <key>grid_pos</key> - <value></value> + <value>2, 0, 1, 8</value> </param> <param> <key>notebook</key> @@ -1009,7 +1500,7 @@ </param> <param> <key>_coordinate</key> - <value>(177, 377)</value> + <value>(679, 130)</value> </param> <param> <key>_rotation</key> @@ -1018,7 +1509,19 @@ </block> <connection> <source_block_id>uhd_usrp_source_0</source_block_id> - <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>uhd_usrp_source_0</source_block_id> + <sink_block_id>wxgui_waterfallsink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>uhd_usrp_source_0</source_block_id> + <sink_block_id>fft</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h index b5acabee4..1243ddcc2 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -129,6 +129,19 @@ public: virtual void set_start_time(const uhd::time_spec_t &time) = 0; /*! + * *Advanced use only:* + * Issue a stream command to all channels in this source block. + * + * This method is intended to override the default "always on" behavior. + * After starting the flow graph, the user should call stop() on this block, + * then issue any desired arbitrary stream_cmd_t structs to the device. + * The USRP will be able to enqueue several stream commands in the FPGA. + * + * \param cmd the stream command to issue to all source channels + */ + virtual void issue_stream_cmd(const uhd::stream_cmd_t &cmd) = 0; + + /*! * Returns identifying information about this USRP's configuration. * Returns motherboard ID, name, and serial. * Returns daughterboard RX ID, subdev name and spec, serial, and antenna. diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index ad4cb4d81..3813673b4 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -338,8 +338,8 @@ public: //If receive resulted in a timeout condition: //We now receive a single packet with a large timeout. - while (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){ - if (boost::this_thread::interruption_requested()) return WORK_DONE; + if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) + { num_samps = _rx_stream->recv( output_items, noutput_items, _metadata, 0.1, true/*one pkt*/ ); @@ -377,9 +377,8 @@ public: break; case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT: - //Assume that the user called stop() on the flow graph. - //However, a timeout can occur under error conditions. - return WORK_DONE; + //its ok to timeout, perhaps the user is doing finite streaming + return 0; case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: _tag_now = true; @@ -402,6 +401,11 @@ public: _stream_now = false; } + void issue_stream_cmd(const uhd::stream_cmd_t &cmd) + { + _dev->issue_stream_cmd(cmd); + } + bool start(void){ #ifdef GR_UHD_USE_STREAM_API _rx_stream = _dev->get_rx_stream(_stream_args); diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 513c1da7e..99258c0f5 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -76,6 +76,8 @@ %include <uhd/types/time_spec.hpp> +%include <uhd/types/stream_cmd.hpp> + %include <uhd/types/clock_config.hpp> %include <uhd/types/metadata.hpp> |