File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
external-control-backend/src Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -56,24 +56,28 @@ def send_command(self, command: str):
5656 try :
5757 # Create a socket connection with the robot IP and port number defined above
5858 s = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
59- s .settimeout (timeout )
59+ s .settimeout (0.1 )
6060 s .connect ((self .robotIP , self .port ))
6161 s .sendall (command .encode ('us-ascii' ))
6262 # Receive script code
6363 raw_data = b""
64+ begin = time .time ()
6465 while True :
6566 try :
66- data = s .recv (1024 )
67- if not data :
68- break
67+ data = s .recv (5 )
6968 raw_data += data
7069 except socket .timeout :
71- s .close ()
72- raise Exception (f"Connection timeout" )
70+ print ("No data received from the server" )
71+ if raw_data != b"" :
72+ print (raw_data )
73+ break
74+ elif time .time () - begin > timeout :
75+ s .close ()
76+ raise Exception (f"Connection timeout" )
7377 program = raw_data .decode ("us-ascii" )
7478 s .close ()
7579 if not bool (program and program .strip ()):
7680 raise Exception (f"Did not receive any script lines" )
7781 return program
7882 except Exception as e :
79- raise Exception (f"Connectivity problem to with { self .robotIP } :{ self .port } : { e } " )
83+ raise Exception (f"Connectivity problem with { self .robotIP } :{ self .port } : { e } " )
You can’t perform that action at this time.
0 commit comments