Home Programming


Left ArrowBack to discussions page
jensssjensss Posts: 23 Apprentice

I'm trying to start a client server with the cobot. So the cobot asks for data.
This works with socket test V3. But in python I get b'asking for data. so I can't build on it either.
How is this happening?

below is my simple robot program.

in sockettest v3 I get it right as shown below.

but in python I get b'asking for data'. you can see this below.

maybe not unimportantly my python code. You can see it here.


  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    edited May 2020
    @jensss I am not sure what is happening, I recreated your code but did it slightly different as I was getting some errors but I do not see the message received error that you are seeing.

    Here is my python code

    <div>import socket</div><div>import time</div><div>host = ""</div><div>port = 5001</div><br><div>print("Program Start")</div><div>tel = 0</div><br><div>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</div><div>s.bind((host, port))</div><div>s.listen(1)</div><div>c, addr = s.accept()</div><br><div>while (tel < 10):</div><div>  </div><div>  try:</div><div>    msg = c.recv(1024)</div><div>    print(msg)</div><div>    c.send("Messsage '"+msg+"' was received")</div><div>    if msg == "Stop":</div><div>      tel = 10</div><div>      print(tel)</div><div>  except socket.error as socketError:</div><div>    tel = 10</div><div>    print(socketError)</div><div>    print(tel)</div><br><div>c.close()</div><div>s.close()</div><div>print("Program Finished")</div>

    One thing I will note, in testing with SocketTest I never could enter the condition for "Stop", the string received never had equality to the string "Stop", not a python programmer so not sure what is up there.

    Here is my Polyscope program, you can see in the variables the result of where the server sent back a response string

    Also, I think you will run into an issue when you try to send your move command to the robot, that will stop the execution of the program that you are running.  The controller can only have one program controlling the main thread at one time.  By sending that single line program in it will halt the program running on the robot to run that single line.  Generally when we are doing something like this we are asking for position data, the server then sends the position data as a list and then the robot is responsible for putting it back together into a pose for use in a move command.

    I am currently running Python 2.7.16
Sign In or Register to comment.
Left ArrowBack to discussions page