Merge branch 'develop' into GPIOAPI
This commit is contained in:
60
gpio/gpio.c
60
gpio/gpio.c
@@ -281,13 +281,33 @@ static void doLoad (int argc, char *argv [])
|
||||
if (!moduleLoaded (module1))
|
||||
{
|
||||
sprintf (cmd, "%s %s%s", findExecutable (MODPROBE), module1, args1) ;
|
||||
system (cmd) ;
|
||||
int ret = system(cmd);
|
||||
if (ret == -1) {
|
||||
perror("Error executing command");
|
||||
} else if (WIFEXITED(ret)) {
|
||||
int exit_status = WEXITSTATUS(ret);
|
||||
if (exit_status != 0) {
|
||||
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Command terminated by signal\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!moduleLoaded (module2))
|
||||
{
|
||||
sprintf (cmd, "%s %s%s", findExecutable (MODPROBE), module2, args2) ;
|
||||
system (cmd) ;
|
||||
int ret = system(cmd);
|
||||
if (ret == -1) {
|
||||
perror("Error executing command");
|
||||
} else if (WIFEXITED(ret)) {
|
||||
int exit_status = WEXITSTATUS(ret);
|
||||
if (exit_status != 0) {
|
||||
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Command terminated by signal\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!moduleLoaded (module2))
|
||||
@@ -341,13 +361,33 @@ static void doUnLoad (int argc, char *argv [])
|
||||
if (moduleLoaded (module1))
|
||||
{
|
||||
sprintf (cmd, "%s %s", findExecutable (RMMOD), module1) ;
|
||||
system (cmd) ;
|
||||
int ret = system(cmd);
|
||||
if (ret == -1) {
|
||||
perror("Error executing command");
|
||||
} else if (WIFEXITED(ret)) {
|
||||
int exit_status = WEXITSTATUS(ret);
|
||||
if (exit_status != 0) {
|
||||
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Command terminated by signal\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleLoaded (module2))
|
||||
{
|
||||
sprintf (cmd, "%s %s", findExecutable (RMMOD), module2) ;
|
||||
system (cmd) ;
|
||||
int ret = system(cmd);
|
||||
if (ret == -1) {
|
||||
perror("Error executing command");
|
||||
} else if (WIFEXITED(ret)) {
|
||||
int exit_status = WEXITSTATUS(ret);
|
||||
if (exit_status != 0) {
|
||||
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Command terminated by signal\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,15 +456,14 @@ static volatile int globalCounter ;
|
||||
|
||||
void printgpioflush(const char* text) {
|
||||
if (gpioDebug) {
|
||||
printf(text);
|
||||
printf("%s", text);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
void printgpio(const char* text) {
|
||||
if (gpioDebug) {
|
||||
printf(text);
|
||||
fflush(stdout);
|
||||
printf("%s", text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +513,7 @@ void doWfi (int argc, char *argv [])
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
printgpio("wait for interrupt function call \n");
|
||||
printgpio("wait for interrupt function call\n");
|
||||
for (int Sec=0; Sec<timeoutSec; ++Sec) {
|
||||
printgpioflush(".");
|
||||
delay (999);
|
||||
@@ -1112,7 +1151,10 @@ static void doVersion (char *argv [])
|
||||
{
|
||||
if ((fd = fopen ("/proc/device-tree/model", "r")) != NULL)
|
||||
{
|
||||
fgets (name, 80, fd) ;
|
||||
if (fgets(name, sizeof(name), fd) == NULL) {
|
||||
// Handle error or end of file condition
|
||||
perror("Error reading /proc/device-tree/model");
|
||||
}
|
||||
fclose (fd) ;
|
||||
printf (" Model: %s\n", name) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user