|
|
|
|
@ -45,9 +45,20 @@ int main(int argc, char *argv[]){
|
|
|
|
|
val = argv[3];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// performing the read/write operation
|
|
|
|
|
gpio_export(pin);
|
|
|
|
|
gpio_direction(pin, dir);
|
|
|
|
|
|
|
|
|
|
//gpio_write(pin, val);
|
|
|
|
|
if (strcmp(dir,"out") == 0) {
|
|
|
|
|
gpio_write(pin, val);
|
|
|
|
|
} else if (strcmp(dir, "in") == 0) {
|
|
|
|
|
gpio_read(pin);
|
|
|
|
|
} else {
|
|
|
|
|
perror("invalid direction argument\n");
|
|
|
|
|
return -12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gpio_unexport(pin);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -68,7 +79,6 @@ int gpio_export(const char *gpio){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// gpio direction
|
|
|
|
|
|
|
|
|
|
int gpio_direction(const char *gpio, const char *direction){
|
|
|
|
|
// pin direction - convert into functions
|
|
|
|
|
int fd;
|
|
|
|
|
@ -108,10 +118,10 @@ int gpio_write(const char *gpio, const char *value){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// gpio read
|
|
|
|
|
int gpio_read(const char *gpio); //read function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int gpio_read(const char *gpio){
|
|
|
|
|
printf(" Test read function for gpio %s\n", gpio);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unexport
|
|
|
|
|
int gpio_unexport(const char *gpio){
|
|
|
|
|
|