@@ -270,8 +270,8 @@ batdrv_select_battery () {
270
270
# retval: $_bat_str: BAT0/BAT1;
271
271
# $_bt_cfg_bat: config suffix = BAT0/BAT1;
272
272
# $_bat_idx: 1/2;
273
- # $_bd_read: directory with battery data sysfiles (for tlp-stat) ;
274
- # $_bd_reada : directory with battery data sysfiles (ACPI );
273
+ # $_bd_read: directory with battery data sysfiles;
274
+ # $_bd_readsm : directory with battery data sysfiles (tp-smapi );
275
275
# $_bf_start: sysfile for start threshold;
276
276
# $_bf_stop: sysfile for stop threshold;
277
277
# $_bf_dischg: sysfile for force discharge;
@@ -281,7 +281,7 @@ batdrv_select_battery () {
281
281
_bat_idx=0 # no index
282
282
_bat_str=" " # no bat
283
283
_bd_read=" " # no directories
284
- _bd_reada =" "
284
+ _bd_readsm =" "
285
285
_bf_start=" "
286
286
_bf_stop=" "
287
287
_bf_dischg=" "
@@ -346,16 +346,15 @@ batdrv_select_battery () {
346
346
case " $_bm_read " in
347
347
natacpi)
348
348
_bd_read=" $ACPIBATDIR /$bs "
349
- _bd_reada=" $ACPIBATDIR /$bs "
350
349
;;
351
350
352
351
tpsmapi)
353
- _bd_read=" $SMAPIBATDIR /$bs "
354
- _bd_reada =" $ACPIBATDIR /$bs "
352
+ _bd_read=" $ACPIBATDIR /$bs "
353
+ _bd_readsm =" $SMAPIBATDIR /$bs "
355
354
;;
356
355
esac
357
356
358
- echo_debug " bat" " batdrv.${_batdrv_plugin} .select_battery($1 ): bat_str=$_bat_str ; cfg=$_bt_cfg_bat ; bat_idx=$_bat_idx ; bd_read=$_bd_read ; bd_reada= $_bd_reada ; bf_start=$_bf_start ; bf_stop=$_bf_stop ; bf_dischg=$_bf_dischg "
357
+ echo_debug " bat" " batdrv.${_batdrv_plugin} .select_battery($1 ): bat_str=$_bat_str ; cfg=$_bt_cfg_bat ; bat_idx=$_bat_idx ; bd_read=$_bd_read ; bd_readsm= $_bd_readsm ; bf_start=$_bf_start ; bf_stop=$_bf_stop ; bf_dischg=$_bf_dischg "
359
358
return 0
360
359
}
361
360
@@ -825,12 +824,12 @@ batdrv_force_discharge_active () { # check if battery is in 'force-discharge' st
825
824
# prerequisite: batdrv_init(), batdrv_select_battery()
826
825
827
826
# battery readings to be returned to caller as retvals (and for trace output)
828
- _bat_en=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_reada /energy_now" ) " ' / 1000.0 );' ) "
827
+ _bat_en=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_read /energy_now" ) " ' / 1000.0 );' ) "
829
828
_bat_soc=" $( batdrv_calc_soc) "
830
- _bat_pwr=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_reada /power_now" ) " ' / 1000.0 );' ) "
831
- _bat_volt=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_reada /voltage_now" ) " ' / 1000.0 );' ) "
829
+ _bat_pwr=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_read /power_now" ) " ' / 1000.0 );' ) "
830
+ _bat_volt=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_read /voltage_now" ) " ' / 1000.0 );' ) "
832
831
833
- _bat_st=" $( read_sysf " $_bd_reada /status" ) "
832
+ _bat_st=" $( read_sysf " $_bd_read /status" ) "
834
833
_bat_fd=" $( batdrv_read_force_discharge 0) "
835
834
if [ " $_bat_en " -le " $_bat_target_en " ]; then
836
835
# target soc reached
@@ -900,9 +899,9 @@ batdrv_discharge () {
900
899
return $_bat_dischg_rc
901
900
fi
902
901
fi
903
- ef=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_reada /energy_full" ) " ' / 1000.0 );' ) "
902
+ ef=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_read /energy_full" ) " ' / 1000.0 );' ) "
904
903
_bat_target_en=" $( perl -e ' printf ("%d", ' " $ef " ' * ' " $target_soc " ' / 100.0)' ) "
905
- en=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_reada /energy_now" ) " ' / 1000.0 );' ) "
904
+ en=" $( perl -e ' printf ("%d", ' " $( read_sysval " $_bd_read /energy_now" ) " ' / 1000.0 );' ) "
906
905
if [ " $_bat_target_en " -ge " $en " ]; then
907
906
echo_debug " bat" " batdrv.${_batdrv_plugin} .discharge.target_below_soc($_bat_str ): target=$target_soc ; soc=$soc "
908
907
cprintf " " " Error: target level (%s%%) is too high compared to the actual charge level (%s%%) of battery %s.\n" " $target_soc " " $soc " " $_bat_str " 1>&2
@@ -1014,7 +1013,7 @@ batdrv_show_battery_data () {
1014
1013
# output battery status
1015
1014
# $1: 1=verbose
1016
1015
# global params: $_batdrv_plugin, $_batteries, $_batdrv_kmod, $_natacpi, $_tpsmapi,
1017
- # $_bm_thresh, $_bm_dischg, $_bd_read, $_bf_start, $_bf_stop, $_bf_dischg
1016
+ # $_bm_thresh, $_bm_dischg, $_bd_read, $_bd_readsm, $ _bf_start, $_bf_stop, $_bf_dischg
1018
1017
# prerequisite: batdrv_init()
1019
1018
local verbose=" ${1:- 0} "
1020
1019
@@ -1133,43 +1132,43 @@ batdrv_show_battery_data () {
1133
1132
;; # natacpi
1134
1133
1135
1134
tpsmapi) # ThinkPad with active tp-smapi
1136
- printparm " %-59s = ##%s##" " $_bd_read /manufacturer"
1137
- printparm " %-59s = ##%s##" " $_bd_read /model"
1138
- printparm " %-59s = ##%s##" " $_bd_read /manufacture_date"
1139
- printparm " %-59s = ##%s##" " $_bd_read /first_use_date"
1140
- printparm " %-59s = ##%6d##" " $_bd_read /cycle_count"
1135
+ printparm " %-59s = ##%s##" " $_bd_readsm /manufacturer"
1136
+ printparm " %-59s = ##%s##" " $_bd_readsm /model"
1137
+ printparm " %-59s = ##%s##" " $_bd_readsm /manufacture_date"
1138
+ printparm " %-59s = ##%s##" " $_bd_readsm /first_use_date"
1139
+ printparm " %-59s = ##%6d##" " $_bd_readsm /cycle_count"
1141
1140
1142
- if [ -f " $_bd_read /temperature" ]; then
1141
+ if [ -f " $_bd_readsm /temperature" ]; then
1143
1142
# shellcheck disable=SC2046
1144
- perl -e ' printf ("%-59s = %6d [°C]\n", "' " $_bd_read /temperature" ' ", ' $( read_sysval " $_bd_read /temperature" ) ' / 1000.0);'
1143
+ perl -e ' printf ("%-59s = %6d [°C]\n", "' " $_bd_readsm /temperature" ' ", ' $( read_sysval " $_bd_readsm /temperature" ) ' / 1000.0);'
1145
1144
fi
1146
1145
1147
- printparm " %-59s = ##%6d## [mWh]" " $_bd_read /design_capacity"
1148
- printparm " %-59s = ##%6d## [mWh]" " $_bd_read /last_full_capacity"
1149
- printparm " %-59s = ##%6d## [mWh]" " $_bd_read /remaining_capacity"
1146
+ printparm " %-59s = ##%6d## [mWh]" " $_bd_readsm /design_capacity"
1147
+ printparm " %-59s = ##%6d## [mWh]" " $_bd_readsm /last_full_capacity"
1148
+ printparm " %-59s = ##%6d## [mWh]" " $_bd_readsm /remaining_capacity"
1150
1149
if [ " $verbose " -eq 1 ]; then
1151
- printparm " %-59s = ##%6d## [%%]" " $_bd_read /remaining_percent"
1150
+ printparm " %-59s = ##%6d## [%%]" " $_bd_readsm /remaining_percent"
1152
1151
fi
1153
- printparm " %-59s = ##%6s## [min]" " $_bd_read /remaining_running_time_now"
1154
- printparm " %-59s = ##%6s## [min]" " $_bd_read /remaining_charging_time"
1155
- printparm " %-59s = ##%6d## [mW]" " $_bd_read /power_now"
1156
- printparm " %-59s = ##%6d## [mW]" " $_bd_read /power_avg"
1157
- print_batstate " $_bd_read /state"
1152
+ printparm " %-59s = ##%6s## [min]" " $_bd_readsm /remaining_running_time_now"
1153
+ printparm " %-59s = ##%6s## [min]" " $_bd_readsm /remaining_charging_time"
1154
+ printparm " %-59s = ##%6d## [mW]" " $_bd_readsm /power_now"
1155
+ printparm " %-59s = ##%6d## [mW]" " $_bd_readsm /power_avg"
1156
+ print_batstate " $_bd_readsm /state"
1158
1157
printf " \n"
1159
1158
if [ " $verbose " -eq 1 ]; then
1160
- printparm " %-59s = ##%6s## [mV]" " $_bd_read /design_voltage"
1161
- printparm " %-59s = ##%6s## [mV]" " $_bd_read /voltage"
1162
- printparm " %-59s = ##%6s## [mV]" " $_bd_read /group0_voltage"
1163
- printparm " %-59s = ##%6s## [mV]" " $_bd_read /group1_voltage"
1164
- printparm " %-59s = ##%6s## [mV]" " $_bd_read /group2_voltage"
1165
- printparm " %-59s = ##%6s## [mV]" " $_bd_read /group3_voltage"
1159
+ printparm " %-59s = ##%6s## [mV]" " $_bd_readsm /design_voltage"
1160
+ printparm " %-59s = ##%6s## [mV]" " $_bd_readsm /voltage"
1161
+ printparm " %-59s = ##%6s## [mV]" " $_bd_readsm /group0_voltage"
1162
+ printparm " %-59s = ##%6s## [mV]" " $_bd_readsm /group1_voltage"
1163
+ printparm " %-59s = ##%6s## [mV]" " $_bd_readsm /group2_voltage"
1164
+ printparm " %-59s = ##%6s## [mV]" " $_bd_readsm /group3_voltage"
1166
1165
printf " \n"
1167
1166
fi
1168
1167
1169
1168
# store values for charge / capacity calculation below
1170
- ed=$( read_sysval " $_bd_read /design_capacity" )
1171
- ef=$( read_sysval " $_bd_read /last_full_capacity" )
1172
- en=$( read_sysval " $_bd_read /remaining_capacity" )
1169
+ ed=$( read_sysval " $_bd_readsm /design_capacity" )
1170
+ ef=$( read_sysval " $_bd_readsm /last_full_capacity" )
1171
+ en=$( read_sysval " $_bd_readsm /remaining_capacity" )
1173
1172
efsum=$(( efsum + ef))
1174
1173
ensum=$(( ensum + en))
1175
1174
;; # tp-smapi
0 commit comments