Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by DJ Sures!

Http Server Control Print Just Returns Ok And Not The Printed String In The Scri

In the Http Server control, when in the scripting console if I type print("hello") the Result window just shows OK. I was expecting it to show "hello". Is this a bug or am I missing something?
I am using python to control my robot. I can access the camera and set variables or call functions. However when I try to obtain a variable value using print it just returns "OK" and not the value.

User-inserted image


Upgrade to ARC Pro

Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!

AI Support Bot
Related Content
The TCP Server can be a bit strange that way - it has been historically used for receiving commands, although it _should_ be able to return data. Not sure why it isn't, but i'll have it looked into.

In the meantime, i created a plugin that is a more efficient approach to what you're doing. This plugin listens on a TCP socket, and receives EZ-Script commands terminated by new lines. The response is returned which is also terminated by new line.

Get the plugin here: https://synthiam.com/redirect/legacy?table=plugin&id=263
Hi JD, thanks for the quick reply. I worked around my original http server control issue by using Script Manager eg: ControlCommand("Script Manager", ScriptStart, "PrintVariable") to call a script which would then write the output to a text file. In python I did a quick sleep and then read the text file.

I tried the TCP server but have not got it to work yet. To get the connect to work I had to change
client.connect('', 8080)
client.connect(('', 8080))

However when I send data I don't get an error. Just a number back of the number of bytes sent.

When I do a recv it just hangs or times out if I set a timeout parameter.

>>> import socket
>>> client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> client.connect(('', 8080))
>>> client.settimeout(2)
>>> client.send('print("hello")')
>>> client.recv(2048)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.timeout: timed out

Here is what ARC shows:

User-inserted image

Is there a way to debug further to get more info on what is happening?

Assuming I figure it out is there a way to capture the camera using the TCP server similar to how you can capture the camera from the HTTP server control?
if you have debug checkbox checked and don’t see any debug info, then absolutely nothing is happening

I’m guessing it’s because my example doesn’t terminate the string with a new line as I’ve written in the write up.
I updated the python example with terminated new lines for the commands.

Simply sending a command with send() doesn’t let the compiler know when the end of the line has been reached. A new line is necessary which is a \r\n

Camera jpg can be read using the standard http control.
Hi JD. The newline \r\n fixed the issue. Thanks for your help and also taking the time to update your plugin example code, so others can just cut and paste to have it work.
You might want to put client.close() at the end of your example with a comment to let folks know to close the socket when their python script is finished.
Marking the issue resolved. Thanks to DJ Sures for helping out and improving the site documentation. Enjoying being able to control JD from a python program.
Great to hear! Thanks for the kind words:)