Skip to content

Instantly share code, notes, and snippets.

@t413
Created March 8, 2022 19:47
Show Gist options
  • Save t413/2065964da1b692deaacec02806c79e81 to your computer and use it in GitHub Desktop.
Save t413/2065964da1b692deaacec02806c79e81 to your computer and use it in GitHub Desktop.
Enables Betaflight blackbox filesystem-mode, archives files, then erases blackbox (for MacOS)
### enables betaflight blackbox filesystem-mode, archives files, then erases blackbox (after manual power cycle)
# usage blackboxPull /dev/tty.my.serial [optional folder to output, default is pwd/logs]
function blackboxPull() {
port="${1}";
folder="${2:-logs}";
[ -f "$port" ] || { echo "port \"$port\" doesn't exist!"; return 1; }
{ echo "#"; sleep 0.5; echo msc; } >> "$port"; ##enables cli then sends command for flash download
sleep 4;
echo "copying files to ${folder}";
rsync -abvP --suffix="_$(date +"%Y%m%d%H%M")" /Volumes/BETAFLT/ "${folder}" --exclude btfl_all.bbl --exclude padding.txt --exclude autorun.inf --exclude icon.ico &&
diskutil unmountDisk /Volumes/BETAFLT &&
echo "power cycle, then hit return to erase blackbox" &&
read &&
{ echo "#"; sleep 1; echo flash_erase; } >> "$port" || return 2; #enable cli, erase flash
cat "$port"; #show erase progress
}
## only execute this if this script is directly called
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
blackboxPull "${@}";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment