Fixed 'view gpio'
This commit is contained in:
parent
590fcb0e91
commit
75c3d6120c
|
@ -0,0 +1 @@
|
|||
.lock
|
|
@ -15,42 +15,34 @@ test ! -f $ROOT/.lock && echo "Daemon not started" && exit 1;
|
|||
# (2) While viewing loop
|
||||
#--------------------------------------------------------#
|
||||
# (1) Initialise vars #
|
||||
BUFFER="";
|
||||
LED="0"; Rx=(0 0 0); # led; relays
|
||||
SYSTD_TREE=""; # service_log
|
||||
|
||||
# (2) Get BUF_IN #
|
||||
source $ROOT/com/config_ioemu;
|
||||
|
||||
|
||||
while sleep 2; clear; do
|
||||
|
||||
# (1) Read buffer into local one (but without flushing buffers) #
|
||||
BUFFER="$BUFFER`$ROOT/com/read ioemu -`";
|
||||
# (3) Get last value from lines beginning by 'GSTA' #
|
||||
STATE="`cat $BUF_IN | grep -Po "^GPIO(.+)$" | sed 's/^GPIO\(....\)$/\1/g' | tail -n1`";
|
||||
|
||||
# (2) Parse each line #
|
||||
line_id=0;
|
||||
echo "state: $STATE";
|
||||
|
||||
while IFS= read -r line; do
|
||||
# (4) Apply to values if not 'x' (means 'ignore' that chip) #
|
||||
if [ ! -z "$STATE" ]; then
|
||||
|
||||
# check if line is about GSTA
|
||||
if [ "${line:0:4}" = "GSTA" ]; then
|
||||
test "${line:4:1}" != "x" && LED="${line:4:1}"; # if set to 'x', ignore
|
||||
test "${line:5:1}" != "x" && Rx[1]="${line:5:1}"; # if set to 'x', ignore
|
||||
test "${line:6:1}" != "x" && Rx[2]="${line:6:1}"; # if set to 'x', ignore
|
||||
test "${line:7:1}" != "x" && Rx[3]="${line:7:1}"; # if set to 'x', ignore
|
||||
test "${STATE:0:1}" != "x" && LED="${STATE:0:1}"; # if set to 'x', ignore
|
||||
test "${STATE:1:1}" != "x" && Rx[1]="${STATE:1:1}"; # if set to 'x', ignore
|
||||
test "${STATE:2:1}" != "x" && Rx[2]="${STATE:2:1}"; # if set to 'x', ignore
|
||||
test "${STATE:3:1}" != "x" && Rx[3]="${STATE:3:1}"; # if set to 'x', ignore
|
||||
|
||||
BUFFER=""; # empty buffer
|
||||
break;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# increment line count
|
||||
line_id=`expr $line_id + 1`;
|
||||
|
||||
done <<< "$BUFFER";
|
||||
|
||||
|
||||
# (3) Display led #
|
||||
# (5) Display led #
|
||||
echo -n "LED: "; $ROOT/src/disp-led $LED;
|
||||
|
||||
# (4) Display relays #
|
||||
# (6) Display relays #
|
||||
echo -n "R1: "; $ROOT/src/disp-relay ${Rx[1]};
|
||||
echo -n "R2: "; $ROOT/src/disp-relay ${Rx[2]};
|
||||
echo -n "R3: "; $ROOT/src/disp-relay ${Rx[3]};
|
||||
|
|
Loading…
Reference in New Issue