Guest User

/etc/init.d/bms.sh

a guest
Oct 13th, 2021
20
26 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. TARGETV=410
  3. while [ true ];  do
  4.   VOLTAGE=`cut -c1-3 /sys/class/power_supply/fuelgauge/voltage_now`
  5.   VDIFF=`expr $VOLTAGE - $TARGETV`
  6.   if [ "$VDIFF" -gt 10 ]; then
  7.     CUR=133
  8.   elif [ "$VDIFF" -gt 5 ]; then
  9.     CUR=167
  10.   elif [ "$VDIFF" -gt 0 ]; then
  11.     CUR=200
  12.   elif [ "$VDIFF" -gt -5 ]; then
  13.     CUR=233
  14.   elif [ "$VDIFF" -gt -10 ]; then
  15.     CUR=267
  16.   else
  17.     CUR=500
  18.   fi
  19.   read LAST < /sys/class/power_supply/battery/input_current_max
  20.   if [ "$LAST" != "$CUR" ]; then
  21.     echo $CUR >/sys/class/power_supply/battery/input_current_max
  22.   fi
  23.   read TEMP < /sys/devices/virtual/thermal/thermal_zone0/temp
  24.   echo V:$VOLTAGE  C:$CUR T:$TEMP
  25.   sleep 60
  26. done >/var/log/bms.log &
  27.  
RAW Paste Data