3 * Copyright 2004,2009 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 %feature("autodoc", "1"); // generate python docstrings
25 %import "gnuradio.i" // the common stuff
28 #include "gnuradio_swig_bug_workaround.h" // mandatory bug fix
29 #include "msdd_source_s.h"
30 #include "msdd_source_c.h"
31 #include "msdd_source_simple.h"
34 // ================================================================
36 // ================================================================
38 // ----------------------------------------------------------------
40 class msdd_source_base : public gr_sync_block {
43 msdd_source_base (const std::string &name,
44 gr_io_signature_sptr output_signature,
46 msdd_source_base::msdd_command_type_t opp_mode,
48 unsigned short port_src
49 ) throw (std::runtime_error);
52 * \brief number of bytes in a low-level sample
54 unsigned int sizeof_basic_sample() const;
57 * \brief convert between native msdd format and output item format
59 * \param output_items[out] stream(s) of output items
60 * \param output_index[in] starting index in output_items
61 * \param output_items_available[in] number of empty items available at item[index]
62 * \param output_items_produced[out] number of items produced by copy
63 * \param msdd_buffer[in] source buffer
64 * \param msdd_buffer_length[in] number of bytes available in \p msdd_buffer
65 * \param bytes_read[out] number of bytes read from \p msdd_buffer
67 * The copy must consume all bytes available. That is, \p bytes_read must equal
68 * \p msdd_buffer_length.
70 virtual void copy_from_msdd_buffer (gr_vector_void_star &output_items,
72 int output_items_available,
73 int &output_items_produced,
74 const void *msdd_buffer,
75 int msdd_buffer_length,
78 int readsock(int sockfd, unsigned char* buf, int nbytes);
81 void* make_request_packet(unsigned int& size, unsigned int number_samples);
84 //! magic value used on alternate register read interfaces
85 static const int READ_FAILED = -99999;
89 int work (int noutput_items,
90 gr_vector_const_void_star &input_items,
91 gr_vector_void_star &output_items);
97 * \brief Set Programmable Gain Amplifier (PGA)
99 * \param which which D/A [0,3]
100 * \param gain_in_db gain value (linear in dB)
102 * gain is rounded to closest setting supported by hardware.
103 * Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.
104 * Setting DAC 0 affects DAC 1 and vice versa. Same with DAC 2 and DAC 3.
106 * \returns true iff sucessful.
108 * \sa pga_min(), pga_max(), pga_db_per_step()
110 bool set_pga (int which, double gain_in_db);
113 * \brief Return programmable gain amplifier gain in dB.
115 * \param which which D/A [0,3]
117 double pga (int which) const;
120 * \brief Return minimum legal PGA gain in dB.
122 double pga_min () const;
125 * \brief Return maximum legal PGA gain in dB.
127 double pga_max () const;
130 * \brief Return hardware step size of PGA (linear in dB).
132 double pga_db_per_step () const;
135 * \brief open a socket specified by the port and ip address info
137 * Opens a socket, binds to the address, and waits for a connection
138 * over UDP. If any of these fail, the fuction retuns the error and exits.
143 * \brief Close current socket.
145 * Shuts down read/write on the socket
150 * \brief Set decimator rate. \p rate must be EVEN and in [8, 256].
152 * The final complex sample rate across the USB is
153 * adc_freq () / decim_rate ()
155 bool set_decim_rate (unsigned int rate);
158 * \brief set the center frequency of the digital down converter.
160 * \p channel must be 0. \p freq is the center frequency in Hz.
161 * It must be in the range [-FIXME, FIXME]. The frequency specified is
162 * quantized. Use rx_freq to retrieve the actual value used.
164 bool set_rx_freq (int channel, double freq);
166 void set_verbose (bool verbose);
170 unsigned int decim_rate () const;
171 double rx_freq (int channel) const;
172 int noverruns () const { return d_noverruns; }
175 * \brief return the msdd's serial number.
177 * \returns non-zero length string iff successful.
179 std::string serial_number();
181 bool set_desired_packet_size (int which, unsigned long packet_size);
183 unsigned long desired_packet_size (int which) const;
188 // ================================================================
190 // ================================================================
193 // ----------------------------------------------------------------
195 GR_SWIG_BLOCK_MAGIC(msdd,source_s)
198 msdd_make_source_s (int which_board,
199 unsigned int decim_rate,
200 unsigned int fft_points,
201 double initial_rx_freq,
204 unsigned short port_src
205 ) throw (std::runtime_error);
208 class msdd_source_s : public msdd_source_base {
210 msdd_source_s (int which_board,
211 unsigned int decim_rate,
212 unsigned int fft_points,
213 double initial_rx_freq,
216 unsigned short port_src
217 ) throw (std::runtime_error);
224 GR_SWIG_BLOCK_MAGIC(msdd,source_c)
227 msdd_make_source_c (int which_board,
230 unsigned short port_src
231 ) throw (std::runtime_error);
234 class msdd_source_c : public msdd_source_base {
236 msdd_source_c (int which_board,
239 unsigned short port_src
240 ) throw (std::runtime_error);
250 GR_SWIG_BLOCK_MAGIC(msdd,source_simple)
252 msdd_source_simple_sptr
253 msdd_make_source_simple (
255 unsigned short port_src
258 class msdd_source_simple : public gr_sync_block {
262 unsigned short port_src
267 int work (int noutput_items,
268 gr_vector_const_void_star &input_items,
269 gr_vector_void_star &output_items);
276 gr_vector_int gain_range();
277 gr_vector_float freq_range();
279 bool set_decim_rate(unsigned int);
280 bool set_rx_freq(int,double);
281 bool set_pga(int,double);