swixteen
0.03
Switch a lamp on/off with X10 RF commands
Main Page
Files
File List
Globals
All
Files
Functions
Variables
Macros
Pages
OldElro
SendOldElroBit.c
Go to the documentation of this file.
1
#include <stdio.h>
2
3
#include "../config.h"
4
#include "../Common/Common.h"
5
#include "../Sysfs/Sysfs.h"
6
#include "../OldElro/OldElro.h"
7
46
int
SendOldElroBit
(
int
Bit )
47
{
48
int
rc=0;
49
50
/* Set sender on */
51
SwitchSender
(
ON
);
52
53
Timing
.tv_sec = 0;
54
Timing
.tv_nsec =
TimeSlot
*1;
55
if
( nanosleep( &
Timing
, &
Remaining
) != 0 )
56
{
57
fprintf( stderr,
"201310021344 Timing failed\n"
);
58
rc=-1;
59
}
60
61
/* Set sender off */
62
SwitchSender
(
OFF
);
63
64
Timing
.tv_sec = 0;
65
Timing
.tv_nsec =
TimeSlot
*3;
66
if
( nanosleep( &
Timing
, &
Remaining
) != 0 )
67
{
68
fprintf( stderr,
"201310021345 Timing failed\n"
);
69
rc=-1;
70
}
71
72
if
(Bit)
/* bit is a positive integer */
73
{
74
/* Set sender on */
75
SwitchSender
(
ON
);
76
77
Timing
.tv_sec = 0;
78
Timing
.tv_nsec =
TimeSlot
*3;
79
if
( nanosleep( &
Timing
, &
Remaining
) != 0 )
80
{
81
fprintf( stderr,
"201310021344 Timing failed\n"
);
82
rc=-1;
83
}
84
85
/* Set sender off */
86
SwitchSender
(
OFF
);
87
88
Timing
.tv_sec = 0;
89
Timing
.tv_nsec =
TimeSlot
*1;
90
if
( nanosleep( &
Timing
, &
Remaining
) != 0 )
91
{
92
fprintf( stderr,
"201310021345 Timing failed\n"
);
93
rc=-1;
94
}
95
}
96
else
/* Bit is 0 */
97
{
98
99
/* Set sender on */
100
SwitchSender
(
ON
);
101
102
Timing
.tv_sec = 0;
103
Timing
.tv_nsec =
TimeSlot
*1;
104
if
( nanosleep( &
Timing
, &
Remaining
) != 0 )
105
{
106
fprintf( stderr,
"201310021346 Timing failed\n"
);
107
rc=-1;
108
}
109
110
/* Set sender off */
111
SwitchSender
(
OFF
);
112
113
Timing
.tv_sec = 0;
114
Timing
.tv_nsec =
TimeSlot
*3;
115
if
( nanosleep( &
Timing
, &
Remaining
) != 0 )
116
{
117
fprintf( stderr,
"201310021347 Timing failed\n"
);
118
rc=-1;
119
}
120
}
121
return
(rc);
122
}
Generated on Sat Oct 5 2013 21:30:15 for swixteen by
1.8.3.1