Demo application
#!/bin/sh
init_leds() {
echo
26
> /sys/
class
/gpio/export
echo
500
> /sys/
class
/gpio/export
echo out > /sys/
class
/gpio/gpio26/direction
echo out > /sys/
class
/gpio/gpio500/direction
echo
0
> /sys/
class
/gpio/gpio26/value
echo
1
> /sys/
class
/gpio/gpio500/value
}
set_leds() {
echo $
1
> /sys/
class
/gpio/gpio26/value
echo $
2
> /sys/
class
/gpio/gpio500/value
}
init_buzzer() {
echo
503
> /sys/
class
/gpio/export
echo out > /sys/
class
/gpio/gpio503/direction
echo
1
> /sys/
class
/gpio/gpio503/value
}
beep() {
for
i in $(seq $
2
)
do
echo
1
> /sys/
class
/gpio/gpio503/value
usleep $
1
echo
1
> /sys/
class
/gpio/gpio503/value
usleep $
1
done
}
get_status() {
status=$(rauc status --detailed | grep
"state=booted"
-A
5
-B
1
)
bootname=$(echo $status | grep -o
"bootname=system[01]"
| grep -o
"system[01]"
)
version=$(echo $status | grep -o
"version=.*$"
| grep -o
"[^=]*$"
)
if
[[
"system0"
== $bootname ]]
then
set_leds
1
1
elif [[
"system1"
== $bootname ]]
then
set_leds
0
0
fi
}
show_status() {
clear
clear
dialog --no-lines --infobox "\
Status\n\
\n\
bootname:\n\
$bootname\n\
version:\n\
$version" \
8
16
}
invert_colors() {
printf
'\ePtmux;\e\e[?5h\e\\'
}
revert_colors() {
printf
'\ePtmux;\e\e[?5l\e\\'
}
show_logo() {
fbi -T
1
--noverbose esec_logo.png
sleep
3
revert_colors
killall fbi
invert_colors
}
revert_colors
init_leds
init_buzzer
cloud=
false
get_status
show_logo
invert_colors
show_status
cat logfile | \
#journalctl -f -u rauc-hawkbit-updater | \
while
read line ;
do
if
$cloud
then
revert_colors
killall fbi
invert_colors
show_status
cloud=
false
beep
100000
1
fi
perc_line=$(echo
"$line"
| grep
"Start downloading: "
)
if
[ $? =
0
]
then
cloud=
true
fbi -T
1
--noverbose solid_cloud-download-alt.png
beep
100000
1
fi
perc_line=$(echo
"$line"
| grep
" :.*%"
)
if
[ $? =
0
]
then
message=$(echo
"$perc_line"
| grep -o
"% .*$"
| grep -o
"[^% ].*"
)
perc=$(echo
"$perc_line"
| grep -o
" :.*%"
| grep -o [
0
-
9
]*)
if
[ $? =
0
]
then
cat <<-EOF
XXX
$perc
$message
XXX
EOF
fi | dialog --no-lines --gauge Installing
8
16
fi
perc_line=$(echo
"$line"
| grep
"Software bundle installed successful."
)
if
[ $? =
0
]
then
sleep
1
fbi -T
1
--noverbose solid_check-circle.png
beep
100000
1
sleep
5
revert_colors
killall fbi
beep
100000
1
invert_colors
dialog --no-lines --msgbox
"Rebooting now!"
8
16
echo reboot
show_status
fi
perc_line=$(echo
"$line"
| grep
"Cancellation completion is finished successfully."
)
if
[ $? =
0
]
then
fbi -T
1
--noverbose solid_times-circle.png
beep
100000
1
sleep
5
revert_colors
killall fbi
invert_colors
show_status
fi
perc_line=$(echo
"$line"
| grep
"Failed to "
)
if
[ $? =
0
]
then
sleep
1
fbi -T
1
--noverbose solid_exclamation-circle.png
beep
100000
2
sleep
10
revert_colors
killall fbi
invert_colors
show_status
fi
usleep
100000
done
CCES39645-557