Skip to content

Commit 874fcaf

Browse files
committed
Initial commit
0 parents  commit 874fcaf

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

libcbus.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python
2+
import struct
3+
from serial import Serial
4+
5+
# command types
6+
POINT_TO_MULTIPOINT = '\\05'
7+
8+
# Applications
9+
APP_LIGHTING = '38'
10+
11+
# Routing buffer
12+
ROUTING_NONE = '00'
13+
14+
15+
def duration_to_ramp_rate(seconds):
16+
if seconds == 0:
17+
return '02'
18+
elif seconds <= 4:
19+
return '0A'
20+
elif seconds <= 8:
21+
return '12'
22+
elif seconds <= 12:
23+
return '1A'
24+
elif seconds <= 20:
25+
return '22'
26+
elif seconds <= 30:
27+
return '2A'
28+
elif seconds <= 40:
29+
return '32'
30+
elif seconds <= 60:
31+
return '3A'
32+
elif seconds <= 90:
33+
return '42'
34+
elif seconds <= 120:
35+
return '4A'
36+
elif seconds
37+
38+
39+
class CBusPCISerial(object):
40+
def __init__(self, device):
41+
self.s = Serial(device, 9600)
42+
self.reset()
43+
44+
def reset(self):
45+
# reset the PCI
46+
self.s.write('~')
47+
48+
49+

0 commit comments

Comments
 (0)