bindings: python: provide Line.is_requested()
authorBartosz Golaszewski <bartekgola@gmail.com>
Tue, 15 May 2018 16:33:47 +0000 (18:33 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Tue, 15 May 2018 16:34:52 +0000 (18:34 +0200)
Add a python wrapper around gpiod_line_is_requested().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
bindings/python/gpiodmodule.c

index 8e1f012c9ca5b447fbabffb027422064caeeee77..8f8ac28f6285dd07b8fc19d4de18310d6e5c54cd 100644 (file)
@@ -344,6 +344,17 @@ static PyObject *gpiod_Line_request(gpiod_LineObject *self,
        return ret;
 }
 
+PyDoc_STRVAR(gpiod_Line_is_requested_doc,
+"Check if this user has ownership of this line.");
+
+static PyObject *gpiod_Line_is_requested(gpiod_LineObject *self)
+{
+       if (gpiod_line_is_requested(self->line))
+               Py_RETURN_TRUE;
+
+       Py_RETURN_FALSE;
+}
+
 PyDoc_STRVAR(gpiod_Line_get_value_doc,
 "Read the current value of this GPIO line.");
 
@@ -566,6 +577,12 @@ static PyMethodDef gpiod_Line_methods[] = {
                .ml_flags = METH_VARARGS | METH_KEYWORDS,
                .ml_doc = gpiod_Line_request_doc,
        },
+       {
+               .ml_name = "is_requested",
+               .ml_meth = (PyCFunction)gpiod_Line_is_requested,
+               .ml_flags = METH_NOARGS,
+               .ml_doc = gpiod_Line_is_requested_doc,
+       },
        {
                .ml_name = "get_value",
                .ml_meth = (PyCFunction)gpiod_Line_get_value,