summaryrefslogtreecommitdiff
path: root/util/battery_temp
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /util/battery_temp
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-release-R101-14588.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'util/battery_temp')
-rwxr-xr-xutil/battery_temp56
1 files changed, 0 insertions, 56 deletions
diff --git a/util/battery_temp b/util/battery_temp
deleted file mode 100755
index c69e3d4778..0000000000
--- a/util/battery_temp
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-# Copyright 2018 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# Description: Read and output temperature of device's primary battery in
-# degrees Celsius.
-#
-# TODO(tbroch) revisit for detachables with multiple batteries.
-
-# Read battery temperature from sysfs power_supply and return in degC.
-batt_temp_sysfs() {
- local temp=""
-
- for psdir in /sys/class/power_supply/* ; do
- if [[ -e "${psdir}/temp" ]] ; then
- pstype=$(cat $psdir/type)
- if [[ "${pstype}" -eq "Battery" ]] ; then
- temp=$(bc <<< "scale=2; $(cat ${psdir}/temp)/10")
- break
- fi
- fi
- done
- echo ${temp}
-}
-
-# Read battery temperature from EC and return in degC.
-batt_temp_ec() {
- local temp=""
-
- local sensor_str=$(ectool tempsinfo all 2>/dev/null | grep Battery)
- if [[ $? -eq 0 ]] && [[ ! -z "${sensor_str}" ]] ; then
- local idx=$(echo ${sensor_str} | cut -d: -f1)
- # ectool temps <idx> looks like 'Reading temperature...298 K'
- temp_str=$(ectool temps ${idx})
- temp="${temp_str//[!0-9]/}"
- if [[ -z "${temp}" ]] ; then
- temp="error"
- else
- temp=$(bc <<< "scale=2; ${temp} - 273.15")
- fi
- fi
- echo $temp
-}
-
-# Main
-TEMP_DEGC=$(batt_temp_sysfs)
-if [[ -z "${TEMP_DEGC}" ]] ; then
- TEMP_DEGC=$(batt_temp_ec)
-fi
-
-if [[ -z "${TEMP_DEGC}" ]] ; then
- echo "unknown"
-else
- echo ${TEMP_DEGC}
-fi