#!/usr/bin/clitest
# Test charge thresholds for Toshiba/Dynabook laptops
# Requirements:
# * Hardware: Toshiba/Dynabook laptop w/ toshiba_acpi driver
# * Battery: BAT1
# * Software: kernel 6.0+
# Copyright (c) 2023 Thomas Koch <linrunner at gmx.net>.
# SPDX-License-Identifier: GPL-2.0-or-later
#
$ # +++ Toshiba/Dynabook ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$ #
$ # --- tlp start
$ sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
TLP started in AC mode (auto).
$ sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1="42" STOP_CHARGE_THRESH_BAT1="24"
Error in configuration at STOP_CHARGE_THRESH_BAT1="24": not specified or invalid (must be 80 or 100). Battery skipped.
TLP started in AC mode (auto).
$ sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1="42" STOP_CHARGE_THRESH_BAT1="80"
TLP started in AC mode (auto).
$ sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF"
TLP started in AC mode (auto).
$ sudo tlp start -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF"
TLP started in AC mode (auto).
$ #
$ # --- tlp setcharge w/o threshold arguments
$ sudo tlp setcharge BAT1 -- START_CHARGE_THRESH_BAT1="42" STOP_CHARGE_THRESH_BAT1="24"
Error in configuration at STOP_CHARGE_THRESH_BAT1="24": not specified or invalid (must be 80 or 100). Aborted.
$ sudo tlp setcharge BAT1 -- START_CHARGE_THRESH_BAT1="DEF" STOP_CHARGE_THRESH_BAT1="DEF"
Setting temporary charge threshold for BAT1:
  stop = 100 (no change)
$ #
$ # --- tlp setcharge w/ threshold arguments
$ sudo tlp setcharge 42 24 BAT1
Error: stop charge threshold (24) for BAT1 is not specified or invalid (must be 80 or 100). Aborted.
$ sudo tlp setcharge 42 100 BAT1
Setting temporary charge threshold for BAT1:
  stop = 100 (no change)
$ sudo tlp setcharge 42 80 BAT1
Setting temporary charge threshold for BAT1:
  stop =  80
$ sudo tlp setcharge DEF DEF BAT1
Setting temporary charge threshold for BAT1:
  stop = 100
$ sudo tlp setcharge 42 80
Error: battery BAT0 not present.
$ sudo tlp setcharge 2
Error: battery 2 not present.
$ #
$ # --- tlp-stat
$ sudo tlp-stat -b | sudo tlp-stat -b | grep -E 'charge_control
/sys/class/power_supply/BAT1/charge_control_end_threshold   =    100 [%]
$ #
