diff options
author | Grissess <grissess@nexusg.org> | 2015-06-14 03:46:37 -0400 |
---|---|---|
committer | Grissess <grissess@nexusg.org> | 2015-06-14 03:46:37 -0400 |
commit | af3e084f8f27f478d372d2906a05d9b289833cb4 (patch) | |
tree | 3028645017b3b5ecd31db07c30c036e49aee79fd /broadcast.py | |
parent | 89fba87e33a0f6d958a67a2b71330f5d2b8762ce (diff) |
Added client.py
Diffstat (limited to 'broadcast.py')
-rw-r--r-- | broadcast.py | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/broadcast.py b/broadcast.py index 0483a67..f244aa6 100644 --- a/broadcast.py +++ b/broadcast.py @@ -5,6 +5,8 @@ import time import xml.etree.ElementTree as ET import threading +from packet import Packet, CMD + PORT = 13676 if len(sys.argv) > 2: factor = float(sys.argv[2]) @@ -13,22 +15,6 @@ else: print 'Factor:', factor -class Packet(object): - def __init__(self, cmd, *data): - self.cmd = cmd - self.data = data - if len(data) >= 8: - raise ValueError('Too many data') - self.data = list(self.data) + [0] * (8-len(self.data)) - def __str__(self): - return struct.pack('>L'+('L'*len(self.data)), self.cmd, *self.data) - -class CMD: - KA = 0 # No important data - PING = 1 # Data are echoed exactly - QUIT = 2 # No important data - PLAY = 3 # seconds, microseconds, frequency (Hz), amplitude (0-255) - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) |