creotech-sayma-testsuite/get_and_plot_remote_sayma_data
2021-05-05 11:47:46 +08:00

53 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# Script to acquire data on remote RP(s), transfer the data to local, and plot the data at local.
# Assumed file hierachy on remote:
# /home/
# └── pi/
# └── mlabs-testsuite/
# ├── rp_get_sayma_data.py
# └── raw/
# | (possible existing data files, will be overwritten)
# ├── rp_..._y1_raw.bin.py
# ├── rp_..._y2_raw.bin.py
# └── ...
# Assumed file hierachy on local:
# ./ (current dir)
# ├── plot_sayma_data.py
# └── creotech-raw/
# | (possible existing data files, will be overwritten)
# ├── rp_..._y1_raw.bin.py
# ├── rp_..._y2_raw.bin.py
# └── ...
# Default host and hostport for the remote
export HOST=pi@rpi-2
export HOSTPORT=6000
if [[ $1 = "" ]] || [[ $2 = "" ]] || [[ $3 = "" ]] || [[ $4 = "" ]] || [[ $5 = "" ]]
then
echo "Arguments: <RP#1 name> <RP#1 channel> <RP#2 name> <RP#1 channel> <RP#1 name>:<IN1 gain>,<IN2 gain> [<RP#2 name>:<IN1 gain>,<IN2 gain>]"
echo "(If RP#1 and RP#2 are the same, skip the bracketed arguments)"
echo "Examples: "
echo "(1) creotech-1 1 creotech-1 2 creotech-1:LV,HV"
echo "(2) creotech-1 1 creotech-2 1 creotech-1:LV,LV creotech-2:HV,HV"
exit
fi
# Acquire data at the remote
if [[ $1 = $3 ]]
then
ssh -t -p $HOSTPORT $HOST "cd mlabs-testsuite && python3 rp_get_sayma_data.py raw $5"
else
ssh -t -p $HOSTPORT $HOST "cd mlabs-testsuite && python3 rp_get_sayma_data.py raw $5 $6"
fi
# Transfer data from remote to local
scp -P $HOSTPORT $HOST:/home/pi/mlabs-testsuite/raw/rp_$1_y$2_raw.bin creotech-raw/
scp -P $HOSTPORT $HOST:/home/pi/mlabs-testsuite/raw/rp_$3_y$4_raw.bin creotech-raw/
# Plot data at local
# (Note: requires numpy, matplotlib and scipy on local)
python plot_sayma_data.py creotech-raw $1:$2 $3:$4