Skip to content

GPIO access as user even with rigth permissions to /sys doesn't work #36

@olegantonyan

Description

@olegantonyan

Hi
My problem is described here http://stackoverflow.com/questions/18926979/beaglebone-black-adafruit-io-python-library-gpio-user-permissions

In short: GPIO works only with root even when all permissions to /sys are OK for user and I can control gpio from user's shell, but not with python.
By experimenting I found that it works if you add delay in event_gpio.c in gpio_export function after closing file:

len = snprintf(str_gpio, sizeof(str_gpio), "%d", gpio);
write(fd, str_gpio, len);
close(fd);
volatile int i = 0; // very cruel delay
for (i = 0; i < 100000000; i++);

// add to list
new_gpio = malloc(sizeof(struct gpio_exp));

fsync(fd) and fdatasync(fd) before closing don't help. It seems like some kind of race condition which shows up only for regular user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions