first commit, 去掉大文件后新建的git库,和老库的提交17ce6ae一样
This commit is contained in:
134
finger_daemon.sh
Normal file
134
finger_daemon.sh
Normal file
@ -0,0 +1,134 @@
|
||||
#!/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.
|
||||
|
||||
rowNumberDisconnect=0
|
||||
|
||||
while true
|
||||
do
|
||||
|
||||
# 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!
|
||||
delete=2
|
||||
fi
|
||||
|
||||
|
||||
# run psdk program
|
||||
cd $LogDirectory
|
||||
if [ ! -e djiLog ]; then
|
||||
sudo mkdir djiLog
|
||||
else
|
||||
# echo directory "djiLog" exist!
|
||||
delete=2
|
||||
fi
|
||||
|
||||
#python /home/pi/tc_ShellScripts/test.py
|
||||
|
||||
bool=`ps -ef | grep dji_300tc | 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/samples/sample_c/platform/linux/manifold2/build/bin
|
||||
sudo /home/300tc/projects_source/Payload-SDK/samples/sample_c/platform/linux/manifold2/build/bin/dji_300tc &> $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!"
|
||||
tmp1=$(dmesg | grep -n disconnect | grep "usb 1-1.1" | awk '{match($0, /^[0-9]+/); print substr($0, RSTART, RLENGTH)}' | awk 'BEGIN {max = rowNumberDisconnect} {if ($1 > max) max = $1} END {print max}')
|
||||
if [ $tmp1 -gt $rowNumberDisconnect ]; then
|
||||
echo "new disconnect! "$rowNumberDisconnect"\t"$tmp1
|
||||
|
||||
dmesg -T &> $LogDirectory"/djiLog/"kernalLog_$(date +%Y%m%d-%H%M%S).txt
|
||||
|
||||
rowNumberDisconnect=$tmp1
|
||||
|
||||
kill -9 $(ps -ef | grep dji_300tc | grep -v grep | awk '{print $2}')
|
||||
else
|
||||
echo "no disconnect!"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# run ximea program
|
||||
while [ ! -f "/media/nvme/300TC/config/timesyncfromdji" ]
|
||||
do
|
||||
sleep 1s
|
||||
echo "timesyncfromdji don't exist"
|
||||
|
||||
done
|
||||
|
||||
while [ ! -s "/media/nvme/300TC/config/timesyncfromdji" ]
|
||||
do
|
||||
sleep 1s
|
||||
echo "timesyncfromdji is empty"
|
||||
|
||||
done
|
||||
|
||||
number=$(cat /media/nvme/300TC/config/timesyncfromdji)
|
||||
while [ "$number" -eq 0 ]
|
||||
do
|
||||
sleep 1s
|
||||
echo "Time synchronization is not performed."
|
||||
|
||||
number=$(cat /media/nvme/300TC/config/timesyncfromdji)
|
||||
done
|
||||
|
||||
cd $LogDirectory
|
||||
if [ ! -e hyperspectralLog ]; then
|
||||
sudo mkdir hyperspectralLog
|
||||
else
|
||||
# echo directory "hyperspectralLog" exist!
|
||||
delete=2
|
||||
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!"
|
||||
delete=2
|
||||
fi
|
||||
|
||||
sleep 1s
|
||||
|
||||
done
|
Reference in New Issue
Block a user