1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. KUKA Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

EthernetKRL connection does not close when submit is deselected

  • mjnewsum
  • July 15, 2021 at 4:32 PM
  • Thread is Unresolved
  • mjnewsum
    Reactions Received
    1
    Trophies
    3
    Posts
    60
    • July 15, 2021 at 4:32 PM
    • #1

    I have EKI running in a user defined submit (multi-submit package installed) on a KRC4. I am not sure how to close the connection when deselecting the submit.

    This sometimes causes an error when the submit is selected. Error - Connection is already initialized. I am trying to find a way to check if the connection is initialized before calling EKI_Init(), but I have not found a valid way to check this. IF NOT RET_Init.Connected THEN EKI_Init() also causes an error.

    I will continue looking for a way to check if there is a connection before initializing (maybe with $FLAG[x]...?), but I also want to know how to close the connection when the submit is deselected. It doesn't make sense to leave it open when it is not in use.

    I found some useful information in this thread How to tell if a connection has already been opened in KUKA.EthernetKRL, but I haven't figured out how to implement the suggestions without getting more erros:

    IF RET.Msg_NO==0 THEN...

    IF NOT RET.Connected THEN...

    I checked the EthernetKRL30 documentation as recommended as well, but it only says to "Delete overprogrammed function" to solve the already initialized error. I only have EKI_Init in the program one time. The issue is that it is called more than once when the program is run again. Actually, the issue is that the program does not close when deselected. I would like to handle both issues, but I am a bit stuck.

  • Online
    panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,037
    • July 15, 2021 at 8:21 PM
    • #2

    you may want to elaborate... what is the configuration? what is the code? is the EKI used as client or server? did you set ENVIRONMENT correctly?

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • mjnewsum
    Reactions Received
    1
    Trophies
    3
    Posts
    60
    • July 15, 2021 at 9:55 PM
    • #3

    Configuration:

    Code
    <ETHERNETKRL>
        <CONFIGURATION>
            <EXTERNAL>
                <IP>172.31.1.44</IP>
                <PORT>59152</PORT>
                <TYPE>Server</TYPE>
            </EXTERNAL>
            <INTERNAL>
            <ENVIRONMENT>Submit</ENVIRONMENT>
                <ALIVE Set_Flag="1" Ping="200" />
                <TIMEOUT Connect="666" />
                <IP>172.31.1.4</IP>
                <PORT>59152</PORT>
                <PROTOCOL>TCP</PROTOCOL>
                <MESSAGES Display="error" Logging="warning" />
            </INTERNAL>
        </CONFIGURATION>
        <RECEIVE>
        </RECEIVE>
            <SEND>
            <XML>
                <ELEMENT Tag="ThingToSend" Type="STRING" />
            </XML> 
        </SEND>
    </ETHERNETKRL>
    Display More

    Code:

    Code
    &ACCESS RVO
    &REL 23
    &PARAM EDITMASK = *
    &PARAM TEMPLATE = C:\KRC\Roboter\Template\submit
    DEF TCP_Streaming( )
    ;FOLD DECLARATIONS
      ;FOLD USER DECL
      ;ENDFOLD (USER DECL)
    ;ENDFOLD (DECLARATIONS)
    ;FOLD INI
      ;FOLD USER INIT
    ; I have tried the block commented out below, but 
    ; it had the error {%variable} value invalid
    ; I am not sure how to initialize RET_Init in the .DAT
    ; IF NOT EKI_Init.Connected THEN
    ;     RET_Init=EKI_Init("ThingSender")
    ; ENDIF
    
        RET_Init=EKI_Init("ThingSender") 
    ; this causes the already initialized,
    ; if the submit stopped while the connection was open 
    
    LOOP
    ;FOLD USER PLC
      IF _stopSubmit THEN
        ; break out of the loop
        _stopSubmit = FALSE
        EXIT
      ENDIF
      IF sendAThing THEN
        RET_Open_Event = EKI_Open("ThingSender")
        RET = EKI_SetString("ThingSender", "ThingToSend", "Thing")
        RET_Send_Event = EKI_Send("ThingSender", "ThingToSend")
        RET_Close_Event = EKI_Close("ThingSender")
      ENDIF
    ENDLOOP
    RET_Clear = EKI_Clear("ThingSender")
    END
    Display More

    I had to dumb down the code, but this is the basic skeleton of what is happening.

    This service is working. I receive data every time I sendAThing. My main issue seems to be stopping and starting the submit. I want to add error handling, but I am not sure how to achieve this.

  • Online
    SkyeFire
    Reactions Received
    1,042
    Trophies
    12
    Posts
    9,388
    • July 16, 2021 at 2:26 PM
    • #4

    Where is TCP_Streaming called from? Or do you have it assigned as one of the secondary SPSs?

    Try checking $FLAG[1] instead of EKI_Init.Connected.

    Also, EKI_Init is function call, not a variable. IF NOT EKI_Init.Connected THEN is not a valid instruction.

  • Online
    panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,037
    • July 16, 2021 at 2:56 PM
    • #5

    that was supposed to be IF NOT RET_Init.Connected THEN

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • mjnewsum
    Reactions Received
    1
    Trophies
    3
    Posts
    60
    • July 16, 2021 at 4:14 PM
    • #6

    SkyFire and Panic Mode, sorry for the typo in the dummy code, I was adding back in the block of code that caused the error and mistyped in the posted code. It was correct in my original post about the error. The original code did use IF NOT RET_Init.Connected THEN.

    I found a solution to the first error.

    The error was: {%variable} value invalid. Cause: Calling RET_Init.Connected.

    To get rid of this error, I had to Declare and Initialize RET_Init in a .DAT file. I couldn't figure out how to do this before, but here is how I got it working, in case anyone else runs into this issue.

    DEFDAT TCP_Streaming PUBLIC

    DECL GLOBAL EKI_STATUS RET_Init = {Buff 0, Read 0, Msg_No 0, Connected FALSE, Counter 0}

    ENDDAT

    I still would like to know how to tell the EKI connection to close when this submit program is deselected. It seems problematic to leave the connection open while it is not in use. Can this be done with something like an interrupt, or would I have to use another submit to check if this submit is still running and close it from there? That doesn't seem like a real solution.

  • Online
    panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,037
    • July 16, 2021 at 6:15 PM
    • #7

    you mentioned that your code tries sending message, then it gets response.

    if your message fails to send you can use this info to close connection.

    but this is only sending...

    also you can have a timer. reset timer every time new message is received. if you stop receiving messages for some time, timer will expire and this can be used to to something.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • mjnewsum
    Reactions Received
    1
    Trophies
    3
    Posts
    60
    • July 16, 2021 at 7:25 PM
    • #8

    I receive the data in my external program. I am only sending from EKI.

    After testing my application some more, I am still getting the connection already initialized when calling EKI_Init().

    My application Initializes the connection only once at the top of the program. I then open, write, send and close the connection on each loop when there is something to send. When the program is reset, my RET_Init.Connected is FALSE, but the connection is still initialized. This doesn't seem possible. If it is possible, I don't see how I can check if the connection is initialized. I tried IF NOT $FLAG[1] THEN, but $FLAG[1] is only TRUE for a brief second when the program is running, so this still lets me initialize an already initialized connection. I am about to just put ON_ERROR_PROCEED on the EKI_Init() call, but I don't like this as a solution.

  • mjnewsum
    Reactions Received
    1
    Trophies
    3
    Posts
    60
    • July 16, 2021 at 7:32 PM
    • #9
    Code
      IF NOT $FLAG[1] THEN ;Flat[1] is set ALIVE by Config
        IF NOT RET_Init.Connected THEN
          RET_Init=EKI_Init("ThingSender")
        ENDIF
      ENDIF

    Here are the If statements I am using. I am not sure what else I can check before trying to initialize the connection.

  • Online
    SkyeFire
    Reactions Received
    1,042
    Trophies
    12
    Posts
    9,388
    • July 20, 2021 at 12:02 AM
    • #10

    If $FLAG[1] isn't True, then the connection isn't open. Period. But that's different from not being initialized.

    You still haven't answered the question of how this program is being called from the SPS, or if it's set up in an SPS of its own. Or how the program gets "de-selected."

    Quote from mjnewsum

    After testing my application some more, I am still getting the connection already initialized when calling EKI_Init().

    And what is the actual code # of this message, and it's exact text? And is this error actually halting the program, or is it just throwing a nuisance informational warning?

    This is from deployed production code using EKI in an SPS, and you'll see it's not really any different than what you're doing:

    Code
     InitRet=EKI_Init(config[])
       EKI_CHECK(InitRet,#QUIT)
       IF (InitRet.Msg_No == 0) THEN
          IsInit = TRUE
       ELSE
          IsInit = FALSE
       ENDIF
       IsConn = FALSE

    I can't recall EKI_INIT ever throwing a halting state, only EKI_CHECK, and then only if the XML file was buggy. The above code is run every time the robot boots, or the SPS is re-selected, or the connection is lost and triggers an automatic re-connect.

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • KRC4
  • EthernetKRL
  • Submit Interpreter
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download