Socket send string issue

I have a UR5e polyscope 5.11.7

I’m trying to connect it to a Keyence GT2 sensor via a Keyence DL-EN1 ethernet connector via TCP/IP. (the Keyence expects ASCII code)

I can establish a connection to the unit without any issues.

however when I send the command:
socket_send_string(“M0”,“DL-EN1”) or socket_send_string(“M0\r\n”,“DL-EN1”)

I receive on a socket_read_string(“DL-EN1”) the error
“ER,M0,255\r\n” ( 255 indicates “The command format is not correct”)

(I’ve also tried a socket_send_line(“M0”,“DL-EN1”) and socket_send_line(“M0\r\n”,“DL-EN1”) the effect is the same)

If I make the same connection from my PC using SocketTest v 3 Program
and send the same information (M0) I receive the correct response m0,+000645125,+000210202.

So to test the syntax I’m sending from the Robot, I set up a socket connection from my UR5e to my PC (again using SocketTest v3 program listening on port 30000 from the robot)
and using the same commands! the PC receives M0 from the Robot

Its probably me and I’ve missed something simple
what am I doing wrong?

I’ve never done it before, but in other similar applications, you actually have to escape the quotes themselves like socket_send_string(\“MO\”,\“DL-EN1\”). Maybe you could give that a try?

Hi,

just to add we set up a simple python program to replicate the command, which is in bytes

Which sending b’M0/r/n/’

gets us the result.

we are trying to socket send the command through the universal robot.

eric,
Thanks for your relpy.

socket_send_string(\“M0\”,\“DL-EN1\”)

isn’t accepted by the Robot!

I tried different adaptations of your suggestion but with no affect.

My colleague Chris had some success communicating to the unit with a python program.
and is seems that it requires a Byte format to correctly send the “M0” and receive a valid reply.

I tried to use the socket_send_byte(“M0”)
but again failed (with "ER,**,255)

I may be struggling with a similar issue:

I need to send a string terminated with “\r\n”, but it appears that socket_send_line only appends \n. I have tried concatenating “\r” to the end of my string, but the socket_send_line function seems to add an extra \. << even right here, i had to type two backslashes to get it to display one. this is expected with escape sequences, but undesired when sending byte strings

edit: i found this today, havent tried it yet: TCP socket line terminator