aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/cal/cal_python.hpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-03-03 16:10:06 -0800
committerAaron Rossetto <aaron.rossetto@ni.com>2020-04-02 11:55:17 -0500
commit3fe5ccf700a0c6f27dca9511386460194dcc593c (patch)
tree19d394faac0581601d3d6e5d35a7a82e325bf245 /host/lib/cal/cal_python.hpp
parent1e016e49e82c430197a90a018fbc7613cc654088 (diff)
downloaduhd-3fe5ccf700a0c6f27dca9511386460194dcc593c.tar.gz
uhd-3fe5ccf700a0c6f27dca9511386460194dcc593c.tar.bz2
uhd-3fe5ccf700a0c6f27dca9511386460194dcc593c.zip
uhd: cal: Add iq_cal calibration data container class
This class can be used to store calibration coefficients for the X300 DC offset and IQ imbalance calibration. Note: This also modifies Doxyfile.in to not document files generated by flatc.
Diffstat (limited to 'host/lib/cal/cal_python.hpp')
-rw-r--r--host/lib/cal/cal_python.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/host/lib/cal/cal_python.hpp b/host/lib/cal/cal_python.hpp
index 0fe87046f..39a13d94c 100644
--- a/host/lib/cal/cal_python.hpp
+++ b/host/lib/cal/cal_python.hpp
@@ -8,6 +8,8 @@
#define INCLUDED_UHD_CAL_PYTHON_HPP
#include <uhd/cal/database.hpp>
+#include <uhd/cal/interpolation.hpp>
+#include <uhd/cal/iq_cal.hpp>
std::vector<uint8_t> pybytes_to_vector(const py::bytes& data)
{
@@ -56,6 +58,42 @@ void export_cal(py::module& m)
[](const std::string& key, const std::string& serial, const py::bytes data) {
database::write_cal_data(key, serial, pybytes_to_vector(data));
});
+
+ py::enum_<interp_mode>(m, "interp_mode")
+ .value("NEAREST_NEIGHBOR", interp_mode::NEAREST_NEIGHBOR)
+ .value("LINEAR", interp_mode::LINEAR);
+
+ py::class_<container, std::shared_ptr<container>>(m, "container")
+ .def("get_name", &container::get_name)
+ .def("get_serial", &container::get_serial)
+ .def("get_timestamp", &container::get_name)
+ .def("serialize",
+ [](std::shared_ptr<container>& self) {
+ return vector_to_pybytes(self->serialize());
+ })
+ .def("deserialize", [](std::shared_ptr<container>& self, const py::bytes data) {
+ self->deserialize(pybytes_to_vector(data));
+ });
+
+ py::class_<iq_cal, container, iq_cal::sptr>(m, "iq_cal")
+ .def(py::init([](const std::string& name,
+ const std::string& serial,
+ const uint64_t timestamp) {
+ return iq_cal::make(name, serial, timestamp);
+ }))
+ .def(py::init([]() { return iq_cal::make(); }))
+ .def(py::init([](const py::bytes data) {
+ return container::make<iq_cal>(pybytes_to_vector(data));
+ }))
+ .def("set_interp_mode", &iq_cal::set_interp_mode)
+ .def("get_cal_coeff", &iq_cal::get_cal_coeff)
+ .def("set_cal_coeff",
+ &iq_cal::set_cal_coeff,
+ py::arg("freq"),
+ py::arg("coeff"),
+ py::arg("suppression_abs") = 0,
+ py::arg("suppression_delta") = 0)
+ .def("clear", &iq_cal::clear);
}
#endif /* INCLUDED_UHD_CAL_PYTHON_HPP */