Discussion

Left ArrowBack to discussions page
SepehrSepehr Posts: 4 Apprentice
Hello all,

I am trying to create a socket through a UR script (socket_open) on a UR10 and then read/send data from/to PC. (read data to move the robot and send a random string to make sure the PC is still connected) 
The problem is that  the command "isConnected = socket_send_string(\"test\")\n" is always successful (always return true!) even if I disconnect the cable between the robot controller and PC! 

Is there a way that I can detect the connection problem between robot and pc? Or am I doing something wrong here?

Thanks in advance for help.

Comments

  • PaulGWFPaulGWF Posts: 10 Apprentice
    edited September 9
    Hi Sepehr,

    Have you taken a look to the method’s documentation? From what I could find on the internet, this method is to be used after the socket was openned. Socket openning can be done with socket_open method, which returns a boolean indicating wether it has succeded or not.
    Do you check the return value of your socket opening?

    For more information please follow post about "Ethernet socket communication via URScript - 15678:)

    Regards.

    Paul
  • SepehrSepehr Posts: 4 Apprentice
    @PaulGWF
    Yes, the socket_open is used before socket_sent_string and the return value is always true. I thought that if something is blocking the communication between the pc and the controller, socket_send_string will return false, which is not the case! For now, I have removed that check from my robot program. I will investigate it more in the future.
  • PaulGWFPaulGWF Posts: 10 Apprentice
    @Sepehr
    it seems quite odd that the socket_open returns true when connecting to a host that is unreachable.
    This might seem very basic to you but are you sure that you are using the correct host address and port?
  • bcastetsbcastets Posts: 100Vacuum Beta tester Handy
    Maybe can use modbus register of the robot and a stread to check if the connection is correctly running.

    - Set a modbus register variable by default the value will be 0 (not connected)
    - Make stread on your PC which periodically write a 1 in the modbus register of the robot.
    - Make a stread on the robot which:

    • return the modbus register variable to 0 if it is a 1.
    • display a disconnection message if the variable is at 0
    If the tread frequency on the robot is twice less than the tread frequency of the PC stread, it should work.

    I hope it helps,

  • SepehrSepehr Posts: 4 Apprentice
    PaulGWF said:
    @Sepehr
    it seems quite odd that the socket_open returns true when connecting to a host that is unreachable.
    This might seem very basic to you but are you sure that you are using the correct host address and port?
    Yes, that's why I decided to post it here to check if someone else had the same issue before or not!
    I validated that the port and IP are correct for openning the socket. 
    I am still working on this issue! Will keep you updated if I found an answer to this!
  • SepehrSepehr Posts: 4 Apprentice
    bcastets said:
    Maybe can use modbus register of the robot and a stread to check if the connection is correctly running.

    - Set a modbus register variable by default the value will be 0 (not connected)
    - Make stread on your PC which periodically write a 1 in the modbus register of the robot.
    - Make a stread on the robot which:

    • return the modbus register variable to 0 if it is a 1.
    • display a disconnection message if the variable is at 0
    If the tread frequency on the robot is twice less than the tread frequency of the PC stread, it should work.

    I hope it helps,

    Thanks for your help.
    I will try your solution in the near future. I decided not to continue using this validation in my program for now.
Sign In or Register to comment.
Left ArrowBack to discussions page