Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add autoflash script for automatic device flashing #32

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions autoflash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Example usage: ./autoflash.sh /dev/ttyACM0 autoflash_ACM0.log

PORT=${1:-/dev/ttyACM0}
OUTFILE=${2:-autoflash_ACM0.log}

while true; do
echo ""
echo "# Waiting for new device on ${PORT}…"
while [ ! -e "${PORT}" ]; do
sleep 0.5
done
echo "# Found new device!"
sleep 1

echo "" | tee -a ${OUTFILE}
echo -n "========== " | tee -a ${OUTFILE}
echo -n $(date -Iseconds) | tee -a ${OUTFILE}
echo -n " ${PORT}" | tee -a ${OUTFILE}
echo " ==========" | tee -a ${OUTFILE}

pio run --upload-port ${PORT} --target upload 2>&1 | tee -a ${OUTFILE}

sleep 1
echo "# Waiting for device disconnect…"
while [ -e "${PORT}" ]; do
sleep 0.5
done
done
Loading