When a Dexter starts, the job engine is available to automatically start jobs. For example Dexters are often shipped with PhUI starting automatically after startup.
When jobs are running, they monopolize the DexRun firmware. That keeps DDE from talking to the robot, and confuses users who want to write jobs.
At this time, the way to start jobs on boot up is to add them to the end of the RunDexRun script. This script also sets a few critical items in the robots, and is responsible for starting the DexRun firmware (it's right there in the name).
So to change what is running on bootup, the user has to edit the RunDexRun file. And not damage it in unintentional ways. And keep the correct execute permissions, or repair them with chmod +x RunDexRun from the SSH prompt.
To avoid this, we can add the following code to the end of RunDexRun in place of the hard coded job start commands:
#Start default jobs from autoexec.jobs
sleep 5 #give DexRun time to finish starting
#https://stackoverflow.com/questions/1521462/looping-through-the-content-of-a-file-in-bash
while read -u 10 job; do # the -u 10 uses pipe 10 in place of stdin
if [[ $job =~ ^#.* ]]
then
echo "Ignoring $job"
else
if [[ -e /srv/samba/share/dde_apps/$job ]]
then
cd /root/Documents/dde
echo "/srv/samba/share/dde_apps/$job"
sudo node core define_and_start_job /srv/samba/share/dde_apps/$job
sleep 1
else
echo "$job not found"
fi
fi
done 10< autoexec.jobs
# pipe to 10 so dde doesn't read lines from autoexec.jobs via stdin
and then in a few file /srv/samba/share/autoexec.jobs, list the jobs you want to run from the /srv/samba/share/dde_apps folder. e.g.
#helloworld.dde
PHUI2RCP.js
This file, being a simple text list of job names, is much easier to edit without causing damage. And even if it IS damaged, RunDexRun will still start the robot and make the firmware accessible to DDE so that it can be fixed.
Note that jobs can be "commented out" by adding a # to the start of the line
When a Dexter starts, the job engine is available to automatically start jobs. For example Dexters are often shipped with PhUI starting automatically after startup.
When jobs are running, they monopolize the DexRun firmware. That keeps DDE from talking to the robot, and confuses users who want to write jobs.
At this time, the way to start jobs on boot up is to add them to the end of the RunDexRun script. This script also sets a few critical items in the robots, and is responsible for starting the DexRun firmware (it's right there in the name).
So to change what is running on bootup, the user has to edit the RunDexRun file. And not damage it in unintentional ways. And keep the correct execute permissions, or repair them with
chmod +x RunDexRun
from the SSH prompt.To avoid this, we can add the following code to the end of RunDexRun in place of the hard coded job start commands:
and then in a few file /srv/samba/share/autoexec.jobs, list the jobs you want to run from the /srv/samba/share/dde_apps folder. e.g.
This file, being a simple text list of job names, is much easier to edit without causing damage. And even if it IS damaged, RunDexRun will still start the robot and make the firmware accessible to DDE so that it can be fixed.
Note that jobs can be "commented out" by adding a # to the start of the line