Find Caller/Runner Program in Karel

  • Figure this is a long shot, but has anyone been able to derive the program that called a Karel program? I'm writing a logging program for a customer, and would like to know what program called/ran my logging function. The logger then creates a program based on the name of the caller/runner and appends _LOG to it. The logger is called from a TP program.

    So far, I've found $TP_DEFPROG and $SHELL_WRK.$ROUT_NAME, but neither is very reliable. $TP_DEFPROG shows what is pulled up on the pendant, so if the user has something else pulled up, that's what it will get, while $SHELL_WRK.$ROUT_NAME seems to lag behind what is actually executing.

    My next avenue is to dig around in the GET_TSK_INFO procedure and see what that tells me.

    Check out the Fanuc position converter I wrote here!

  • AD
    • Helpful

    I've done it this way:

  • Well, that was a pain in the ass. Karel is a joy to work with as always.

    I tried the following:


    This had some promising results initially. It would return the task and program in that task that fired up this code, but then something happened, and it would only return itself as its parent. I was running the code from a TP program.

    Then I switched to this:

    Since I know my calling task will have the 1st motion group locked, I just loop through all running tasks until I find the that task, then get its running program out of it. This seems to be pretty reliable.

    On a side note: This thread has been extremely helpful with creating a TP program using Karel. Last thing I need to do is to figure out how to alter the header of the created program to say that it is a line tracking program.

    Check out the Fanuc position converter I wrote here!

  • I've done it this way:

    ::large code block::

    Great post. You manged to post it while I was writing up my long winded reply.

    This works a lot better. And I see why my initial attempts weren't working. I was leaving the both the task_no, and the task_name uninit, or whatever they were last time. I didn't even think to set the task name to itself.

    Check out the Fanuc position converter I wrote here!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now