47 lines
1.3 KiB
Bash
47 lines
1.3 KiB
Bash
cn-progload() {
|
|
local addr="$1"
|
|
local project="$2" # /foo/bar/baz.bunk
|
|
local ext="${project##*.}" # bunk
|
|
local projfname="${project%.*}" # /foo/bar/baz
|
|
local projfnamebase="${projfname##*/}" # baz
|
|
local zigstash
|
|
zigstash="$(mktemp /tmp/$projfnamebase.XXXX.zig)"
|
|
# Add a zero in front of the 3rd arg
|
|
local slot="0${3}"
|
|
# expand only to the last 2 digits of $slot
|
|
slot="${slot: -2}"
|
|
|
|
|
|
case $ext in
|
|
|
|
vtz)
|
|
if [[ -n $slot ]]; then
|
|
echo "==NOTICE== Ignoring slot number for touchpanel project..."
|
|
fi
|
|
printf 'put %q %q' "$project" "/display/"| cnsftp "$addr"
|
|
cnssh "$addr" projectload
|
|
;;
|
|
|
|
lpz)
|
|
if [[ -z $slot ]]; then
|
|
echo "==NOTICE== No target program slot defined. Assuming Slot 01..."
|
|
slot=01
|
|
fi
|
|
# Stop and delete current program in $slot
|
|
cnssh "$addr" killprog -P$slot
|
|
# Upload
|
|
printf 'put %q %q' "$project" "/Program$slot" | cnsftp "$addr"
|
|
# Load the program
|
|
cnssh "$addr" progload -p:$slot
|
|
# Zip up the sig file in a temporary location
|
|
zip -j - "$projfname.sig" > "$zigstash"
|
|
# Upload the zig
|
|
printf 'put %q %q' "$zigstash" "/Program$slot/$projfnamebase.zig" | cnsftp "$addr"
|
|
;;
|
|
|
|
*)
|
|
echo "Error: Bad file type. Currently only supports vtz and lpz projects."
|
|
;;
|
|
esac
|
|
}
|