Projects
rs485
python-pycmox
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
python-pycmox.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Sun Jan 1 11:03:22 UTC 2023 - Matwey V. Kornilov <matwey@sai.msu.ru> + +- Version 0.2.0 + +------------------------------------------------------------------- Mon Mar 14 17:03:23 UTC 2022 - Matwey V. Kornilov <matwey@sai.msu.ru> - Initial version
View file
python-pycmox.spec
Changed
@@ -1,7 +1,7 @@ # # spec file for package python-pycmox # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pycmox -Version: 0.1.0 +Version: 0.2.0 Release: 0 Summary: Python wrapper for RS485 exchange License: LGPL-3.0-or-later @@ -27,14 +27,11 @@ URL: https://curl.sai.msu.ru/hg/pycmox Source: pycmox-%{version}.tar.xz BuildRequires: %{python_module devel} +BuildRequires: %{python_module pybind11-devel} BuildRequires: %{python_module setuptools} BuildRequires: %{pythons} BuildRequires: gcc -%if %{with python2} -BuildRequires: libboost_python-devel -%endif BuildRequires: gcc-c++ -BuildRequires: libboost_python3-devel BuildRequires: python-rpm-macros BuildRoot: %{_tmppath}/%{name}-%{version}-build %python_subpackages
View file
_service
Changed
@@ -1,7 +1,7 @@ <services> <service name="tar_scm" mode="disabled"> <param name="url">http://curl.sai.msu.ru/hg/pycmox</param> - <param name="revision">0.1.0</param> + <param name="revision">0.2.0</param> <param name="versionformat">{latesttag}</param> <param name="scm">hg</param> </service>
View file
pycmox-0.2.0.tar.xz/.hgtags
Added
@@ -0,0 +1 @@ +3342af332420fe26a1bfe19e3866c27ac1cd95cb 0.1.0
View file
pycmox-0.1.0.tar.xz/MANIFEST.in -> pycmox-0.2.0.tar.xz/MANIFEST.in
Changed
@@ -1,2 +1,3 @@ include src/infras/exchange.h include README.rst +include requirements.txt
View file
pycmox-0.1.0.tar.xz/README.rst -> pycmox-0.2.0.tar.xz/README.rst
Changed
@@ -6,7 +6,7 @@ Build requirements ================== 1. C++ compiler with C++11 support (gcc 4.8 or later) -2. `Boost.Python Py3 libraries <https://www.boost.org/doc/libs/1_75_0/libs/python/doc/html/index.html>`_ +2. `pybind11 <https://pypi.org/project/pybind11/>`_ Installation ============ @@ -45,7 +45,7 @@ License ======= -Copyright (C) 2021 Matwey V. Kornilov <matwey.kornilov@gmail.com> +Copyright (C) 2021-2023 Matwey V. Kornilov <matwey.kornilov@gmail.com> 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.
View file
pycmox-0.2.0.tar.xz/requirements.txt
Added
@@ -0,0 +1 @@ +pybind11
View file
pycmox-0.1.0.tar.xz/setup.py -> pycmox-0.2.0.tar.xz/setup.py
Changed
@@ -14,19 +14,19 @@ include_dirs = 'src/infras', language = 'c++', extra_compile_args = '-std=gnu++11', - define_macros = ('NO_RS485_LEGACY', None), - libraries = 'boost_python-py3') + define_macros = ('NO_RS485_LEGACY', None)) setup( name='pycmox', - version='0.1.0', + version='0.2.0', packages=, ext_modules=tree, + install_requires='pybind11', include_package_data=True, license='LGPL-3.0-or-later', description='A Python wrapper for lmox', long_description=README, - url='', + url='https://curl.sai.msu.ru/hg/pycmox/', author='Matwey V. Kornilov', author_email='matwey.kornilov@gmail.com', classifiers=
View file
pycmox-0.1.0.tar.xz/src/pycmox.cpp -> pycmox-0.2.0.tar.xz/src/pycmox.cpp
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Matwey V. Kornilov <matwey.kornilov@gmail.com> + * Copyright (c) 2021-2023, Matwey V. Kornilov <matwey.kornilov@gmail.com> * * SPDX-License-Identifier: LGPL-3.0-or-later * @@ -7,21 +7,15 @@ #include <string> #include <memory> +#include <vector> -#include <boost/python.hpp> +#include <pybind11/pybind11.h> #include <exchange.h> -void translator(const BaseRS485::ErrFatal& err) { - PyErr_SetString(PyExc_RuntimeError, err.what()); -} -void translator(const BaseRS485::ErrDriver& err) { - PyErr_SetString(PyExc_RuntimeError, err.what()); -} -void translator(const BaseRS485::ErrSignal& err) { - PyErr_SetString(PyExc_RuntimeError, err.what()); -} +namespace py = pybind11; + class rs485 { public: @@ -43,18 +37,18 @@ int askLong(unsigned int addr, int c) { return impl_->askLong(addr, ALong(c)); } - boost::python::object askData(unsigned int addr, int c) { - auto vec = impl_->askData(addr, AData(c)); + py::bytes askData(unsigned int addr, int c) { + const auto vec = impl_->askData(addr, AData(c)); - const auto handle = boost::python::handle<>(PyBytes_FromStringAndSize(reinterpret_cast<char*>(vec.data()), vec.size())); - return boost::python::object(handle); + return py::bytes(reinterpret_cast<const char*>(vec.data()), vec.size()); } - boost::python::object askRaw(const boost::python::object& data) { - const boost::python::stl_input_iterator<unsigned char> begin(data), end; - auto vec = impl_->askRaw(std::vector<unsigned char>(begin, end)); + py::bytes askRaw(const py::buffer& data) { + const auto info = data.request(); + const auto begin = reinterpret_cast<const unsigned char*>(info.ptr); + const auto end = begin + static_cast<std::size_t>(info.size); + const auto vec = impl_->askRaw(std::vector<unsigned char>(begin, end)); - const auto handle = boost::python::handle<>(PyBytes_FromStringAndSize(reinterpret_cast<char*>(vec.data()), vec.size())); - return boost::python::object(handle); + return py::bytes(reinterpret_cast<const char*>(vec.data()), vec.size()); } int sendSimpleCommand(unsigned int addr, int c) { @@ -66,8 +60,10 @@ int sendWordCommand(unsigned int addr, int c, int w) { return impl_->sendWordCommand(addr, SWord(c), w); } - int sendData(unsigned int addr, const boost::python::object& data) { - const boost::python::stl_input_iterator<unsigned char> begin(data), end; + int sendData(unsigned int addr, const py::buffer& data) { + const auto info = data.request(); + const auto begin = reinterpret_cast<const unsigned char*>(info.ptr); + const auto end = begin + static_cast<std::size_t>(info.size); const std::vector<unsigned char> vec(begin, end); return impl_->sendData(addr, vec.size(), vec); @@ -383,28 +379,24 @@ constexpr const char* rs485::sendData_docstring; -BOOST_PYTHON_MODULE(pycmox) +PYBIND11_MODULE(pycmox, m) { - using namespace boost::python; - - register_exception_translator<BaseRS485::ErrFatal, - void (*)(const BaseRS485::ErrFatal&)>(translator); - register_exception_translator<BaseRS485::ErrDriver, - void (*)(const BaseRS485::ErrDriver&)>(translator); - register_exception_translator<BaseRS485::ErrSignal, - void (*)(const BaseRS485::ErrSignal&)>(translator); + py::register_exception<BaseRS485::ErrFatal>(m, "ErrFatal", PyExc_RuntimeError); + py::register_exception<BaseRS485::ErrDriver>(m, "ErrDriver", PyExc_RuntimeError); + py::register_exception<BaseRS485::ErrSignal>(m, "ErrSignal", PyExc_RuntimeError); { - scope in_RS485 = class_<rs485, boost::noncopyable>("RS485", rs485::docstring, init<std::string, int>(rs485::init_docstring, args("self", "filename", "baudrate"))) - .def("askByte", &rs485::askByte, rs485::askByte_docstring, args("self", "address", "command")) - .def("askWord", &rs485::askWord, rs485::askWord_docstring, args("self", "address", "command")) - .def("askLong", &rs485::askLong, rs485::askLong_docstring, args("self", "address", "command")) - .def("askData", &rs485::askData, rs485::askData_docstring, args("self", "address", "command")) - .def("askRaw", &rs485::askRaw, rs485::askRaw_docstring, args("self", "bytes")) - .def("sendSimpleCommand", &rs485::sendSimpleCommand, rs485::sendSimpleCommand_docstring, args("self", "address", "command")) - .def("sendByteCommand", &rs485::sendByteCommand, rs485::sendByteCommand_docstring, args("self", "address", "command", "argument")) - .def("sendWordCommand", &rs485::sendWordCommand, rs485::sendWordCommand_docstring, args("self", "address", "command", "argument")) - .def("sendData", &rs485::sendData, rs485::sendData_docstring, args("self", "address", "bytes")) + auto in_RS485 = py::class_<rs485>(m, "RS485", rs485::docstring) + .def(py::init<std::string, int>(), rs485::init_docstring, py::arg("filename"), py::arg("baudrate")) + .def("askByte", &rs485::askByte, rs485::askByte_docstring, py::arg("address"), py::arg("command")) + .def("askWord", &rs485::askWord, rs485::askWord_docstring, py::arg("address"), py::arg("command")) + .def("askLong", &rs485::askLong, rs485::askLong_docstring, py::arg("address"), py::arg("command")) + .def("askData", &rs485::askData, rs485::askData_docstring, py::arg("address"), py::arg("command")) + .def("askRaw", &rs485::askRaw, rs485::askRaw_docstring, py::arg("bytes")) + .def("sendSimpleCommand", &rs485::sendSimpleCommand, rs485::sendSimpleCommand_docstring, py::arg("address"), py::arg("command")) + .def("sendByteCommand", &rs485::sendByteCommand, rs485::sendByteCommand_docstring, py::arg("address"), py::arg("command"), py::arg("argument")) + .def("sendWordCommand", &rs485::sendWordCommand, rs485::sendWordCommand_docstring, py::arg("address"), py::arg("command"), py::arg("argument")) + .def("sendData", &rs485::sendData, rs485::sendData_docstring, py::arg("address"), py::arg("bytes")) ; in_RS485.attr("DONE") = static_cast<int>(BaseRS485::DONE);
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.