Skip to content

Commit

Permalink
make sure to check and set pluto fw attrs to ad9361
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Mar 24, 2024
1 parent 85b4d8a commit 30fa967
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

eths=`ls /sys/class/net/ -l | awk '{print $NF}' | grep usb | xargs -l basename`

function turn_on_eths {
for ethx in ${eths}; do
sudo ifconfig ${ethx} up
done
}

function turn_off_eths {
for ethx in ${eths}; do
sudo ifconfig ${ethx} down
done
}


function check_pluto {
rm -f pluto_env
sshpass -panalog ssh root@192.168.2.1 'fw_printenv' > pluto_env 2> /dev/null
grep 'attr_name=compatible' pluto_env > /dev/null
if [ $? -ne 0 ]; then
return 1
fi
grep 'attr_val=ad9361' pluto_env > /dev/null
if [ $? -ne 0 ]; then
return 1
fi
grep 'compatible=ad9361' pluto_env > /dev/null
if [ $? -ne 0 ]; then
return 1
fi
return 0
}

function set_and_reboot_pluto {
sshpass -panalog ssh root@192.168.2.1 'fw_setenv attr_name compatible; fw_setenv attr_val ad9361; fw_setenv compatible ad9361; fw_setenv mode 2r2t' > /dev/null 2>&1
sshpass -panalog ssh root@192.168.2.1 'reboot' > /dev/null 2>&1


}

function wait_for_pluto {
while [ 0 -eq 0 ]; do
sshpass -panalog ssh -o ConnectTimeout=1 root@192.168.2.1 uptime > /dev/null 2>&1
if [ $? -eq 0 ]; then
return 0
fi
sleep 0.5
done
}

for eth in ${eths}; do
turn_off_eths
sudo ifconfig ${eth} up
echo "Wait for pluto on $eth"
wait_for_pluto
check_pluto
if [ $? -ne 0 ]; then
echo "Setting fw param on $eth"
set_and_reboot_pluto
sleep 10 # wait for reboot to start
echo "Waiting for pluto to come back up"
wait_for_pluto
check_pluto
if [ $? -ne 0 ]; then
echo "FAILED TO SET PARAMS ON $eth"
else
echo "Successfully set params on $eth"
fi
else
echo "Params already set on $eth"
fi
wait_for_pluto # lets make sure its online before we turn off this interface again
done

turn_on_eths
sleep 0.5

lsusb -t | grep usb-storage | sed 's/.*Port \([0-9]*\): Dev \([0-9]*\),.*/\1 \2/g' > ~/device_mapping # update out USB mappings
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ test -z "$VIRTUAL_ENV" && source ~/spf-virtualenv/bin/activate

rover_id=`cat /home/pi/rover_id`

if [ ! -f "/home/pi/.ssh/config" ]; then
cp ${repo_root}/data_collection_model_and_results/rover/rover_v3.1/ssh_config /home/pi/.ssh/config
fi

python ${repo_root}/spf/mavlink/mavlink_controller.py --buzzer git

echo "checking if updates available"
bash ${repo_root}/data_collection_model_and_results/rover/rover_v3.1/install_deps.sh
pushd ${repo_root}
current_hash=`git rev-parse --short HEAD`
git pull
Expand Down Expand Up @@ -63,4 +68,4 @@ else
fi

python3 ${repo_root}/spf/mavlink_radio_collection.py \
-c ${config} -m /home/pi/device_mapping -r ${routine} -t "RO${rover_id}" -n $n
-c ${config} -m /home/pi/device_mapping -r ${routine} -t "RO${rover_id}" -n $n
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
sudo apt-get update
sudo apt-get install git screen libiio-dev libiio-utils vim python3-dev uhubctl libusb-dev libusb-1.0-0-dev sshpass -y
8 changes: 6 additions & 2 deletions data_collection_model_and_results/rover/rover_v3.1/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ if [ $# -ne 1 ]; then
fi

#assign the rover its ID
repo_root="/home/pi/spf/"

rover_id=$1
echo ${rover_id} > ~/rover_id

sudo apt-get update
sudo apt-get install git screen libiio-dev libiio-utils vim python3-dev uhubctl libusb-dev libusb-1.0-0-dev -y

bash ${repo_root}/data_collection_model_and_results/rover/rover_v3.1/install_deps.sh
#sudo apt-get update
#sudo apt-get install git screen libiio-dev libiio-utils vim python3-dev uhubctl libusb-dev libusb-1.0-0-dev sshpass -y

# virtual enviornment setup
python -m venv ~/spf-virtualenv
Expand Down
3 changes: 3 additions & 0 deletions data_collection_model_and_results/rover/rover_v3.1/ssh_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Host 192.168.2.*
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null

0 comments on commit 30fa967

Please sign in to comment.