Skip to content

Commit

Permalink
Add scripts for connecting and flashing to robots
Browse files Browse the repository at this point in the history
  • Loading branch information
calebchalmers committed Aug 24, 2024
1 parent 8c14997 commit 87a733d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{
"label": "Connect to Robot",
"type": "shell",
"command": "ssh -fF ssh.config ${input:debug_dest} sleep 15",
"command": "scripts/connect_to_robot.sh ${input:debug_dest}",
"hide": true,
"presentation": {
"echo": true,
Expand Down
14 changes: 0 additions & 14 deletions flash.sh

This file was deleted.

28 changes: 28 additions & 0 deletions scripts/build_and_flash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/bash

# Build the source code and flash it to a robot via the dev container.
# This script is useful if you are unable to use the dev container during
# development; for example, if using an IDE that does not support them.
#
# Syntax: scripts/build_and_flash.sh [SSH destination] [scons arguments]

if [ ! -d "ut-robomaster" ]; then
echo "ut-robomaster not found. Please run from the repository folder"
exit 1
fi

run_cmd="
~/.local/bin/scons build ${@:2} &&
cd .. &&
scripts/connect_to_robot.sh $1 &&
cd ut-robomaster &&
~/.local/bin/scons run ${@:2}
"

podman run -it --rm \
--userns=keep-id:uid=1000,gid=1000 \
--security-opt label=disable \
-v .:/code \
-w /code/ut-robomaster \
ghcr.io/ut-ras/robomaster-firmware \
sh -c "$run_cmd"
8 changes: 8 additions & 0 deletions scripts/connect_to_robot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/bash
echo "Attempting connection to [$1]..."
if ssh -fF ssh.config $1 sleep 15; then
echo "Connected"
else
echo "Connection failed"
exit 1
fi

0 comments on commit 87a733d

Please sign in to comment.