diff --git a/setup.py b/setup.py index 3c6296e..2a475f1 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ classifiers = ['Development Status :: 3 - Alpha', 'Topic :: System :: Hardware'] setup(name = 'CHIP_IO', - version = '0.0.7', + version = '0.0.8', author = 'Robert Wolterman', author_email = 'robert.wolterman@gmail.com', description = 'A module to control CHIP IO channels', diff --git a/source/constants.c b/source/constants.c index 8254a51..7696318 100644 --- a/source/constants.c +++ b/source/constants.c @@ -76,6 +76,6 @@ void define_constants(PyObject *module) both_edge = Py_BuildValue("i", BOTH_EDGE); PyModule_AddObject(module, "BOTH", both_edge); - version = Py_BuildValue("s", "0.0.7"); + version = Py_BuildValue("s", "0.0.8"); PyModule_AddObject(module, "VERSION", version); } diff --git a/source/py_gpio.c b/source/py_gpio.c index 3e19d21..f417459 100644 --- a/source/py_gpio.c +++ b/source/py_gpio.c @@ -546,6 +546,19 @@ static PyObject *py_setwarnings(PyObject *self, PyObject *args) Py_RETURN_NONE; } +// python function base = get_xio_base() +static PyObject *py_gpio_base(PyObject *self, PyObject *args) +{ + unsigned int value; + PyObject *py_value; + + value = get_xio_base(); + + py_value = Py_BuildValue("i", value); + + return py_value; +} + // Internal unit tests extern int num_get_xio_base; extern pins_t pins_info[]; @@ -668,6 +681,7 @@ PyMethodDef gpio_methods[] = { {"wait_for_edge", py_wait_for_edge, METH_VARARGS, "Wait for an edge.\ngpio - gpio channel\nedge - RISING, FALLING or BOTH"}, {"gpio_function", py_gpio_function, METH_VARARGS, "Return the current GPIO function (IN, OUT, ALT0)\ngpio - gpio channel"}, {"setwarnings", py_setwarnings, METH_VARARGS, "Enable or disable warning messages"}, + {"get_gpio_base", py_gpio_base, METH_VARARGS, "Get the XIO base number for sysfs"}, {"selftest", py_selftest, METH_VARARGS, "Internal unit tests"}, {NULL, NULL, 0, NULL} }; diff --git a/test/gptest.py b/test/gptest.py index 0b0cf99..886bbef 100755 --- a/test/gptest.py +++ b/test/gptest.py @@ -99,7 +99,9 @@ print "SETTING UP EDGE DETECTION ON XIO-P0" GPIO.add_event_detect("XIO-P0", GPIO.FALLING, myfuncallback) print "VERIFYING EDGE DETECT" -f = open("/sys/class/gpio/gpio408/edge", "r") +base = GPIO.get_gpio_base() +gfile = "/sys/class/gpio/gpio%d/edge" % base +f = open(gfile, "r") edge = f.read() f.close() print "EDGE: %s" % edge