You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
819 B
Plaintext

4 years ago
#! /bin/sh
cco=
mdu=
# check arguments
while :; do
[ $# = 0 ] && break
[ "$1" = "-c" ] && cco="$2" && shift 2 && continue
[ "$1" = "-m" ] && mdu="$2" && shift 2 && continue
# invalid argument
exit 1
done
# nothing to do
[ -z "$cco$mdu" ] && exit
. /lib/functions.sh
iface="$(uci_get plc plc interface br-lan)"
[ -n "$cco" ] && case "$cco" in
auto)
cco=0
;;
never)
cco=1
;;
always)
cco=2
;;
*)
exit 1
;;
esac
[ -n "$mdu" ] && case "$mdu" in
disabled)
mdu=0x0000
;;
slave)
mdu=0x0001
;;
master)
mdu=0x0101
;;
*)
exit 1
;;
esac
pib=/tmp/.PIB.$$
plctools-wrapper plctool "" -i "$iface" -p "$pib" || exit
trap 'rm -f "$pib"' EXIT
[ -n "$cco" ] && { modpib -C "$cco" "$pib" || exit; }
[ -n "$mdu" ] && { setpib "$pib" 0x100 word "$mdu" || exit; }
plctools-wrapper plctool "" -i "$iface" -P "$pib"