2019-12-11 17:46:30 +00:00
|
|
|
cn-progload() {
|
|
|
|
local addr="$1"
|
2021-05-06 22:44:34 +00:00
|
|
|
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)"
|
2019-12-11 17:46:30 +00:00
|
|
|
# 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)
|
2021-05-06 22:44:34 +00:00
|
|
|
if [[ -n $slot ]]; then
|
2019-12-11 17:46:30 +00:00
|
|
|
echo "==NOTICE== Ignoring slot number for touchpanel project..."
|
|
|
|
fi
|
2021-05-14 16:54:30 +00:00
|
|
|
printf 'put %q %q' "$project" "/display/"| cnsftp "$addr"
|
2021-05-06 22:44:34 +00:00
|
|
|
cnssh "$addr" projectload
|
2019-12-11 17:46:30 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
lpz)
|
|
|
|
if [[ -z $slot ]]; then
|
|
|
|
echo "==NOTICE== No target program slot defined. Assuming Slot 01..."
|
|
|
|
slot=01
|
|
|
|
fi
|
2021-05-06 22:44:34 +00:00
|
|
|
# Stop and delete current program in $slot
|
|
|
|
cnssh "$addr" killprog -P$slot
|
|
|
|
# Upload
|
2021-05-14 16:54:30 +00:00
|
|
|
printf 'put %q %q' "$project" "/Program$slot" | cnsftp "$addr"
|
2021-05-06 22:44:34 +00:00
|
|
|
# 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
|
2021-05-14 16:54:30 +00:00
|
|
|
printf 'put %q %q' "$zigstash" "/Program$slot/$projfnamebase.zig" | cnsftp "$addr"
|
2019-12-11 17:46:30 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Error: Bad file type. Currently only supports vtz and lpz projects."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|