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.
item-sort/pi_client.py

27 lines
817 B
Python

import socket
import sort
import control_motor
import control_pixel
host = "192.168.1.248" # 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:
control_pixel.ledOn()
try:
data = s.recv(1024)
#control_pixel.ledOn()
if not data: break
print("[ INFO ] Item name: "+ str(data)[2:len(str(data))-1])
selectedBin = sort.sort(str(data)[2:len(str(data))-1])
control_pixel.ledOff()
control_motor.goToBin(selectedBin)
control_pixel.ledOn()
s.sendall(b'Continue')
except socket.error:
print("[ EXIT ] Socket connection error.")
break
s.close()