From bd792739c3c783d0ec723bc85d132fef0bb8d6c1 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 9 Mar 2021 12:41:26 +0800 Subject: [PATCH] Add auto script for getting data on remote and plotting data on local --- get_and_plot_remote_sayma_data | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 get_and_plot_remote_sayma_data diff --git a/get_and_plot_remote_sayma_data b/get_and_plot_remote_sayma_data new file mode 100755 index 0000000..bacc047 --- /dev/null +++ b/get_and_plot_remote_sayma_data @@ -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: " + 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