-
Notifications
You must be signed in to change notification settings - Fork 5
/
showpower
50 lines (48 loc) · 1.8 KB
/
showpower
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash -u
# Script_name : showpower
# Author : Bert Lindeman
# Description : Show variables related to EV3 battery
# Version : v1.3
# Date : 2014-11-04
# Usage : showpower
# Notes : The field "status" has a fixed value "Discharging"
# this is by kernel design.
# Copyright : 2014 Bert Lindeman
# License : GPL-3.0+
#
#============================================================================
#
# Changelog
# Date By Description
# 20141104 BL prepare for release v1.3
# 20140914 BL small cleanup
# 20140826 BL 0 add script header
# 0 made a bit more robust
#============================================================================
devide_1000000 () {
volt=$(bc <<< "scale=7; $2/1000000")
printf "%20s : %11.3f\n" $1 $volt
}
#
cd /sys/devices/platform/legoev3-battery/power_supply/legoev3-battery
echo "printing info from `pwd`"
#
#
printf "%20s : %11s\n" "Battery type" `cat type`
printf "%20s : %11s\n" "technology" `cat technology`
devide_1000000 " current_now" `cat current_now`
#
if [ `cat present` == 1 ]; then
ISpresentBOOL="YES present"
else
ISpresentBOOL="NO absent"
fi
printf "%20s : %11s\n" "present" "$ISpresentBOOL"
#
printf "%20s : %11s\n" "scope" `cat scope`
printf "%20s : %11s %s\n" "status" `cat status` "(fake value)"
devide_1000000 " voltage_max_design" `cat voltage_max_design`
devide_1000000 " voltage_min_design" `cat voltage_min_design`
devide_1000000 " voltage_now" `cat voltage_now`
# just for verification:
echo -e " uevent: \n`cat uevent`" # too many lines of output