Argh! I must confess that shot myself in the foot.

Starting with a clean reboot, GPIO devices are all existent as they should 
be:

debian@beaglebone:~/stepper/beaglebone$ ls /sys/class/gpio/
export   gpio112  gpio117  gpio19  gpio26  gpio32  gpio37  gpio45  gpio5  
 gpio62  gpio68  gpio72  gpio77  gpio81  gpio9       unexport
gpio10   gpio113  gpio12   gpio2   gpio27  gpio33  gpio38  gpio46  gpio50  
gpio63  gpio69  gpio73  gpio78  gpio86  gpiochip0
gpio11   gpio114  gpio13   gpio20  gpio3   gpio34  gpio39  gpio47  gpio51  
gpio65  gpio7   gpio74  gpio79  gpio87  gpiochip32
gpio110  gpio115  gpio14   gpio22  gpio30  gpio35  gpio4   gpio48  gpio60  
gpio66  gpio70  gpio75  gpio8   gpio88  gpiochip64
gpio111  gpio116  gpio15   gpio23  gpio31  gpio36  gpio44  gpio49  gpio61  
gpio67  gpio71  gpio76  gpio80  gpio89  gpiochip96

Then I ran this snippet of code:

#define SYSFS_GPIO_DIR "/sys/class/gpio"
#define MAX_BUF 64

int gpio_export(unsigned int gpio)
{
        int fd, len;
        char buf[MAX_BUF];

        fd = open(SYSFS_GPIO_DIR "/export", O_WRONLY);
        if (fd < 0) {
                perror("gpio/export");
                return fd;
        }

        len = snprintf(buf, sizeof(buf), "%d", gpio);
        write(fd, buf, len);
        close(fd);

        return 0;
}

int main(int argc, char *argv[]){

        gpio_export(26);

        return 0;
}

and *poof* gpio26 disappears:

debian@beaglebone:~/stepper/beaglebone$ ls /sys/class/gpio/
export   gpio112  gpio117  gpio19  gpio27  gpio33  gpio38  gpio46  gpio50  
gpio63  gpio69  gpio73  gpio78  gpio86  gpiochip0
gpio10   gpio113  gpio12   gpio2   gpio3   gpio34  gpio39  gpio47  gpio51  
gpio65  gpio7   gpio74  gpio79  gpio87  gpiochip32
gpio11   gpio114  gpio13   gpio20  gpio30  gpio35  gpio4   gpio48  gpio60  
gpio66  gpio70  gpio75  gpio8   gpio88  gpiochip64
gpio110  gpio115  gpio14   gpio22  gpio31  gpio36  gpio44  gpio49  gpio61  
gpio67  gpio71  gpio76  gpio80  gpio89  gpiochip96
gpio111  gpio116  gpio15   gpio23  gpio32  gpio37  gpio45  gpio5   gpio62  
gpio68  gpio72  gpio77  gpio81  gpio9   unexport

Sorry for the distraction.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/1f0054f2-e3f7-4323-8c92-ee7cc633fd89%40googlegroups.com.

Reply via email to