Commit 22ae1ef4 authored by Tobias Bjerg's avatar Tobias Bjerg
Browse files

Mainly START to kill children

parent 2090b7d5
#!/bin/bash
DIR_BASE=/home/mors/WORK/PROJEKTE/Datenlogger/GIT/
DIR_BASE=/home/odaq/GeomagLogger/
# Paramters file
PAR_FILE=$DIR_BASE\usr/par/parameters.par
PAR_FILE=/home/odaq/parameters.par
# Directory with executables
DIR_BIN=$DIR_BASE\bin/
PATH=$PATH:$DIR_BIN
# Read parameters file
source $PAR_FILE
#MYPID=$$
# Check if remote directoy is mounted,
# and mount if necessry
mounted=$(cat /etc/mtab | grep $DIR_VAR)
#echo $MYPID > /home/odaq/pidfile
if [ -z "$mounted" ]; then
mount $DIR_VAR
fi
# Kill all subprocesses when parent dies
#trap 'echo "HELLO: TEST" > /home/odaq/TEST; killall Stream_Reader; killall OBSDAQ_Logger' SIGHUP SIGINT SIGQUIT SIGTERM SIGPIPE TERM EXIT SIGCHLD SIGTSTP SIGBUS SIGABRT SIGTAP SIGILL
function killit {
PIDs=$(pgrep -P $MYPID)
for p in $PIDs; do
pkill -P $p;
done
}
# Read parameters file
source $PAR_FILE
# Create logging directory
mkdir -p $DIR_LOG
# Start data acquisition
#OBSDAQ_Logger $PAR_FILE
OBSDAQ_Logger $PAR_FILE 2> $DIR_LOG/OBSDAQ.log | Stream_Reader $PAR_FILE
{ trap 'kill 0' EXIT; OBSDAQ_Logger $PAR_FILE 2> $DIR_LOG/OBSDAQ.log; pkill -g 0; } | { trap 'kill 0' EXIT; Stream_Reader $PAR_FILE; pkill -g 0; }
#(OBSDAQ_Logger $PAR_FILE 2> $DIR_LOG/OBSDAQ.log && pkill -g 0) | { Stream_Reader $PAR_FILE; pkill -g 0; }
#{ (OBSDAQ_Logger $PAR_FILE $DIR_LOG/OBSDAQ.log | Stream_Reader $PAR_FILE); pkill -P $MYPID; }
# Some attempts to kill all from child process
#PID=$!
#PIDs=$(pgrep -P $PID)
#PID_O=$(pidof OBSDAQ_Logger)
#PID_S=$(pidof Stream_Reader)
#echo "TEST: " $PIDs > /home/odaq/TEST
#wait $!
......@@ -57,7 +57,7 @@ int main(int argc, char* argv[]) {
// Initialize the calibration constants for FGE
Obs_Calibration_Vector cal = Obs_Calibration_Vector(X_s/R,Y_s/R,Z_s/R);
// Initialize the calibration constants for ObsDAQ
cal.set_adc_calibrate("usr/par/ADC.par");
cal.set_adc_calibrate(par.get_str("FILE_ADC_CONFIG"));
// Initialize new OBSDAQ device
driver_obs_obsdaq obsdaq = driver_obs_obsdaq(par.get_str("PORT"),
......
......@@ -21,7 +21,7 @@ int main(){
std::cerr << "BAUD: ";
std::cin >> baud;
driver_serial serial = driver_serial("/dev/ttyUSB0",term,1,baud);
driver_serial serial = driver_serial("/dev/OBSDAQ",term,1,baud);
while (1){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment