Fix problem with start
This commit is contained in:
12
gpiosysfs.c
12
gpiosysfs.c
@@ -32,19 +32,17 @@ static void writeToFile(const char *absoluteFileName, const char *contents) {
|
||||
}
|
||||
|
||||
void gpioSetup(const char *pin) {
|
||||
// TODO only export if not already exported...
|
||||
if (access("/sys/class/gpio/unexport",W_OK) == 0)
|
||||
writeToFile("/sys/class/gpio/unexport", pin);
|
||||
writeToFile("/sys/class/gpio/export", pin);
|
||||
|
||||
char buf[33];
|
||||
char buf[64];
|
||||
struct stat statBuf;
|
||||
int pinExported = -1;
|
||||
|
||||
sprintf(buf, "/sys/class/gpio/gpio%s/direction", pin);
|
||||
|
||||
if (stat(buf, &statBuf) != 0)
|
||||
writeToFile("/sys/class/gpio/export", pin);
|
||||
|
||||
// May have to briefly wait for OS to make symlink!
|
||||
while (pinExported != 0) {
|
||||
while (pinExported != 0) {
|
||||
msleep(1000);
|
||||
pinExported = stat(buf, &statBuf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user