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
|
//
// Copyright 2018 Ettus Research, a National Instruments Company
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
// Relative to uhd/host/lib/usrp/common/ad9361_driver/
#include "../../../include/uhdlib/usrp/common/ad9361_ctrl.hpp"
#include <boost/make_shared.hpp>
#include <boost/noncopyable.hpp>
#include <functional>
#include <string>
#include <vector>
#include <future>
namespace mpm { namespace chips {
using uhd::usrp::ad9361_ctrl;
}}; // namespace mpm::chips
//! Async calls
std::future<double> handle_tune;
std::future<double> handle_set_clock_rate;
// TODO: pull in filter_info_base
#ifdef LIBMPM_PYTHON
void export_catalina(py::module& top_module)
{
using namespace mpm::chips;
auto m = top_module.def_submodule("ad9361");
py::class_<ad9361_ctrl, boost::shared_ptr<ad9361_ctrl>>(m, "ad9361_ctrl")
.def_static("get_gain_names", &ad9361_ctrl::get_gain_names)
// Make this "Python private" because the return value can't be serialized
.def_static("_get_gain_range", &ad9361_ctrl::get_gain_range)
.def_static("get_rf_freq_range", &ad9361_ctrl::get_rf_freq_range)
.def_static("get_bw_filter_range", &ad9361_ctrl::get_bw_filter_range)
.def_static("get_clock_rate_range", &ad9361_ctrl::get_clock_rate_range)
.def("set_bw_filter", &ad9361_ctrl::set_bw_filter)
.def("set_gain", &ad9361_ctrl::set_gain)
.def("set_agc", &ad9361_ctrl::set_agc)
.def("set_agc_mode", &ad9361_ctrl::set_agc_mode)
.def("set_clock_rate", &ad9361_ctrl::set_clock_rate)
.def("set_active_chains", &ad9361_ctrl::set_active_chains)
.def("set_timing_mode", &ad9361_ctrl::set_timing_mode)
.def("tune", &ad9361_ctrl::tune)
.def("set_dc_offset", &ad9361_ctrl::set_dc_offset)
.def("set_dc_offset_auto", &ad9361_ctrl::set_dc_offset_auto)
.def("set_iq_balance", &ad9361_ctrl::set_iq_balance)
.def("set_iq_balance_auto", &ad9361_ctrl::set_iq_balance_auto)
.def("get_freq", &ad9361_ctrl::get_freq)
.def("data_port_loopback", &ad9361_ctrl::data_port_loopback)
.def("get_rssi",
+[](ad9361_ctrl& self, std::string which) {
return self.get_rssi(which).to_real();
})
.def("get_temperature",
+[](ad9361_ctrl& self) { return self.get_temperature().to_real(); })
.def("get_filter_names", &ad9361_ctrl::get_filter_names)
// Make this "Python private" because the return value can't be serialized.
.def("_get_filter", &ad9361_ctrl::get_filter)
.def("set_filter", &ad9361_ctrl::set_filter)
.def("output_digital_test_tone", &ad9361_ctrl::output_digital_test_tone);
m.def("async__tune", +[](
ad9361_ctrl& catalina,
const std::string &which,
const double value
){
handle_tune = std::async(std::launch::async,
&ad9361_ctrl::tune,
&catalina,
which,
value
);
});
m.def("await__tune", +[](
)->bool{
if (handle_tune.wait_for(std::chrono::seconds(0))
== std::future_status::ready){
handle_tune.get();
return true;
}
return false;
});
m.def("async__set_clock_rate", +[](
ad9361_ctrl& catalina,
const double value
){
handle_set_clock_rate = std::async(std::launch::async,
&ad9361_ctrl::set_clock_rate,
&catalina,
value
);
});
m.def("await__set_clock_rate", +[](
)->bool{
if (handle_set_clock_rate.wait_for(std::chrono::seconds(0))
== std::future_status::ready){
handle_set_clock_rate.get();
return true;
}
return false;
});
}
#endif
|