You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
658 B
Python
25 lines
658 B
Python
5 years ago
|
import socket
|
||
|
import sort
|
||
|
import control_motor
|
||
|
import control_pixel
|
||
|
|
||
|
host = socket.gethostname()
|
||
|
port = 9001 # The same port as used by the server
|
||
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||
|
s.connect((host, port))
|
||
|
s.sendall(b'Connected to server!')
|
||
|
control_pixel.ledOn()
|
||
|
while True:
|
||
|
try:
|
||
|
data = s.recv(1024)
|
||
|
if not data: break
|
||
|
print("Found "+data)
|
||
|
selectedBin = sort.sort(data)
|
||
|
control_pixel.ledOff()
|
||
|
control_motor.goToBin(selectedBin)
|
||
|
control_pixel.ledOn()
|
||
|
s.sendall(b'Continue')
|
||
|
except socket.error:
|
||
|
print("Error Occured.")
|
||
|
break
|
||
|
s.close()
|