88 lines
2.6 KiB
Bash
Executable File
88 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Program:
|
|
# This script is a finger daemon of program ximeaImageRecorder and psdkProgram. It has three function:
|
|
# 1) ensure that the programs ximeaImagerRecorder and psdkProgram are runing; if not run the programs;
|
|
# 2) generate log file name based the local time and directory if not exist;
|
|
# 3) redirect the output of programs to file generated in (2);
|
|
# Usage:
|
|
# 1) crontab -e
|
|
# 2) */1 * * * * /home/pi/tc_ShellScripts/finger_daemon.sh
|
|
# History:
|
|
# 2021/07/13 Tangchao First release
|
|
# 2022/06/24 Tangchao Second release
|
|
#
|
|
|
|
#sleep 60s #rockpi need sleep 180s when start because if not wired lan which psdk's image transmission use don't work normal.
|
|
|
|
echo "current time is " $(date)
|
|
|
|
echo "the current directory is " $(pwd)
|
|
|
|
LogDirectory=/media/nvme/300TC/programRunLog
|
|
|
|
if [ ! -e $LogDirectory ]; then
|
|
sudo mkdir -p $LogDirectory
|
|
else
|
|
echo directory $LogDirectory exist!
|
|
fi
|
|
|
|
|
|
# run psdk program
|
|
cd $LogDirectory
|
|
if [ ! -e djiLog ]; then
|
|
sudo mkdir djiLog
|
|
else
|
|
echo directory "djiLog" exist!
|
|
fi
|
|
|
|
#python /home/pi/tc_ShellScripts/test.py
|
|
|
|
bool=`ps -ef | grep psdk_demo | grep -v grep | wc -l`
|
|
|
|
if [ $bool -eq 0 ] ; then
|
|
psdkLogFileName=$(date +%Y%m%d_%H%M_%S).dji_log
|
|
sudo /bin/echo $(/bin/date +%F_%T) >> $LogDirectory"/djiLog/runtime.log"
|
|
|
|
# sudo /home/300tc/projects/psdk/psdk_demo &> $LogDirectory"/djiLog/"$psdkLogFileName &
|
|
|
|
cd /home/300tc/projects_source/Payload_SDK_V2.2.1_300tc/sample/platform/linux/manifold2/project/build/
|
|
sudo /home/300tc/projects_source/Payload_SDK_V2.2.1_300tc/sample/platform/linux/manifold2/project/build/psdk_demo &> $LogDirectory"/djiLog/"$psdkLogFileName &
|
|
|
|
runtimes=$(head -n +1 $LogDirectory"/djiLog/Number_of_runs.txt")
|
|
echo $runtimes
|
|
runtimes=$[runtimes+1]
|
|
echo $runtimes
|
|
|
|
sudo sed -i "1i $runtimes" $LogDirectory"/djiLog/Number_of_runs.txt"
|
|
|
|
echo "Now, start run dji program!"
|
|
else
|
|
echo "Dji program already runing!"
|
|
fi
|
|
|
|
|
|
|
|
# run ximea program
|
|
sleep 100s # wait for dji to set time
|
|
cd $LogDirectory
|
|
if [ ! -e hyperspectralLog ]; then
|
|
sudo mkdir hyperspectralLog
|
|
else
|
|
echo directory "hyperspectralLog" exist!
|
|
fi
|
|
|
|
|
|
procnum=`ps -ef | grep ximeaAirborneSystem | grep -v grep | wc -l`
|
|
|
|
if [ $procnum -eq 0 ] ; then
|
|
fileName=$(date +%Y%m%d_%H%M_%S).hyperspectral_log
|
|
|
|
echo $fileName
|
|
|
|
sudo /home/300tc/projects/ximeaAirborneSystem/ximeaAirborneSystem &> $LogDirectory"/hyperspectralLog/"$fileName &
|
|
|
|
echo "Now, start run hyperspectral program!"
|
|
else
|
|
echo "HyperspectralLog program already runing!"
|
|
fi
|