summaryrefslogtreecommitdiff
path: root/gr-usrp/src/usrp_swig.i
blob: b1797d7589625e3b668f2365683f1e424094a783 (plain)
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
/* -*- c++ -*- */
/*
 * Copyright 2008,2009 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.
 */

%include "gnuradio.i"	// the common stuff

%{
#include <vector>
%}

%include <usrp/usrp_subdev_spec.h>
%include <usrp/db_base.i>
%include <fpga_regs_common.h>
%include <fpga_regs_standard.h>
%include "usrp_standard.i"
%include "usrp_base.i"
%include "usrp_source_base.i"
%include "usrp_source_c.i"
%include "usrp_source_s.i"
%include "usrp_sink_base.i"
%include "usrp_sink_c.i"
%include "usrp_sink_s.i"

#ifdef SWIGPYTHON
//---Allow a more Pythonic interface
%pythoncode %{

# Allow subdev_spec to be tuple
def __selected_subdev(self, subdev_spec):
  ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
  return self._real_selected_subdev(ss)

# Allow subdev_spec to be tuple
def __determine_tx_mux_value(self, subdev_spec, subdev_spec_=None):
    ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
    if subdev_spec_ is None: return self._real_determine_tx_mux_value(ss)
    ss_ = usrp_subdev_spec(subdev_spec_[0], subdev_spec_[1])
    return self._real_determine_tx_mux_value(ss, ss_)

# Allow subdev_spec to be tuple
def __determine_rx_mux_value(self, subdev_spec, subdev_spec_=None):
    ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1])
    if subdev_spec_ is None: return self._real_determine_rx_mux_value(ss)
    ss_ = usrp_subdev_spec(subdev_spec_[0], subdev_spec_[1])
    return self._real_determine_rx_mux_value(ss, ss_)

# Allow subdev_spec to be tuple
def __pick_subdev(self, candidates=[]):
    ss = self._real_pick_subdev(candidates)
    return (ss.side, ss.subdev)

# Allow subdev_spec to be tuple
def __pick_tx_subdevice(self):
    ss = self._real_pick_tx_subdevice()
    return (ss.side, ss.subdev)

# Allow subdev_spec to be tuple
def __pick_rx_subdevice(self):
    ss = self._real_pick_rx_subdevice()
    return (ss.side, ss.subdev)

# Make return tune_result or None on failure
def __tune(self, chan, db, target_freq):
    tr = usrp_tune_result()
    r = self._real_tune(chan, db, target_freq, tr)
    if r:
        return tr
    else:
        return None

# Allow to be called as a free function
def tune(u, chan, subdev, target_freq):
    return u.tune(chan, subdev, target_freq)

# Allow to be called as free function
def determine_tx_mux_value(u, subdev_spec, subdev_spec_=None):
    return u.determine_tx_mux_value(subdev_spec, subdev_spec_)

# Allow to be called as free function
def determine_rx_mux_value(u, subdev_spec, subdev_spec_=None):
    return u.determine_rx_mux_value(subdev_spec, subdev_spec_)

# Allow to be called as free function
def selected_subdev(u, subdev_spec):
    return u.selected_subdev(subdev_spec)

# Allow to be called as free function
def pick_subdev(u, candidates=[]):
    return u.pick_subdev(candidates);

# Allow to be called as free function
def pick_tx_subdevice(u):
    return u.pick_tx_subdevice();

# Allow to be called as free function
def pick_rx_subdevice(u):
    return u.pick_rx_subdevice();

# Jam into Python objects
usrp_sink_c_sptr.determine_tx_mux_value   = __determine_tx_mux_value
usrp_sink_s_sptr.determine_tx_mux_value   = __determine_tx_mux_value

usrp_source_c_sptr.determine_rx_mux_value = __determine_rx_mux_value
usrp_source_s_sptr.determine_rx_mux_value = __determine_rx_mux_value

usrp_sink_c_sptr.selected_subdev          = __selected_subdev
usrp_sink_s_sptr.selected_subdev          = __selected_subdev
usrp_source_c_sptr.selected_subdev        = __selected_subdev
usrp_source_s_sptr.selected_subdev        = __selected_subdev

usrp_sink_c_sptr.tune                     = __tune
usrp_sink_s_sptr.tune                     = __tune
usrp_source_c_sptr.tune                   = __tune
usrp_source_s_sptr.tune                   = __tune

usrp_sink_c_sptr.pick_subdev              = __pick_subdev
usrp_sink_s_sptr.pick_subdev              = __pick_subdev
usrp_source_c_sptr.pick_subdev            = __pick_subdev
usrp_source_s_sptr.pick_subdev            = __pick_subdev

usrp_sink_c_sptr.pick_tx_subdevice        = __pick_tx_subdevice
usrp_sink_s_sptr.pick_tx_subdevice        = __pick_tx_subdevice
usrp_source_c_sptr.pick_rx_subdevice      = __pick_rx_subdevice
usrp_source_s_sptr.pick_rx_subdevice      = __pick_rx_subdevice

%}
#endif


#if SWIGGUILE
%scheme %{
(load-extension-global "libguile-gnuradio-usrp_swig" "scm_init_gnuradio_usrp_swig_module")
%}

%goops %{
(use-modules (gnuradio gnuradio_core_runtime))
%}
#endif