Add auto script for getting data on remote and plotting data on local

master
Harry Ho 2021-03-09 12:41:26 +08:00
parent 45367ac52f
commit bd792739c3
1 changed files with 49 additions and 0 deletions

49
get_and_plot_remote_sayma_data Executable file
View File

@ -0,0 +1,49 @@
#!/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
# └── creotech-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 = "" ]]
then
echo "Arguments: <RP#1 name> <RP#1 channel> <RP#2 name> <RP#2 channel>"
echo "(RP#1 and RP#2 can be the same)"
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 creotech-raw $1"
else
ssh -t -p $HOSTPORT $HOST "cd mlabs-testsuite && python3 rp_get_sayma_data.py creotech-raw $1 $3"
fi
# Transfer data from remote to local
scp -P $HOSTPORT $HOST:/home/pi/mlabs-testsuite/creotech-raw/rp_$1_y$2_raw.bin creotech-raw/
scp -P $HOSTPORT $HOST:/home/pi/mlabs-testsuite/creotech-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