From 5368f164a1c68c094c6649424f052c5180ce5269 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 16 Oct 2021 00:59:39 +0200 Subject: Added methods for value manipulation in daemon --- src/hwdmodule.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/hwdmodule.cpp b/src/hwdmodule.cpp index d0565df..3d21e08 100644 --- a/src/hwdmodule.cpp +++ b/src/hwdmodule.cpp @@ -11,8 +11,27 @@ static PyObject * hwd_stop_server(PyObject * self, PyObject * args) } +static PyObject * hwd_get_value(PyObject * self, PyObject * args) +{ + const int value = hwd::get_value(); + return PyLong_FromLong(value); +} + + +static PyObject * hwd_set_value(PyObject * self, PyObject * args) +{ + int value = 0; + if (!PyArg_ParseTuple(args, "i", &value)) + return NULL; + hwd::set_value(value); + Py_RETURN_NONE; +} + + static PyMethodDef HwdMethods[] = { {"stop_server", hwd_stop_server, METH_VARARGS, "Shutdown daemon instance"}, + {"get_value", hwd_get_value, METH_VARARGS, "Gets value from the daemon instance"}, + {"set_value", hwd_set_value, METH_VARARGS, "Sets integer value in the daemon instance"}, {NULL, NULL, 0, NULL} }; -- cgit v1.1