# UR skips socket send command

**URL:** <https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330>\
**Category:** Java\
**Created:** [November 14, 2017, 3:38pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330 "2017-11-14T15:38:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon62140534](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@anon62140534](https://forum.universal-robots.com/u/anon62140534)\
**Post date:** [November 14, 2017, 3:38pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/1 "2017-11-14T15:38:43Z")

</div>

I am working on a URCap that will control a outside device that is running on it’s own pc. At this point, I am verifying that the java code on the outside device will work but I am running into a bit of an issue that I do not know the answer to.

I have established a socket in the before start routine. The socket is var\_1. Also, I included a loop if var\_1 is false in the main program. The socket almost always establishes in the before start routine unless I have left the java program in the external pc running. If I have, then the main program takes over and goes into the loop since var\_1 is false.

The UR program( real robot not simulator) goes to waypoint 1 with a two second wait following arrival at waypoint 1, the next node is the socket false loop and the third node is a script command: "socket\_send\_string(“Center”).

Before I run the UR program, I start the pc which has a server socket program that listens on a specific port and this works well.

During execution of the UR program, the program jumps over the socket\_send\_string command and moves to the next UR program node.

When I stop UR execution, then the pc java program shows the input for the number of cycles run.

I would appreciate any thoughts you might have and I can supply much more detail if necessary.  
Jerry

---

<div class="post-metadata">

**Author:** ![anon62140534](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@anon62140534](https://forum.universal-robots.com/u/anon62140534)\
**Post date:** [November 15, 2017, 9:39pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/2 "2017-11-15T21:39:00Z")

</div>

I got it figured out… a bit of syntax goes a long way…

---

<div class="post-metadata">

**Author:** ![anon63859582](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon63859582](https://forum.universal-robots.com/u/anon63859582)\
**Post date:** [March 16, 2018, 1:09pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/3 "2018-03-16T13:09:47Z")

</div>

Hey Jerry

Im new to URcaps developing, and was wondering which functions you use to connect to your server, when node is executed in polyscope?

---

<div class="post-metadata">

**Author:** ![anon62140534](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@anon62140534](https://forum.universal-robots.com/u/anon62140534)\
**Post date:** [March 16, 2018, 3:12pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/4 "2018-03-16T15:12:04Z")

</div>

Kmeld,  
I would be happy to give you any help that I can but your question is too general.  
If you could sharpen your question by telling me what you are trying to accomplish I may be able to give you some insight.  
Jerry

---

<div class="post-metadata">

**Author:** ![anon63859582](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon63859582](https://forum.universal-robots.com/u/anon63859582)\
**Post date:** [March 17, 2018, 12:15pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/5 "2018-03-17T12:15:52Z")

</div>

Im trying to implement a node that connects to a server (via ethernet/ip tcp) running on my external microcontroller. The IP + port# will be set in installation, but im unsure how the node will connect to the server everytime polyscope exucutes it.  
The idea is that polyscope will send a signal to the microcontroller, whether to activate/deactivate my actuator - it is not possible to use the UR controller I/O.  
Thnaks

---

<div class="post-metadata">

**Author:** ![anon62140534](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@anon62140534](https://forum.universal-robots.com/u/anon62140534)\
**Post date:** [March 19, 2018, 11:34am UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/6 "2018-03-19T11:34:34Z")

</div>

Kmeld17,  
Yes, it is possible to do what you are wanting to do. You will most likely need to use XmlRpc to call procedures on your remote computer. You most likely are using HTML in the Installation and Program nodes, gather the required information from the HTML interface, construct XmlRpc to send that info to your remote computer and build your remote procedures in the program language you prefer. You end up with a few discrete operations; Html, Robot Java, Remote Computer XmlRpc handler, Remote Computer execution program.

This is easy to say and may be somewhat difficult to execute ( I speak from experience). You will be mixing several different technologies together to form your end product. I have been through the process and will gladly share my key learnings and offer help where needed.  
Jerry

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [March 20, 2018, 1:43pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/7 "2018-03-20T13:43:28Z")

</div>

Is the microcontroller capable of hosting a TCP server?  
If you have the power to define the protocol yourself, you could create a simple TCP socket communication, where native URScript commands such as `socket_send_int(42, "mySocketName")` and `socket_read_ascii_float(3, "mySocketName")` could be used to communicate at runtime.  
Consult the URScript manual for documentation on the various script commands.  
You could use the URCap to get the IP address to the MCU, and optionally port (or the port could be fixed).

---

<div class="post-metadata">

**Author:** ![anon63859582](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon63859582](https://forum.universal-robots.com/u/anon63859582)\
**Post date:** [March 20, 2018, 2:00pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/8 "2018-03-20T14:00:35Z")

</div>

Thanks Jerry & JBM  
The controller (Raspberri Pi) should be able to host the server.  
I’ll consult the URscript manual.

in addiition, I must say that the project is part of my uni c++ course, which is why i have to run the signal through the RPI.  
Thanks agian for support

---

<div class="post-metadata">

**Author:** ![anon63859582](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon63859582](https://forum.universal-robots.com/u/anon63859582)\
**Post date:** [April 25, 2018, 2:51pm UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/9 "2018-04-25T14:51:31Z")

</div>

Follow up question:  
I’ve now build a URcap, which have been installed on the UR5. But when the urscript attempts an open\_socket, it fails. UR5 & MCU are connected via ethernet cable. I tried setting the UR5 controller network to DHCP, static…, but it just wont connect to the server.  
Any Thoughts?

The plugin works fine on a virtual machine with a cable from my pc to the MCU

Regards

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [May 1, 2018, 9:34am UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/10 "2018-05-01T09:34:58Z")

</div>

For just a 1-to-1 connection via an Ethernet cable, you probably want to use a static IP.  
Also, remember that both devices should be on the same subnet.  
I.e.  
UR: IP = 172.16.17.10 Subnet mask = 255.255.255.0  
MCU IP = 172.16.17.11 Subnet mask = 255.255.255.0

And ensure that the TCP server is running and accepting connections on the MCU, before trying to open the client from URScript.

---

<div class="post-metadata">

**Author:** ![anon63859582](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon63859582](https://forum.universal-robots.com/u/anon63859582)\
**Post date:** [May 1, 2018, 11:20am UTC](https://forum.universal-robots.com/t/ur-skips-socket-send-command/1330/11 "2018-05-01T11:20:27Z")

</div>

Thanks  
This works  
I’m setting the UR5 IP = to the MCU IP + 1 and same mask (static)
