Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit b734fe7

Browse files
Add Zenoh configuration files and enhance deployment script for Raspberry Pi
1 parent 6625227 commit b734fe7

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

Clusters/InstrumentCluster/config/InstrumentClusterConfig.json renamed to ZenohConfig/InstrumentClusterConfig.json

File renamed without changes.

deploy/scripts/deployToRasp.sh

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ projectDir=RaspberryPi
44
piUserName=team02
55
piIpAddressLocal=10.21.221.64
66
piIpAddressRemote=10.21.221.19
7-
piPath=/home/team02
7+
piPathBin=/opt/vehicle/bin
8+
piPathEtc=/opt/vehicle/etc/zenoh
89
piPass=seameteam2
9-
1010
architecture=$(uname -m)
11-
echo "Detected architecture: $architecture"
11+
12+
check_ssh_connection() {
13+
local host=$1
14+
local user=$2
15+
echo "Checking connection to $host..."
16+
# Use nc (netcat) to test connection with 5 second timeout
17+
if nc -G 5 -z "$host" 22 >/dev/null 2>&1; then
18+
# Test SSH login
19+
if sshpass -p "$piPass" ssh -q -o ConnectTimeout=5 "$user@$host" exit; then
20+
return 0
21+
fi
22+
fi
23+
return 1
24+
}
1225

1326
# Build docker image with appropriate platform flag
1427
echo "Building docker image to build app..."
@@ -33,7 +46,31 @@ echo "Copy the binary from tmp container"
3346
docker cp tmpapp:/home/$projectDir/InstrumentClusterApp ./InstrumentClusterApp
3447
docker cp tmpapp:/home/$projectDir/HandClusterApp ./HandClusterApp
3548
docker cp tmpapp:/home/$projectDir/MiddleWareApp ./MiddleWareApp
36-
echo "Send binary to local rasp over scp"
37-
sshpass -p "$piPass" scp InstrumentClusterApp MiddleWareApp "$piUserName"@"$piIpAddressLocal":"$piPath"
38-
echo "Send binary to remote rasp over scp"
39-
sshpass -p "$piPass" scp HandClusterApp "$piUserName"@"$piIpAddressRemote":"$piPath"
49+
50+
if check_ssh_connection "$piIpAddressLocal" "$piUserName"; then
51+
echo "Stopping services on local Raspberry Pi..."
52+
sshpass -p "$piPass" ssh "$piUserName"@"$piIpAddressLocal" "sudo systemctl stop middleware.service && pkill InstrumentClus"
53+
54+
echo "Send binary to local rasp over scp"
55+
sshpass -p "$piPass" scp InstrumentClusterApp MiddleWareApp "$piUserName"@"$piIpAddressLocal":"$piPathBin"
56+
sshpass -p "$piPass" scp ./$projectDir/ZenohConfig/InstrumentClusterConfig.json ./$projectDir/ZenohConfig/MiddleWareConfig.json "$piUserName"@"$piIpAddressLocal":"$piPathEtc"
57+
58+
echo "Restarting services on local Raspberry Pi..."
59+
sshpass -p "$piPass" ssh "$piUserName"@"$piIpAddressLocal" "sudo systemctl start middleware.service"
60+
61+
echo "InstrumentCluster will restart on next login"
62+
else
63+
echo "ERROR: Cannot connect to local Raspberry Pi at $piIpAddressLocal"
64+
fi
65+
66+
if check_ssh_connection "$piIpAddressRemote" "$piUserName"; then
67+
echo "Stopping service on remote Raspberry Pi..."
68+
sshpass -p "$piPass" ssh "$piUserName"@"$piIpAddressRemote" "pkill HandCluster"
69+
70+
echo "Send binary to remote rasp over scp"
71+
sshpass -p "$piPass" scp HandClusterApp "$piUserName"@"$piIpAddressRemote":"$piPathBin"
72+
73+
echo "HandCluster will restart on next login"
74+
else
75+
echo "ERROR: Cannot connect to remote Raspberry Pi at $piIpAddressRemote"
76+
fi

0 commit comments

Comments
 (0)