Fix problem with start
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,4 +1,4 @@
|
|||||||
VERSION = 0.0.7
|
VERSION = 0.0.11
|
||||||
# Global target; when 'make' is run without arguments, this is what it should do
|
# Global target; when 'make' is run without arguments, this is what it should do
|
||||||
all: bell-mqtt-recv
|
all: bell-mqtt-recv
|
||||||
|
|
||||||
@@ -35,4 +35,4 @@ clean:
|
|||||||
rm bell-mqtt-recv -f *.o
|
rm bell-mqtt-recv -f *.o
|
||||||
|
|
||||||
pack:
|
pack:
|
||||||
tar cvzf ../bell-rspro-$(VERSION).tar.gz $(DEPS) $(SRC) Makefile bell-rspro.init
|
tar cvzf ../bell-rspro-$(VERSION).tar.gz $(DEPS) $(SRC) Makefile Makefile.openwrt bell-rspro.init
|
||||||
|
|||||||
12
gpiosysfs.c
12
gpiosysfs.c
@@ -32,19 +32,17 @@ static void writeToFile(const char *absoluteFileName, const char *contents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gpioSetup(const char *pin) {
|
void gpioSetup(const char *pin) {
|
||||||
// TODO only export if not already exported...
|
char buf[64];
|
||||||
if (access("/sys/class/gpio/unexport",W_OK) == 0)
|
|
||||||
writeToFile("/sys/class/gpio/unexport", pin);
|
|
||||||
writeToFile("/sys/class/gpio/export", pin);
|
|
||||||
|
|
||||||
char buf[33];
|
|
||||||
struct stat statBuf;
|
struct stat statBuf;
|
||||||
int pinExported = -1;
|
int pinExported = -1;
|
||||||
|
|
||||||
sprintf(buf, "/sys/class/gpio/gpio%s/direction", pin);
|
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!
|
// May have to briefly wait for OS to make symlink!
|
||||||
while (pinExported != 0) {
|
while (pinExported != 0) {
|
||||||
msleep(1000);
|
msleep(1000);
|
||||||
pinExported = stat(buf, &statBuf);
|
pinExported = stat(buf, &statBuf);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user