Feb-01-2018, 09:53 AM
Hello experts,
I'm new to the world of programming and I've already made a socket connection to C # on a Raspberry Pi (Python).
The software controls a servomotor. After a while, under the surface of the connection and the Raspberry Pi did not send commands to the servomotor because I believe the socket connection was broken.
Does anyone know a solution to my code?
I'm new to the world of programming and I've already made a socket connection to C # on a Raspberry Pi (Python).
The software controls a servomotor. After a while, under the surface of the connection and the Raspberry Pi did not send commands to the servomotor because I believe the socket connection was broken.
Does anyone know a solution to my code?
import socket
from Handler import Handler
import time
from Servo import Servo
def Server(serverSocket, port):
handler = Handler(12, 50)
serverSocket.listen(1)
i=0
connect = 1
try:
while i == 0:
clientSocket, addr = serverSocket.accept()
i = 1
while connect == 1:
data = clientSocket.recv(1024)
request = handler.handleRequest(data)
if not data:
break
if request == "SSDN K0":
connect = 0
except Exception as ex:
print(ex)
Server(serverSocket, port)
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
port=1234
serverSocket.bind(('192.168.0.8',port))
Server(serverSocket, port)
