diff --git a/V1/switch.c b/V1/switch.c index ed448c8..ceab9d4 100644 --- a/V1/switch.c +++ b/V1/switch.c @@ -7,24 +7,27 @@ * * */ -#define PIN01 1 -#define PIN12 12 -#define PIN11 11 -#define PIN06 6 -#define IN ((const unsigned char *)"in\n") -#define OUT ((const unsigned char *)"out\n") +#define PIN01 ((char *) "1\n") +#define PIN12 ((char *) "12\n") +#define PIN11 ((char *) "11\n") +#define PIN06 ((char *) "6\n") +#define IN ((char *)"in\n") +#define OUT ((char *)"out\n") #include +#include +#include #include +#include -int reserve(char gpioPort) +int reserve(char* gpioPort) { int fd; char buffer[2]; + printf("%s", gpioPort); + strcpy(buffer, gpioPort ); - strcpy(buffer, gpioPort + "\n"); - - if((fd=open("/sys/class/gpio/export", O_RDWR | O_CREAT | O_TRUNC) == -1) { + if((fd=open("/sys/class/gpio/export", O_RDWR | O_CREAT | O_TRUNC) == -1)) { perror(NULL); return EXIT_FAILURE; } @@ -45,6 +48,6 @@ int inOut(char gpioPort, char * inOut) int main() { - + reserve(PIN06); return 0; }