Browse Source

bash

master
Your Name 3 years ago
parent
commit
de186cf19d
1 changed files with 31 additions and 0 deletions
  1. +31
    -0
      UserSpaceArduinoUno_via_Ulisp/code/bash_cpu_load/output4.sh

+ 31
- 0
UserSpaceArduinoUno_via_Ulisp/code/bash_cpu_load/output4.sh View File

@ -0,0 +1,31 @@
#!/bin/bash -x
COUNTER=0
while test $COUNTER -lt 1; do #run forever #this seems to expect a file named 1 in the directory. no idea why. EDIT: that was with counter < 1. must use -lt
#if load gt 1, then load == 1
LOAD=$(cat /proc/loadavg | cut -c 1-4)
FIRSTVAL=$(echo $LOAD | cut -c 1) #check if 1 or higher
test $FIRSTVAL == 1; #is equal to 1?
if test $? == 0; then #return value
FINALVAL=47
fi
test $FIRSTVAL > 1;
if test $? == 0; then #if test is succesful, returns zero, so we are looking for a zero
FINALVAL=47
fi
test $FIRSTVAL < 1;
if test $? == 0; then #i know this isn't efficient. could combine if else. dont care.
FINALVAL=$(echo $LOAD | cut -c 3-4)
fi
echo $FINALVAL
#otherwise load x 47 == VAL
DIVIDEBYTWO=$(expr $FINALVAL / 2) #must be space between / and numbers
# if test $DIVIDEBYTWO > 50; then #hmmm... needs -gt not >
# DIVIDEBYTWO=50;
# fi
# echo "DIVIDEBY TWO IS: $DIVIDEBYTWO"
#seems to need a space after the first funct. parenthesis, and the call to function
echo "(defun gopher () (with-i2c (str 96) (write-byte #x40 str) (write-byte $DIVIDEBYTWO str) (write-byte #x00 str))) (gopher)" > /dev/ttyUS>
# echo " (gopher)" > /dev/ttyUSB0
sleep 5
done

Loading…
Cancel
Save