58 lines
1.7 KiB
Bash
58 lines
1.7 KiB
Bash
#!/bin/sh
|
|
# The program itself on tower 111 - real camera, gimbal, the tower's own config -
|
|
# with the CPU throttled: 3 min normal, 6 min at 800 MHz + 2 busy cores, 3 min
|
|
# restored. ~13 min. nohup sh ~/thermal-test/guard_run.sh > ~/thermal-test/guard_run.out 2>&1 &
|
|
set -u
|
|
# What scripts/fgc sets up for the program: the camera SDK's transport layer,
|
|
# and the MQTT credentials (read, not sourced).
|
|
export GENICAM_GENTL64_PATH=/opt/VimbaX/cti
|
|
CRED=/etc/fire_gimbal_control/credentials.env
|
|
if [ -r "$CRED" ]; then
|
|
FGC_MQTT_USER=$(sed -n 's/^FGC_MQTT_USER=//p' "$CRED")
|
|
FGC_MQTT_PW=$(sed -n 's/^FGC_MQTT_PW=//p' "$CRED")
|
|
export FGC_MQTT_USER FGC_MQTT_PW
|
|
fi
|
|
T=~/thermal-test
|
|
SIM=$T/software/tools/thermal-sim
|
|
BIN=$T/software/build/fire_gimbal_control
|
|
LOG=$T/guard_run.log
|
|
FIFO=$T/cmd.fifo
|
|
|
|
restore() {
|
|
sudo -n "$SIM/cap-cpu.sh" restore
|
|
pkill -f "stress-ng --cpu" 2>/dev/null
|
|
}
|
|
trap restore EXIT INT TERM
|
|
|
|
rm -f "$FIFO"; mkfifo "$FIFO"
|
|
sleep 100000 > "$FIFO" & # holds the console's stdin open
|
|
holder=$!
|
|
"$BIN" -c ~/.config/fire_gimbal_control/config.ini --no-tui --trace mqtt \
|
|
< "$FIFO" > "$LOG" 2>&1 &
|
|
pid=$!
|
|
say() { echo "$(date +%T) $*"; }
|
|
cmd() { echo "$1" > "$FIFO"; }
|
|
|
|
say "started pid $pid; normal for 3 min"
|
|
sleep 180
|
|
cmd thermal
|
|
say "cap 800 MHz + 2 busy cores for 6 min"
|
|
sudo -n "$SIM/cap-cpu.sh" 800
|
|
stress-ng --cpu 2 --timeout 360s --quiet &
|
|
sleep 120; cmd thermal
|
|
sleep 120; cmd thermal
|
|
sleep 120; cmd thermal
|
|
wait $! 2>/dev/null
|
|
sudo -n "$SIM/cap-cpu.sh" restore
|
|
say "restored; 3 min more"
|
|
sleep 90; cmd thermal
|
|
sleep 90; cmd thermal
|
|
sleep 5
|
|
say "stopping"
|
|
kill -TERM "$pid"
|
|
sleep 15
|
|
kill "$holder" 2>/dev/null
|
|
sleep 3
|
|
kill -0 "$pid" 2>/dev/null && { say "still running, killing"; kill -KILL "$pid"; } || say "program exited"
|
|
rm -f "$FIFO"
|