-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path430MHz-Deamon.py
43 lines (37 loc) · 1.18 KB
/
430MHz-Deamon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import os
import time
import Adafruit_BBIO.GPIO as GPIO
#import serial
class Tranceiver:
repeat = 8 #later in config file
pulselength = 0.000030 # = 30 ms (verified with logic analyser) later in config file
transmitFIFO = '/tmp/transmitterfifo'
pin_out ="P8_12" #later in config file
def __init__(self):
if os.path.exists(self.transmitFIFO) :
os.unlink(self.transmitFIFO)
os.mkfifo(self.transmitFIFO)
os.chmod(self.transmitFIFO, 0666)
GPIO.cleanup()
GPIO.setup(self.pin_out, GPIO.OUT)
GPIO.output(self.pin_out,GPIO.LOW)
def transmitter(self):
while 1:
with open(self.transmitFIFO,'r') as fifo:
lines = fifo.read()
lines = lines.splitlines()
for line in lines:
if len(line):
for bit in line:
if bit == "1":
GPIO.output(self.pin_out, GPIO.HIGH)
else :
GPIO.output(self.pin_out, GPIO.LOW)
time.sleep(self.pulselength)
GPIO.output(self.pin_out, GPIO.LOW)
time.sleep(0.3)
# def receiver(self):
# ser = serial.Serial('/dev/ttyS1', 19200, timeout=1)
transmit = Tranceiver()
transmit.transmitter()