From 919a147afcbecace5107a4d0a4da556cfd56df92 Mon Sep 17 00:00:00 2001 From: Samuel O'Brien Date: Thu, 25 Jun 2020 15:43:32 -0500 Subject: python: Add bindings for C++ CHDR Parser This commit adds pybind11 glue code for the userland chdr parsing code introduced in the uhd::utils::chdr namespace. Additionally, it moves some pybind11 adapter code to a common pybind_adaptors.hpp file which originally existed in the cal_python.hpp file. This commit also adds unit tests for the python bindings using a captured wireshark trace which is located in rfnoc_packets_*.py and some handwritten packets in hardcoded_packets.py Signed-off-by: Samuel O'Brien --- host/lib/cal/cal_python.hpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'host/lib/cal') diff --git a/host/lib/cal/cal_python.hpp b/host/lib/cal/cal_python.hpp index 513dda344..fa38c568b 100644 --- a/host/lib/cal/cal_python.hpp +++ b/host/lib/cal/cal_python.hpp @@ -11,26 +11,9 @@ #include #include #include +#include #include -namespace pybind11 { namespace detail { -template -struct type_caster> : optional_caster> -{ -}; -}} - -std::vector pybytes_to_vector(const py::bytes& data) -{ - const std::string data_str = std::string(data); - return std::vector(data_str.cbegin(), data_str.cend()); -} - -py::bytes vector_to_pybytes(const std::vector& data) -{ - return py::bytes(std::string(data.cbegin(), data.cend())); -} - void export_cal(py::module& m) { using namespace uhd::usrp::cal; @@ -48,7 +31,8 @@ void export_cal(py::module& m) .value("NONE", source::NONE); py::class_(m, "database") - .def_static("read_cal_data", + .def_static( + "read_cal_data", [](const std::string& key, const std::string& serial, const source source_type) { -- cgit v1.2.3