From 84df4376f83bb4de2b4e2f77447cb75704ebdaf4 Mon Sep 17 00:00:00 2001 From: Robert Wolterman Date: Sun, 12 Nov 2017 08:06:35 -0600 Subject: [PATCH] added logging to inform user of 1s retry if set_direction fails on the first try, updating to v0.7.1 --- CHANGELOG.rst | 6 ++++++ debian/changelog | 29 ++++++++++++++++++----------- debian/files | 4 ++-- setup.py | 2 +- source/constants.c | 2 +- source/event_gpio.c | 5 +++++ 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 94ded19..4b5844f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,9 @@ +0.7.1 +--- +* Merged in PR #79 +* Merged in PR #80 +* Added message notifying user of the gpio set direction retry + 0.7.0 --- * Added ability to specify GPIO only as a number, this doesn't work for PWM/SPWM/LRADC/SERVO diff --git a/debian/changelog b/debian/changelog index 2e9a5f1..bf81da6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,36 +1,43 @@ +chip-io (0.7.1-1) unstable; urgency=low + + * Merged PR#79 and#80 + * Added logging to tell user of the 1 second sleep before retry on setting gpio direction + + -- Robert Wolterman Sun, 12 Nov 2017 07:40:00 -0600 + chip-io (0.7.0-1) unstable; urgency=low - * Added ability to specify GPIO only as a number, this doesn't work for PWM/SPWM/LRADC/SERVO + * Added ability to specify GPIO only as a number, this doesn't work for PWM/SPWM/LRADC/SERVO -- Robert Wolterman Wed, 13 Sep 2017 09:51:00 -0600 chip-io (0.6.2-1) unstable; urgency=low - * Implementation for number 77 ability to push up binary pypi - * Implementation for number 75 wait for edge timeout + * Implementation for number 77 ability to push up binary pypi + * Implementation for number 75 wait for edge timeout -- Robert Wolterman Sun, 03 Sep 2017 21:34:00 -0600 chip-io (0.6.1-1) unstable; urgency=low - * Fixing implementation for #76 + * Fixing implementation for #76 -- Robert Wolterman Wed, 09 Aug 2017 23:09:00 -0600 chip-io (0.6.0-1) unstable; urgency=low - * Random comment cleanup - * Implement fix for #76 - * API documentation added - * Closing #74 + * Random comment cleanup + * Implement fix for #76 + * API documentation added + * Closing #74 -- Robert Wolterman Wed, 09 Aug 2017 22:50:00 -0600 chip-io (0.5.9-1) unstable; urgency=low - * Merged PR#70 to enable the underlying C code to be used properly in C based code - * Updated README to add missing pins on the CHIP Pro that are available as GPIO - * Updated README to denote pins that are available for Edge Detection + * Merged PR#70 to enable the underlying C code to be used properly in C based code + * Updated README to add missing pins on the CHIP Pro that are available as GPIO + * Updated README to denote pins that are available for Edge Detection -- Robert Wolterman Tue, 08 Jun 2017 20:03:00 -0600 diff --git a/debian/files b/debian/files index 432ccd0..736e56b 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,2 @@ -python-chip-io_0.7.0-1_armhf.deb python optional -python3-chip-io_0.7.0-1_armhf.deb python optional +python-chip-io_0.7.1-1_armhf.deb python optional +python3-chip-io_0.7.1-1_armhf.deb python optional diff --git a/setup.py b/setup.py index fbe1ebc..d12ce01 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'Topic :: System :: Hardware'] setup(name = 'CHIP_IO', - version = '0.7.0', + version = '0.7.1', 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 7b8cdc6..3810f7e 100644 --- a/source/constants.c +++ b/source/constants.c @@ -85,6 +85,6 @@ void define_constants(PyObject *module) bcm = Py_BuildValue("i", BCM); PyModule_AddObject(module, "BCM", bcm); - version = Py_BuildValue("s", "0.7"); + version = Py_BuildValue("s", "0.7.1"); PyModule_AddObject(module, "VERSION", version); } diff --git a/source/event_gpio.c b/source/event_gpio.c index 8a792b3..9955719 100644 --- a/source/event_gpio.c +++ b/source/event_gpio.c @@ -385,10 +385,15 @@ int gpio_set_direction(int gpio, unsigned int in_flag) snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/direction", gpio); BUF2SMALL(filename); if ((fd = open(filename, O_WRONLY)) < 0) { + // NOTIFY THAT WE'RE GOING TO SLEEP AND RETRY + char err[256]; + snprintf(err, sizeof(err), "gpio_set_direction: could not open '%s', sleeping for 1 second and retrying", filename); + add_error_msg(err); // if called as non-root, udev may need time to adjust file // permissions after setting up gpio sleep(1); + // TRY AGAIN AND IF THIS TIME FAILS, KICK OUT if ((fd = open(filename, O_WRONLY)) < 0) { char err[256]; snprintf(err, sizeof(err), "gpio_set_direction: could not open '%s' (%s)", filename, strerror(errno));