swixteen
0.03
Switch a lamp on/off with X10 RF commands
Main Page
Files
File List
Globals
All
Files
Functions
Variables
Macros
Pages
Sysfs
SetGpioAsOutput.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <unistd.h>
3
#include <sys/types.h>
4
#include <sys/stat.h>
5
#include <fcntl.h>
6
7
#include "../Sysfs/Sysfs.h"
8
#include "../config.h"
9
15
int
SetGpioAsOutput
(
int
Pin)
16
{
17
int
fd;
18
19
snprintf(
path
,
DIRECTION_MAX
,
"/sys/class/gpio/gpio%d/direction"
, Pin);
20
fd = open(
path
, O_WRONLY);
21
if
(fd == -1 )
22
{
23
fprintf(stderr,
"201309231650 Failed to open gpio direction for writing, are you root?\n"
);
24
return
(-1);
25
}
26
27
if
( write(fd,
"out"
, 3) == -1 )
28
{
29
fprintf(stderr,
"201309210050 Failed to set direction, are you root?\n"
);
30
return
(-1);
31
}
32
33
close(fd);
34
return
(0);
35
}
36
Generated on Sat Oct 5 2013 21:30:15 for swixteen by
1.8.3.1