swixteen  0.03
Switch a lamp on/off with X10 RF commands
 All Files Functions Variables Macros Pages
OpenGpioPinFd.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <fcntl.h>
5 #include <unistd.h>
6 #include <stdlib.h>
7 
8 #include "../Sysfs/Sysfs.h"
9 
10 int OpenGpioPinFd( int Pin )
11  {
12  GpioExport(Pin);
13  SetGpioAsOutput(Pin);
14 
15  snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/value", Pin);
16  GpioPinFd = open( path, O_WRONLY | O_SYNC );
17  if (GpioPinFd == -1)
18  {
19  fprintf(stderr, "201309202358 Failed to open gpio pin %i for writing, are you root?\n", Pin);
20  exit(-1);
21  }
22 
23  return(GpioPinFd);
24  }
25 
26