| | |
| | | #!/bin/bash |
| | | #!/bin/sh |
| | | # Copyright (C) 2022 LingYun IoT System Studio |
| | | # Author: Guo Wenxue<guowenxue@gmail.com> |
| | | # |
| | | # This shell script used to control GPIO port on IGKBoard |
| | | # |
| | | |
| | | direction=out |
| | | sysdir=/sys/class/gpio/ |
| | |
| | | cat $pindir/value |
| | | } |
| | | |
| | | if [ $# -lt 1 ] ; then |
| | | if [[ $# -lt 1 ]] ; then |
| | | usage; |
| | | fi |
| | | |
| | |
| | | do |
| | | case "${OPTNAME}" in |
| | | "i") |
| | | direction=in |
| | | direction="in" |
| | | shift |
| | | ;; |
| | | |
| | | "u") |
| | | action=unexport; |
| | | action="unexport"; |
| | | shift |
| | | ;; |
| | | |
| | |
| | | |
| | | calc_pinum $1 |
| | | |
| | | if [[ $action == unexport ]] ; then |
| | | if [[ "$action" == "unexport" ]] ; then |
| | | unexport_gpio |
| | | exit; |
| | | fi |
| | | |
| | | export_gpio |
| | | |
| | | if [ $direction == in ] ; then |
| | | if [[ "$direction" == "in" ]] ; then |
| | | read_gpio |
| | | else |
| | | set_gpio $2 |