1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

added logging to inform user of 1s retry if set_direction fails on the first try, updating to v0.7.1

This commit is contained in:
Robert Wolterman
2017-11-12 08:06:35 -06:00
parent 906beb0257
commit 84df4376f8
6 changed files with 33 additions and 15 deletions

View File

@ -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 0.7.0
--- ---
* 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

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
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 <robert.wolterman@gmail.com> Sun, 12 Nov 2017 07:40:00 -0600
chip-io (0.7.0-1) unstable; urgency=low 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

4
debian/files vendored
View File

@ -1,2 +1,2 @@
python-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.0-1_armhf.deb python optional python3-chip-io_0.7.1-1_armhf.deb python optional

View File

@ -13,7 +13,7 @@ classifiers = ['Development Status :: 3 - Alpha',
'Topic :: System :: Hardware'] 'Topic :: System :: Hardware']
setup(name = 'CHIP_IO', setup(name = 'CHIP_IO',
version = '0.7.0', version = '0.7.1',
author = 'Robert Wolterman', author = 'Robert Wolterman',
author_email = 'robert.wolterman@gmail.com', author_email = 'robert.wolterman@gmail.com',
description = 'A module to control CHIP IO channels', description = 'A module to control CHIP IO channels',

View File

@ -85,6 +85,6 @@ void define_constants(PyObject *module)
bcm = Py_BuildValue("i", BCM); bcm = Py_BuildValue("i", BCM);
PyModule_AddObject(module, "BCM", bcm); PyModule_AddObject(module, "BCM", bcm);
version = Py_BuildValue("s", "0.7"); version = Py_BuildValue("s", "0.7.1");
PyModule_AddObject(module, "VERSION", version); PyModule_AddObject(module, "VERSION", version);
} }

View File

@ -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); snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/direction", gpio); BUF2SMALL(filename);
if ((fd = open(filename, O_WRONLY)) < 0) { 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 // if called as non-root, udev may need time to adjust file
// permissions after setting up gpio // permissions after setting up gpio
sleep(1); sleep(1);
// TRY AGAIN AND IF THIS TIME FAILS, KICK OUT
if ((fd = open(filename, O_WRONLY)) < 0) { if ((fd = open(filename, O_WRONLY)) < 0) {
char err[256]; char err[256];
snprintf(err, sizeof(err), "gpio_set_direction: could not open '%s' (%s)", filename, strerror(errno)); snprintf(err, sizeof(err), "gpio_set_direction: could not open '%s' (%s)", filename, strerror(errno));