I need to be able to run a KAREL program continuously in the background, that listens for a KAREL variable (or perhaps we will look into using a flag for this) that signifies an abort all request. Using a background logic program would be perfect, but KAREL programs sadly cannot be used here. I have tried to use a hot start autoexec program that calls a 'listener' KAREL program with the infinite loop, however this autoexec program still blocks the execution of other KAREL/TP programs which we need for the robot's regular functionality (TPIF-013 Other program is running). I am not sure what other options I have to implement this functionality, all options seems to get stuck on the fact that a program that is running and needs to be aborted blocks the execution of the abort_all program... Any suggestions would be appreciated.
KAREL abort all is blocked by program that needs to be aborted
-
hoitzing -
December 2, 2022 at 10:43 AM -
Thread is Unresolved
-
- Go to Best Answer
-
.. I have tried to use a hot start autoexec program that calls a 'listener' KAREL program with the infinite loop,..
How does the program call the listener Karel? "call" or "run"?
-
It's a KAREL program so it doesn't use either, but it spawns the listener program using "start_task".
-
Update: I have been testing with using the UI[4] with $shell_cfg.$use_abort enabled, which looks promising. Hopefully this will provide a solution that makes the stated problem obsolete.
-
It's a KAREL program so it doesn't use either, but it spawns the listener program using "start_task".
that doesn't really start a program I believe. It calls the function which happens to exist in a different program.
You need to use RUN_TASK.
-
You need to use RUN_TASK.
My bad, I misread and put 'start_task' accidentally, which doesn't even exist in the documentation. I used RUN_TASK indeed, with a blocking program as a result.
-
- Best Answer
The parent would stick around, which is probably what you call blocking.
According to the manual:
If you want the child task to be completely independent of the parent, a KAREL program can initiate
another task using the KCL or KCL_NOWAIT built-ins to issue a KCL>RUN command
-
a KAREL program can initiate another task using the KCL or KCL_NOWAIT built-ins to issue a KCL>RUN command
You are correct, this seems to be what I'm looking for. However, I can't seem to get a KCL call in the KAREL script right. When I'm trying to call a sample KAREL-program 'hello_world.pc' I get status results unequal to 0.
KCL('LOAD PROG hello_world', status) -> returns 2014
KCL('RUN hello_world', status) -> returns 24003 (probably because it wasn't loaded correctly)
Now I can't find any help regarding these return values online, so I'm still stuck.
-
-
-
When I'm trying to call a sample KAREL-program 'hello_world.pc' I get status results unequal to 0.
KCL('LOAD PROG hello_world', status) -> returns 2014
2014 is file-014 which is "file not found".
According to the manual again:
Purpose: Loads a p-code file from the default storage device and default directory into memory using
the specified or default file name. The file type is assumed to be ``.PC.''
If file_spec is not specified, the default program is used. If the default has not been set, then the
message, ``Default program name not set,'' will be displayed.
Note For R-30iB Plus, R-30iB, and R-30iB Mate controllers, the KAREL option must be
installed on the robot controller in order to load KAREL programs.
-
Have you seen this thread:
ThreadBackground programs
I'm getting stuck on setting up some background programs that I want to run on boot. One is a TP program, the other a KAREL program.
I've tried adding each of them to the Cold Start Autoexec option under SYSTEM>CONFIG. No dice. Nothing happens when I cold boot the robot -- no errors show up in the alarm history, the programs just don't run.
I also tried creating a CF file that would load and run both programs, and put it into the Autoexec option. Same (lack of) result.
Then I tried going to…SkyeFireOctober 22, 2020 at 12:36 AM -
2014 is file-014 which is "file not found".
Is there any error code conversion table available? I have tried looking for it but could not find it online.
Regarding the use of the load function; when I already have the .PC file in the controller's memory (but not loaded as the active program), do I need to load the file before I can run it using RUN?
-
Have you seen this thread:
ThreadBackground programs
I'm getting stuck on setting up some background programs that I want to run on boot. One is a TP program, the other a KAREL program.
I've tried adding each of them to the Cold Start Autoexec option under SYSTEM>CONFIG. No dice. Nothing happens when I cold boot the robot -- no errors show up in the alarm history, the programs just don't run.
I also tried creating a CF file that would load and run both programs, and put it into the Autoexec option. Same (lack of) result.
Then I tried going to…SkyeFireOctober 22, 2020 at 12:36 AM Yes I have found this, but the issue in that thread is not what I am running into. I can run a KAREL program as a hot_start program without issues, the problem arises when I want to call another program from this hot_start-ed program.
-
I need to be able to run a KAREL program continuously in the background, that listens for a KAREL variable (or perhaps we will look into using a flag for this) that signifies an abort all request. Using a background logic program would be perfect, but KAREL programs sadly cannot be used here. I have tried to use a hot start autoexec program that calls a 'listener' KAREL program with the infinite loop, however this autoexec program still blocks the execution of other KAREL/TP programs which we need for the robot's regular functionality (TPIF-013 Other program is running). I am not sure what other options I have to implement this functionality, all options seems to get stuck on the fact that a program that is running and needs to be aborted blocks the execution of the abort_all program... Any suggestions would be appreciated.
What is your $SCR.$MAXNUMTASK variable? Maybe increasing this variable and using autoexec will solve your problem.
-
What is your $SCR.$MAXNUMTASK variable?
It is currently set to 4, and I cannot change it ('variable/field write-protected). Since it is already 4 and I'm only running the autoexec program and its child, I don't expect this is the issue (but correct me if I'm wrong).
-
The maximum number of user programs which can be run simultaneously. You can change it in controlled start. I had similar problem and it helped me, but if your variable is set to 4 maybe its not the problem. What does your code look like?
-
The auto-exec program is as follows:
Code
Display More-- hot_start_prg.kl PROGRAM hot_start_prg %NOLOCKGROUP %NOABORT=ERROR+COMMAND+TPENABLE %NOPAUSE=ERROR+COMMAND+TPENABLE VAR status : INTEGER request : STRING[40] BEGIN request = 'LOAD PROG test_bg' KCL(request, status) WRITE(request, ' -- st: ', status, '.', CR) request = 'RUN test_bg' KCL(request, status) WRITE(request, ' -- st: ', status, '.', CR) END hot_start_prg
And the program 'test_bg' that I try to call is for now a simple program I use to debug the functionality:
Code
Display More-- test_bg.kl PROGRAM test_bg %NOLOCKGROUP %NOABORT=ERROR+COMMAND+TPENABLE %NOPAUSE=ERROR+COMMAND+TPENABLE VAR counter, status : INTEGER BEGIN -- program WRITE('BEGINNING TEST_BG', CR) counter = 0 WHILE TRUE DO counter = counter + 1 DELAY 500 SET_INT_REG(196, counter, status) ENDWHILE END test_bg -- program
Both programs build successfully and their .pc files are in the controller's memory in roboguide.
-
Easy solution: don't call a different program. Why don't you start the 'test_bg' direct by autostart.
And by the way: it's a good idea to change the WHILE TRUE with a test for a flag or something else to be able to stop the background program. Otherwise testing will be a bit fiddly.
-
Yes I have found this, but the issue in that thread is not what I am running into. I can run a KAREL program as a hot_start program without issues, the problem arises when I want to call another program from this hot_start-ed program.
In that thread there is described a solution with assigning a macro to a flag, and start the macro by setting this flag, this works with starting TP or Karel programs from a autostart routine, and the foreground task is not blocked by those background tasks.