swixteen  0.03
Switch a lamp on/off with X10 RF commands
 All Files Functions Variables Macros Pages
SendBit.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "../config.h"
3 
4 #include "../Common/Common.h"
5 #include "../Sysfs/Sysfs.h"
6 #include "../MarmitekX10/MarmitekX10.h"
7 
13 int SendBit( int Bit )
14  {
15  int rc=0;
16 
17  if(Bit) /* Bit is not zero, but a positive integer */
18  {
19  /* Set sender on */
21 
22  /*
23  * One is high for 0.5625 mS and low for 1.6875 mS
24  */
25  Timing.tv_sec = 0;
26  Timing.tv_nsec = 562500;
27  if( nanosleep( &Timing, &Remaining) != 0 )
28  {
29  fprintf( stderr, "201309131344 Timing failed\n" );
30  rc=-1;
31  }
32 
33  /* Set sender off */
35 
36  Timing.tv_sec = 0;
37  Timing.tv_nsec = 1687500;
38  if( nanosleep( &Timing, &Remaining) != 0 )
39  {
40  fprintf( stderr, "201309131345 Timing failed\n" );
41  rc=-1;
42  }
43  }
44  else /* Bit is 0 */
45  {
46 
47  /* Set sender on */
49 
50  /*
51  * Zero is high for 0.5625 mS and low for 0.5625 mS
52  */
53  Timing.tv_sec = 0;
54  Timing.tv_nsec = 562500;
55  if( nanosleep( &Timing, &Remaining) != 0 )
56  {
57  fprintf( stderr, "201309131346 Timing failed\n" );
58  rc=-1;
59  }
60 
61  /* Set sender off */
63 
64  Timing.tv_sec = 0;
65  Timing.tv_nsec = 562500;
66  if( nanosleep( &Timing, &Remaining) != 0 )
67  {
68  fprintf( stderr, "201309131347 Timing failed\n" );
69  rc=-1;
70  }
71  }
72  return(rc);
73  }