1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
/* -*- c++ -*- */
/*
* Copyright 2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
%feature("autodoc", "1"); // generate python docstrings
%include "exception.i"
%import "gnuradio.i" // the common stuff
%{
#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix
#include <stdexcept>
#include "msdd_source_s.h"
#include "msdd_source_c.h"
%}
// ================================================================
// abstract classes
// ================================================================
// ----------------------------------------------------------------
class msdd_source_base : public gr_sync_block {
protected:
msdd_source_base (const std::string &name,
gr_io_signature_sptr output_signature,
int which_board,
msdd_source_base::msdd_command_type_t opp_mode,
const char *src,
unsigned short port_src
) throw (std::runtime_error);
/*!
* \brief return number of msdd input bytes required to produce noutput items.
*/
int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0;
/*!
* \brief number of bytes in a low-level sample
*/
unsigned int sizeof_basic_sample() const;
/*!
* \brief convert between native msdd format and output item format
*
* \param output_items[out] stream(s) of output items
* \param output_index[in] starting index in output_items
* \param output_items_available[in] number of empty items available at item[index]
* \param output_items_produced[out] number of items produced by copy
* \param msdd_buffer[in] source buffer
* \param msdd_buffer_length[in] number of bytes available in \p msdd_buffer
* \param bytes_read[out] number of bytes read from \p msdd_buffer
*
* The copy must consume all bytes available. That is, \p bytes_read must equal
* \p msdd_buffer_length.
*/
virtual void copy_from_msdd_buffer (gr_vector_void_star &output_items,
int output_index,
int output_items_available,
int &output_items_produced,
const void *msdd_buffer,
int msdd_buffer_length,
int &bytes_read) = 0;
int readsock(int sockfd, unsigned char* buf, int nbytes);
void* make_request_packet(unsigned int& size, unsigned int number_samples);
public:
//! magic value used on alternate register read interfaces
static const int READ_FAILED = -99999;
~msdd_source_base ();
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
bool start();
bool stop();
/*!
* \brief Set Programmable Gain Amplifier (PGA)
*
* \param which which D/A [0,3]
* \param gain_in_db gain value (linear in dB)
*
* gain is rounded to closest setting supported by hardware.
* Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.
* Setting DAC 0 affects DAC 1 and vice versa. Same with DAC 2 and DAC 3.
*
* \returns true iff sucessful.
*
* \sa pga_min(), pga_max(), pga_db_per_step()
*/
bool set_pga (int which, double gain_in_db);
/*!
* \brief Return programmable gain amplifier gain in dB.
*
* \param which which D/A [0,3]
*/
double pga (int which) const;
/*!
* \brief Return minimum legal PGA gain in dB.
*/
double pga_min () const;
/*!
* \brief Return maximum legal PGA gain in dB.
*/
double pga_max () const;
/*!
* \brief Return hardware step size of PGA (linear in dB).
*/
double pga_db_per_step () const;
/*!
* \brief open a socket specified by the port and ip address info
*
* Opens a socket, binds to the address, and waits for a connection
* over UDP. If any of these fail, the fuction retuns the error and exits.
*/
bool open();
/*!
* \brief Close current socket.
*
* Shuts down read/write on the socket
*/
bool close();
/*!
* \brief Set decimator rate. \p rate must be EVEN and in [8, 256].
*
* The final complex sample rate across the USB is
* adc_freq () / decim_rate ()
*/
bool set_decim_rate (unsigned int rate);
/*!
* \brief set the center frequency of the digital down converter.
*
* \p channel must be 0. \p freq is the center frequency in Hz.
* It must be in the range [-FIXME, FIXME]. The frequency specified is
* quantized. Use rx_freq to retrieve the actual value used.
*/
bool set_rx_freq (int channel, double freq);
void set_verbose (bool verbose);
// ACCESSORS
unsigned int decim_rate () const;
double rx_freq (int channel) const;
int noverruns () const { return d_noverruns; }
/*!
* \brief return the msdd's serial number.
*
* \returns non-zero length string iff successful.
*/
std::string serial_number();
bool set_desired_packet_size (int which, unsigned long packet_size);
unsigned long desired_packet_size (int which) const;
};
// ================================================================
// concrete sources
// ================================================================
// ----------------------------------------------------------------
GR_SWIG_BLOCK_MAGIC(msdd,source_s)
msdd_source_s_sptr
msdd_make_source_s (int which_board,
unsigned int decim_rate,
unsigned int fft_points,
double initial_rx_freq,
int opp_mode,
const char *src,
unsigned short port_src
) throw (std::runtime_error);
class msdd_source_s : public msdd_source_base {
protected:
msdd_source_s (int which_board,
unsigned int decim_rate,
unsigned int fft_points,
double initial_rx_freq,
int opp_mode,
const char *src,
unsigned short port_src
) throw (std::runtime_error);
virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);
public:
~msdd_source_s ();
};
GR_SWIG_BLOCK_MAGIC(msdd,source_c)
msdd_source_c_sptr
msdd_make_source_c (int which_board,
int opp_mode,
const char *src,
unsigned short port_src
) throw (std::runtime_error);
class msdd_source_c : public msdd_source_base {
protected:
msdd_source_c (int which_board,
int opp_mode,
const char *src,
unsigned short port_src
) throw (std::runtime_error);
virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);
public:
~msdd_source_c ();
};
|