
goldenbot
Canada
Asked
— Edited

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.
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
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('127.0.0.1', 8080)
to
client.connect(('127.0.0.1', 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.
eg:
>>> import socket
>>> client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> client.connect(('127.0.0.1', 8080))
>>> client.settimeout(2)
>>> client.send('print("hello")')
14
>>> client.recv(2048)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.timeout: timed out
>>>
Here is what ARC shows:
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?
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.
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.
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.