-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
38 lines (33 loc) · 1.16 KB
/
client.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
import socket
import sys
from time import sleep
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
servo_server = ('169.254.191.81', 3000)
peltier_server = ('169.254.191.81', 3001)
try:
message = '{"timestamp": 1404330711, "angle": 180}'
print>>sys.stderr, 'sending %s' % message
sock.sendto(message, servo_server)
sleep(5)
message = '{"timestamp": 1404330711, "angle": 5}'
print>>sys.stderr, 'sending %s' % message
sock.sendto(message, servo_server)
sleep(5)
message = '{"timestamp": 1404330711, "angle": 0}'
print>>sys.stderr, 'sending %s' % message
sock.sendto(message, servo_server)
sleep(5)
message = '{"timestamp": 1404330711, "temperature": 10}'
print>>sys.stderr, 'sending %s' % message
sock.sendto(message, peltier_server)
sleep(5)
message = '{"timestamp": 1404330711, "temperature": -10}'
print>>sys.stderr, 'sending %s' % message
sock.sendto(message, peltier_server)
sleep(5)
message = '{"timestamp": 1404330711, "temperature": 0}'
print>>sys.stderr, 'sending %s' % message
sock.sendto(message, peltier_server)
finally:
print >> sys.stderr, 'closing socket'
sock.close()