#!/bin/sh
# Gesamtablauf:
# 
# ggf. alten Test_JobApi004 killen und gdbserver
# KM entladen
# fpga neu laden
# KM laden, parallel 

newImgId=$1

modprobe -r KM_CvKernelAccess.ko
sync
/opt/fpga_load /opt/ImgFromJavaTool.bit &
pid = $!
echo "pid of fpga_load: $pid"
cd /
killall Test_JobApi004
sleep 2
killall gdbserver

if [ "$newImgId" != "" ]
then
	echo "Speichere neue FPGA_IMG_ID IN /FPGA_IMG_ID.txt: $newImgId"
	echo "$newImgId" >/FPGA_IMG_ID.txt
fi


# warte auf fpga_load und lade danach KM
wait $pid
modprobe KM_CvKernelAccess.ko

/Test_JobApi004
