From dfdc98d38358c1d375c99a27f5b22d86984979e3 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 2 Oct 2012 20:55:25 +0200 Subject: osc2light: Adjust for new protocol --- osc2light.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/osc2light.py b/osc2light.py index 0746202..4a6d20e 100644 --- a/osc2light.py +++ b/osc2light.py @@ -1,5 +1,9 @@ #!/usr/bin/env python +# This is a very crude script which receives osc commands and passes those +# on to the ethernet/can gateway so it controls the light + +import hashlib import liblo import socket import struct @@ -36,7 +40,7 @@ class LightServer(object): self.handle_dali_lamp(path[len(prefix):], args, types, src) else: raise self.Unknown() - + def handle_dali_lamp(self, path, args, types, src): path_parts = path.split('/') while len(path_parts) and not path_parts[0]: @@ -70,17 +74,32 @@ class LightServer(object): if brightness >= 255: brightness = 254 + buf = chr(brightness) + addr = 0xcc080440 + lamp + + buf = struct.pack('>IB', addr, len(buf)) + buf + '\x00' * (3 + 8 - len(buf)) + src = '\x00\x04\x23\xb6\xde\xe4' dst = '\xff\x3a\xf6CAN' proto = 0x88b7 oui = '\x00\x80\x41' subp = 0xaaaa - typ = 2 - buf = struct.pack('>6s6sH3sHB', dst, src, proto, oui, subp, typ) + typ = 3 - addr = 0xcc080440 + lamp - buf += struct.pack('>IBB', addr, 1, brightness) + buf = struct.pack('6s6sH3sH', dst, src, proto, oui, subp) + buf self.raw_socket.sendto(buf, (self.interface, 0)) if __name__ == '__main__': -- cgit v1.2.1