TCP server that listens for script commands.
How to add the TCP Script Server Raw robot skill
- Load the most recent release of ARC (Get ARC).
- Press the Project tab from the top menu bar in ARC.
- Press Add Robot Skill from the button ribbon bar in ARC.
- Choose the Communication category tab.
- Press the TCP Script Server Raw icon to add the robot skill to your project.
Don't have a robot yet?
Follow the Getting Started Guide to build a robot and use the TCP Script Server Raw robot skill.
How to use the TCP Script Server Raw robot skill
This TCP server will bind to a port and listen for incoming EZ-Script, JavaScript or Python commands. This is a useful plugin for connecting third part controllers and products to ARC. You may send any command of the specified language, terminated by a new line (\r\n). The response is received which is also terminated by a new line (\r\n).
Control Command
There are also ControlCommand() for starting, stopping and controlling debug settings. This is useful if you wish to control this plugin from another script in the project, or when a connection is established to the EZ-B.
Configure Language
The configuration screen of this robot skill allows specifying the language that will be used for incoming connections. You can choose between Python, JavaScript and EZ-Script.

Be Socket Friendly
Although you can establish a new connection for each request, it is recommended that you maintain one connection and reuse it throughout your program. This will use the nature of the TCP (transmission controlled protocol). Every time a TCP connection is established, a bunch of back and forth occurs, which takes time and resources. If you reuse the connection, your program will run much faster. If your program is using multi-threads and therefore executes commands asynchronously, we recommend using a TCP connection per thread.
New Line Terminated Response
Every command that you send will return a new line terminated response, even if it is an empty response. Empty new line terminated responses would be for commands that do not return anything, such as SetServo(). This means it is important for your program to read the response of every command to ensure it is always caught up with the input stream.
Python
To send and receive from a python program...
Code:
import socket
# create an ipv4 (AF_INET) socket object using the tcp protocol (SOCK_STREAM)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connect the client, in this case localhost
client.connect(('127.0.0.1', 8080))
# -------------------------------------------------------------------------------------------
# send some EZ-Script (in this case do some simple math)
client.send('print(23+65)\r\n')
# receive the response data
response = client.recv(2048)
print response
# -------------------------------------------------------------------------------------------
# send some more EZ-Script (in this case print a string)
client.send('print("Hello World!")\r\n')
# receive the response data
response = client.recv(2048)
print response
# -------------------------------------------------------------------------------------------
# send some more EZ-Script (in this case move a servo)
client.send('Servo(d0, 90)\r\n')
# receive the response data
response = client.recv(2048)
print response
# -------------------------------------------------------------------------------------------
# send some more EZ-Script (in this case get servo position)
client.send('GetServo(d0)\r\n')
# receive the response data
response = client.recv(2048)
print response
# -------------------------------------------------------------------------------------------
# close the tcp connection
client.close()
JavaScript python or ezscript