Skip to content

Commit

Permalink
Miscellaneous fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VR-25 committed Jul 29, 2022
1 parent f740feb commit 142d160
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
3 changes: 1 addition & 2 deletions install/acc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ test_charging_switch() {

local idleMode=false
local failed=false
local testingSwitch=true
chargingSwitch=($@)

echo
Expand All @@ -152,7 +151,7 @@ test_charging_switch() {
echo "chargingSwitch=($*)" > $TMPDIR/.sw
flip_sw off

$blacklisted && {
${blacklisted:-false} && {
print_blacklisted
return 10
}
Expand Down
8 changes: 4 additions & 4 deletions install/accd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ else
local over3=false
[ $# -gt 3 ] && over3=true
for f in $(echo $1); do
if [ -f "$f" ] && chmod +r $f 2>/dev/null \
if [ -f "$f" ] && chmod a+r $f 2>/dev/null \
&& {
! cat $f > /dev/null 2>&1 \
|| [ -z "$(cat $f 2>/dev/null)" ] \
Expand Down Expand Up @@ -599,7 +599,7 @@ else
: > $TMPDIR/ch-volt-ctrl-files_
ls -1 $(ls_volt_ctrl_files | grep -Ev '^#|^$') 2>/dev/null | \
while read file; do
chmod +r $file 2>/dev/null && grep -Eq '^4[1-4][0-9]{2}' $file || continue
chmod a+r $file 2>/dev/null && grep -Eq '^4[1-4][0-9]{2}' $file || continue
grep -q '.... ....' $file && continue
echo ${file}::$(sed -n 's/^..../v/p' $file)::$(cat $file) \
>> $TMPDIR/ch-volt-ctrl-files_
Expand All @@ -613,13 +613,13 @@ else
: > $TMPDIR/ch-curr-ctrl-files_
ls -1 $(ls_curr_ctrl_files_boolean | grep -Ev '^#|^$') 2>/dev/null | \
while read file; do
chmod +r $file 2>/dev/null || continue
chmod a+r $file 2>/dev/null || continue
grep -q '^[01]$' $file && echo ${file}::1::0 >> $TMPDIR/ch-curr-ctrl-files
done

ls -1 $(ls_curr_ctrl_files_static | grep -Ev '^#|^$') 2>/dev/null | \
while read file; do
chmod +r $file 2>/dev/null || continue
chmod a+r $file 2>/dev/null || continue
defaultValue=$(cat $file)
[ -n "$defaultValue" ] || continue
ampFactor=$(sed -n 's/^ampFactor=//p' $dataDir/config.txt 2>/dev/null)
Expand Down
26 changes: 13 additions & 13 deletions install/batt-interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ not_charging() {
tt "${chargingSwitch[$*]-}" "*\ --" || battStatusOverride=
[ $currFile != $TMPDIR/.dummy-curr ] || battStatusWorkaround=false

if [ -z "${battStatusOverride-}" ] && [ "$switch" = off ]; then
if [ -z "${battStatusOverride-}" ] && [ -n "$switch" ]; then
for i in $(seq $nci); do
! status ${1-} || return 0
[ $i = $nci ] || sleep 3
done
return 1
elif ! ${isAccd:-false} && [ "$switch" = on ]; then
for i in $(seq $nci); do
status ${1-} || return 1
if [ "$switch" = off ]; then
! status ${1-} || return 0
else
status ${1-} || return 1
fi
[ ! -f $TMPDIR/.nowrite ] || { rm $TMPDIR/.nowrite 2>/dev/null || :; break; }
[ $i = $nci ] || sleep 3
done
[ "$switch" = on ] || return 1
else
status ${1-}
fi
Expand All @@ -48,8 +48,8 @@ online() {
read_status() {
local status="$(cat $battStatus)"
case "$status" in
*Charging*) printf Charging;;
*Not*) printf Idle;;
Charging|Discharging) printf %s $status;;
Not?charging) printf Idle;;
*) printf Discharging;;
esac
}
Expand All @@ -76,8 +76,6 @@ status() {

_status=$(read_status)

[ -z "${exitCode_-}" ] || echo " switch:${switch:-on} current:$curThen,$curNow"

if [ -n "${battStatusOverride-}" ]; then
if tt "$battStatusOverride" "Discharging|Idle"; then
[ $(cat ${chargingSwitch[0]}) != ${chargingSwitch[2]} ] || _status=$battStatusOverride
Expand All @@ -88,6 +86,8 @@ status() {
[ $_status = Idle ] || idle_discharging
fi

[ -z "${exitCode_-}" ] || echo -e " switch: ${switch:--} (${swValue:-N/A})\tcurrent: $(calc $curNow \* 1000 / ${ampFactor:-$ampFactor_} | xargs printf %.f)mA ($_status)"

for i in Discharging DischargingDischarging Idle IdleIdle; do
[ $i != ${1-}$_status ] || return 0
done
Expand Down Expand Up @@ -143,7 +143,7 @@ if ${init:-false}; then
}


idleThreshold=21 # mA
idleThreshold=11 # mA
ampFactor=$(sed -n 's/^ampFactor=//p' $dataDir/config.txt 2>/dev/null || :)
ampFactor_=${ampFactor:-1000}

Expand Down
2 changes: 1 addition & 1 deletion install/read-ch-curr-ctrl-files-p2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ then

ls -1 $(ls_curr_ctrl_files_dynamic | grep -Ev '^#|^$') 2>/dev/null | \
while read file; do
chmod +r $file || continue
chmod a+r $file || continue
defaultValue=$(cat $file)
[ -n "$defaultValue" ] || continue
[ $defaultValue -eq 0 ] && continue
Expand Down
4 changes: 1 addition & 3 deletions install/set-ch-curr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ set_ch_curr() {

apply_current() {
eval "
if [ $1 -ne 0 ]
then
if [ $1 -ne 0 ]; then
maxChargingCurrent=($1 $(sed "s|::v|::$1|" $TMPDIR/ch-curr-ctrl-files))
else
maxChargingCurrent=($1 $(sed "s|::v.*::|::$1::|" $TMPDIR/ch-curr-ctrl-files))
Expand All @@ -50,7 +49,6 @@ set_ch_curr() {
&& unset max_charging_current mcc \
&& apply_on_plug \
&& {
#noEcho=true
! $verbose || print_curr_set $1
} || return 1
}
Expand Down
1 change: 0 additions & 1 deletion install/set-ch-volt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ set_ch_volt() {
&& unset max_charging_voltage mcv \
&& apply_on_boot \
&& {
#noEcho=true
! ${verbose:-true} || print_volt_set $1
} || return 1
}
Expand Down

0 comments on commit 142d160

Please sign in to comment.