Universal Robots Forum

Send and recive EOT or CR by Socket Communication URScript


I would want to know how could i recive a text with “End of Text” EOT i know that is 04 in ASCII, Actually, i’m using the “socket_read_string” instruction and i have tried to use in like sufix the follow combinations: “eot”, “$04”, “”\u0004", 4 (number). Also, i have tried to put the EOT in the text to compare with the recibe message.

But the software does not recognize it.

I need to use the EOT because the software that I want to communicate use it, and we cant modify that software, we do not have the code to change this character for other.

My code is the following:

   v_rcv_init = "0001##F001##01#\u0004"
   v_ok_init = "0002##0001##01#\u0004"
   rcvData = socket_read_string("etop11","","")
   if (rcvData != ""):
      if (rcvData ==v_rcv_init):
           socket_send_string(v_ok_init, "etop11")
           send_dn_socket = True

I wait you can help me.


EOT is actually End Of Transmission.
ETX (End of TeXt) is 0x03.

If you want to send it, you can use socket_send_byte(4, socket_name).
If you want to receive it, I think socket_read_string would do the job:

msg_part1 = socket_read_string(suffix="#")
msg_part2 = socket_read_string(prefix="#", suffix="#")
msg_part3 = socket_read_string(prefix="#", suffix="#")
msg_part4 = socket_read_string(prefix="#", suffix="") # this square is EOT character

EDIT: There was a square in suffix argument, that represented \004 character, but looks like forum does not allow it.

You can disregard msg_part4. It is only there to get characters out of the buffer.
You can copy-paste this square into a program, but it will not be visible in Polyscope.

String manipulation is really hard in Polyscope, because a lot of standard functions are missing. Usually I did the tricky part in python script and called it via XMLRPC from Polyscope. However, depending on your application, this could be impractical.