# intended to be included from shell-script PORT=${PORT:-/dev/ttyUSB0} _PROJECT_DIR=${0%/*} _SCRIPTS_DIR=${0%/*}/../scripts if test -z "$PY_SOURCES"; then echo "PY_SOURCES variable must be set" exit 1 fi testport() { if test -c $PORT; then true else echo "$PORT not connected" >&2 exit 1 fi } case "$1" in console) testport screen $PORT 115200 ;; flash) testport $_SCRIPTS_DIR/flash.sh "${PORT}" ;; setup) testport $_SCRIPTS_DIR/setup_wlan.sh "${PORT}" "${_PROJECT_DIR}/.config" ;; copy) testport for file in $PY_SOURCES; do $_SCRIPTS_DIR/transfer.sh "${PORT}" "${_PROJECT_DIR}/$file" "$file" done ;; format) testport $_SCRIPTS_DIR/format.sh "${PORT}" ;; reset) testport echo -e -n "\003\004" > "${PORT}" sleep 3 ;; config) export srctree="${_PROJECT_DIR}" export KCONFIG_CONFIG="${_PROJECT_DIR}/.config" python3 "$_SCRIPTS_DIR/menuconfig.py" "${_PROJECT_DIR}/Kconfig" ;; *) echo "Command '$1' not supported" >&2 exit 1 ;; esac