(1)In order to view logs by filebrowser, I chang programRunLog from /home/programRunLog to /media/nvme/300TC/programRunLog (2)Add kill_psdk.py, but not use

This commit is contained in:
tangchao
2022-12-04 13:21:46 +00:00
parent 8ab4eb7261
commit 76554ef64c
2 changed files with 54 additions and 21 deletions

View File

@ -12,46 +12,46 @@
# 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.
#sleep 60s #rockpi need sleep 180s when start because if not wired lan which psdk's image transmission use don't work normal.
echo "the current directory is " $(pwd)
LogDirectory=/media/nvme/300TC/programRunLog
if [ ! -e /home/programRunLog ]; then
sudo mkdir /home/programRunLog
if [ ! -e $LogDirectory ]; then
sudo mkdir $LogDirectory
else
echo directory "/home/programRunLog" exist!
echo directory $LogDirectory exist!
fi
cd /home/programRunLog
echo "the current directory is " $(pwd)
# run psdk program
cd $LogDirectory
if [ ! -e djiLog ]; then
sudo mkdir djiLog
else
echo directory "djiLog" exist!
fi
#echo "1111111111111111111111111111111111"
#sleep 60s
#echo "2222222222222222222222222222222222"
#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) >> /home/programRunLog/djiLog/runtime.log
sudo /bin/echo $(/bin/date +%F_%T) >> $LogDirectory"/djiLog/runtime.log"
sudo /home/300tc/projects/psdk/psdk_demo &> djiLog/$psdkLogFileName &
# 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
@ -61,6 +61,7 @@ fi
# run ximea program
cd $LogDirectory
if [ ! -e hyperspectralLog ]; then
sudo mkdir hyperspectralLog
else
@ -75,10 +76,9 @@ if [ $procnum -eq 0 ] ; then
echo $fileName
sudo /home/300tc/projects/ximeaAirborneSystem/ximeaAirborneSystem &> hyperspectralLog/$fileName &
sudo /home/300tc/projects/ximeaAirborneSystem/ximeaAirborneSystem &> $LogDirectory"/hyperspectralLog/"$fileName &
echo "Now, start run hyperspectral program!"
else
echo "HyperspectralLog program already runing!"
fi

33
kill_psdk.py Normal file
View File

@ -0,0 +1,33 @@
import os
import sys
import subprocess
def get_process_id(name):
child = subprocess.Popen(["pgrep","-f",name],stdout=subprocess.PIPE,shell=False)
response = child.communicate()[0]
return response
pids = get_process_id("psdk_demo")
pids = pids.splitlines()
print type(pids)
print pids
if not pids:
print "no target pid to kill,please check"
sys.exit(1)
f=open('/media/nvme/300TC/programRunLog/djiLog/Number_of_runs.txt')
signal=[]
for line in f:
signal.append(line.strip())
f.close()
signal_int=int(signal[0])
for pid in pids:
if (signal_int % 2) != 0:
result=os.system("kill -9 "+pid)
if result==0:
print "execute kill success"
else:
sys.exit(1)