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. Fanuc 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

Find Caller/Runner Program in Karel

  • Nation
  • February 18, 2022 at 1:41 AM
  • Thread is Resolved
  • Nation
    Typical Robot Error
    Reactions Received
    544
    Trophies
    9
    Posts
    1,924
    • February 18, 2022 at 1:41 AM
    • #1

    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! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Go to Best Answer
  • pdl
    Reactions Received
    270
    Trophies
    9
    Posts
    1,533
    • February 18, 2022 at 3:58 PM
    • #2

    I think using GET_TSK_INFO to get the attribute TSK_PARENT may help.

  • TitusLepic
    Reactions Received
    112
    Trophies
    7
    Posts
    442
    • February 18, 2022 at 8:03 PM
    • Best Answer
    • #3

    I've done it this way:

    Code
    parentTask = GET_PAR_TSK(thisProgName)
    parentName = GET_TSK_NAME(parentTask)
    
    
    ROUTINE GET_PAR_TSK(myName: STRING): INTEGER
    VAR
    taskNo		: INTEGER
    tempInt		: INTEGER
    tempStr		: STRING[2]
    STATUS		: INTEGER
    BEGIN
    GET_TSK_INFO(myName,taskNo,TSK_PARENT,tempInt,tempStr,STATUS)
    RETURN(tempInt)
    END GET_PAR_TSK
    
    
    ROUTINE GET_TSK_NAME(taskNo: INTEGER): STRING
    VAR
    tskName		: STRING[12]
    tempInt		: INTEGER
    tempStr		: STRING[2]
    STATUS		: INTEGER
    BEGIN
    GET_TSK_INFO(tskName,taskNo,TSK_STATUS,tempInt,tempStr,STATUS)
    RETURN(tskName)
    END GET_TSK_NAME
    Display More
  • Nation
    Typical Robot Error
    Reactions Received
    544
    Trophies
    9
    Posts
    1,924
    • February 18, 2022 at 8:29 PM
    • #4

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

    I tried the following:

    Code
    GET_TSK_INFO(task_name,task_no,TSK_PARENT,valInt,valStr,STATUS)
    GET_TSK_INFO(task_name,task_no,TSK_PROGNAME,valInt,prog_name,STATUS)

    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:

    Code
    STATUS = 0
    task_no=1
    WHILE STATUS = 0 DO
    GET_TSK_INFO(task_name,task_no,TSK_LOCKGRP,valInt,valStr,STATUS)
        IF (valInt=1) THEN
            GOTO gettaskinfo  -- Karel needs a break command
        ENDIF
        task_no=task_no+1
    ENDWHILE
    gettaskinfo::
    GET_TSK_INFO(prog_name,task_no,TSK_PROGNAME,valInt,valStr,STATUS)
    Display More

    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! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Nation
    Typical Robot Error
    Reactions Received
    544
    Trophies
    9
    Posts
    1,924
    • February 18, 2022 at 8:38 PM
    • #5
    Quote from TitusLepic

    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! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

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

  • karel
  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