Skip to content

Commit

Permalink
add: migrate existing scripts:
Browse files Browse the repository at this point in the history
- pico fw update
- start ros bash
- xesc2tcp by jkaflik (ClemensElflein/OpenMowerOS#5)
  • Loading branch information
docgalaxyblock committed Sep 14, 2023
1 parent 2835983 commit 12285a8
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fetch_and_upload_firmware.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

source /boot/openmower/mower_config.txt

# remove old firmware
rm -rf firmware_download
mkdir firmware_download
cd firmware_download

# Download the latest firmware
echo "Fetching Firmware"
wget https://github.com/ClemensElflein/OpenMower/releases/download/latest/firmware.zip

unzip firmware.zip

cd ..

echo "Flashing Firmware: ./firmware_download/firmware/$OM_HARDWARE_VERSION/firmware.elf"
sudo ./upload_firmware.sh ./firmware_download/firmware/$OM_HARDWARE_VERSION/firmware.elf
9 changes: 9 additions & 0 deletions start_openocd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# This script starts OpenOCD on the pi and allows external connections.
# This way you can use VS code to remotely debug the Pico code.

echo "10" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio10/direction
echo "1" > /sys/class/gpio/gpio10/value
openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg -c "bindto 0.0.0.0"
6 changes: 6 additions & 0 deletions start_ros-debug_bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Starts a bash in the container.
# Use this for ROS specific commands (e.g. rostopic echo)

sudo podman exec -it openmower-debug /openmower_entrypoint.sh ${@:-/bin/bash}
6 changes: 6 additions & 0 deletions start_ros_bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Starts a bash in the container.
# Use this for ROS specific commands (e.g. rostopic echo)

sudo podman exec -it openmower /openmower_entrypoint.sh ${@:-/bin/bash}
10 changes: 10 additions & 0 deletions upload_firmware.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# This script uploads new firmware to the Pico.
# You need to provide the .elf file, not the .uf2
# run as root!

echo "10" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio10/direction
echo "1" > /sys/class/gpio/gpio10/value
openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg -c "program $1 verify reset exit"
30 changes: 30 additions & 0 deletions xesc2tcp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

PORT=1234

declare -A DEVICE_MAP=(
["left"]="/dev/ttyAMA4"
["right"]="/dev/ttyAMA2"
["mower"]="/dev/ttyAMA3"
)

if [[ -z $1 ]]; then
echo "Error: Argument required."
exit 1
fi

if [[ -z ${DEVICE_MAP[$1]} ]]; then
echo "Error: Invalid argument. Valid values are: left, right, mower."
exit 1
fi

DEVICE=${DEVICE_MAP[$1]}

running=true
trap 'echo "Interrupt received! Stopping..."; running=false' SIGINT

echo "Running socat for device: ${DEVICE} on port: ${PORT}..."

while $running; do
sudo socat TCP-LISTEN:${PORT},reuseaddr,fork FILE:${DEVICE},b115200,cs8,raw,echo=0 || true
done

0 comments on commit 12285a8

Please sign in to comment.