From ef6326a174e6880be5e2eaeac26a2c5de0768807 Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Tue, 21 Mar 2017 19:46:50 -0700 Subject: mpm: python refactoring --- mpm/lib/udev_helper.hpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 mpm/lib/udev_helper.hpp (limited to 'mpm/lib/udev_helper.hpp') diff --git a/mpm/lib/udev_helper.hpp b/mpm/lib/udev_helper.hpp new file mode 100644 index 000000000..055a93cee --- /dev/null +++ b/mpm/lib/udev_helper.hpp @@ -0,0 +1,62 @@ +// +// Copyright 2017 Ettus Research (National Instruments) +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 this program. If not, see . +// + +#include +#include +#include + +namespace mpm { + /*! + * The udev_helper class: + * + * talks to libudev and holds a udev context. Device enumeration is done + * once during initialization. + * On destruction the udev context is unreferenced again. + */ + class udev_helper{ + public: + udev_helper(); + ~udev_helper(); + /*! + * Return the nvmem device associated with the parent address + * \param address of the parent platform driver + * \return a string containing the name of file of the device in /sys + */ + std::string get_eeprom(const std::string &address); + /*! + * Find spidevices associated with the spi_master + * \param address of the parent platform driver + * \return a vector of string containing the device paths is /dev + */ + std::vector get_spidev_nodes(const std::string &spi_master); + + private: + udev *_udev; + udev_enumerate *_enumerate; + }; +} + +#ifdef LIBMPM_PYTHON +void export_udev_helper(){ + LIBMPM_BOOST_PREAMBLE("udev") + bp::class_("udev_helper", bp::init<>()) + .def("get_eeprom", &mpm::udev_helper::get_eeprom) + .def("get_spidev_nodes", &mpm::udev_helper::get_spidev_nodes) + ; +} +#endif + -- cgit v1.2.3