blob: 0614ff08277b3b9ec474f00580682ce11caa8903 [file] [log] [blame]
Delphine CC Chiu177e9872023-09-22 10:30:23 +08001#!/bin/bash
2
3set_gpio()
4{
5 local NET_NAME=$1
6 local OUT_VAL=$2
7 mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME")
8 if [ "${#GPIO_INFO[@]}" -ne 2 ]; then
9 echo "set_gpio: can not find gpio, $NET_NAME"
10 return 1
11 fi
12
13 echo -n "set_gpio: set $NET_NAME = $OUT_VAL"
14 if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then
15 echo " failed"
16 return 1
17 fi
18
19 echo " success"
20 return 0
21}
22