Adding script to flash multiple devices at a time, to ensure consistent configuration across all connected devices
Create and publish a Docker image / build-and-push-image (push) Successful in 8m51s
Details
Create and publish a Docker image / build-and-push-image (push) Successful in 8m51s
Details
This commit is contained in:
parent
233fc09f68
commit
7e3b6d7c60
7
.env
7
.env
|
@ -1,2 +1,5 @@
|
|||
DEVICE_PATH=/dev/ttyUSB1
|
||||
BAUD_RATE=230400
|
||||
DEVICES="
|
||||
/dev/ttyUSB0,230400
|
||||
/dev/ttyUSB1,230400
|
||||
/dev/ttyUSB2,230400
|
||||
"
|
|
@ -1,3 +1,19 @@
|
|||
# Flash Xbee devices
|
||||
# ---------------------------------------------------------------------------------
|
||||
# 1. To flash a single device, modify the .env file like shown below:
|
||||
# DEVICE_PATH=/dev/ttyUSB0
|
||||
# BAUD_RATE=230400
|
||||
# Then use the cmd: docker compose -f docker-compose-flash-device.yml up --build
|
||||
#
|
||||
# 2. To flash multiple devices, modify the .env file like shown below:
|
||||
# DEVICES="
|
||||
# /dev/ttyUSB0,230400
|
||||
# /dev/ttyUSB1,230400
|
||||
# /dev/ttyUSB2,230400
|
||||
# "
|
||||
# Then run the bash script using: sh ./flash-devices-batch.sh
|
||||
# -----------------------------------------------------------------------------------
|
||||
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
|
|
|
@ -26,7 +26,6 @@ services:
|
|||
- sim_network
|
||||
|
||||
xbee-mav:
|
||||
# command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400
|
||||
command: tail -f /dev/null
|
||||
depends_on:
|
||||
- ros-master
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# flash-devices-batch.sh
|
||||
# Expects .env file to have the following structure:
|
||||
#
|
||||
# DEVICES="
|
||||
# /dev/ttyUSB0,230400
|
||||
# /dev/ttyUSB1,230400
|
||||
# /dev/ttyUSB2,230400
|
||||
# "
|
||||
#
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
# Load environment variables from .env file
|
||||
. ./.env
|
||||
|
||||
# Iterate over each device in the DEVICES string
|
||||
for device in $DEVICES; do
|
||||
# Split the device string into path and baud rate
|
||||
DEVICE_PATH=$(echo $device | cut -d',' -f1)
|
||||
BAUD_RATE=$(echo $device | cut -d',' -f2)
|
||||
|
||||
# Export the variables for docker-compose to use
|
||||
export DEVICE_PATH
|
||||
export BAUD_RATE
|
||||
|
||||
# Run docker-compose with the current device
|
||||
docker compose -f docker-compose-flash-device.yml up --build
|
||||
|
||||
# Optionally, bring down the containers after each run
|
||||
docker compose -f docker-compose-flash-device.yml down
|
||||
done
|
Loading…
Reference in New Issue