Open vazhnov opened 3 years ago
I probably should use some advice from https://stackoverflow.com/questions/8654051/how-to-compare-two-floating-point-numbers-in-bash
Similar error when the battery is not connected, and VBUS_C
= -
:
$ sudo bash ./axp209.sh -a
ACIN: 1 Avail: 1
VBUS: 0 Avail: 0
VHOLD: 0 (Whether VBUS is above 4.4V before being used)
Shutdown voltage: 2.9V
VBUS current limit: 900mA
Boot source is ACIN/VBUS
Battery connected: 0
No Battery connected
Temperature: 39.2°C
Battery: -%
ACIN: 5.0490V 276.000mA
VBUS: -V./axp209.sh: line 225: [: -: integer expression expected
./axp209.sh: line 231: [: -: integer expression expected
Here is the code:
if [ $VBUS_C -gt 0 ];then
https://github.com/vazhnov/sunxi-axp209/commit/9355e0ce14ee7b55d801d4930971e0891947e18f — replaced -gt
to !=
. So now logic should work when variable is 0
or any digit (integer or not), but logic probably broke when variable is -
.
Result without battery:
% sudo bash ./axp209.sh -a
ACIN: 1 Avail: 1
VBUS: 0 Avail: 0
VHOLD: 0 (Whether VBUS is above 4.4V before being used)
Charge direction: 0 (0:Battery discharging; 1:The battery is charging)
Shutdown voltage: 2.9V
VBUS current limit: 900mA
Boot source is ACIN/VBUS
Battery connected: 0
No Battery connected
Temperature: 39.2°C
Battery: -%
ACIN: 5.0456V 280.125mA
VBUS: -V -mA
VBAT: -V Discharging at mA
Vout: 4.9616V
Result with a charging battery:
% sudo bash ./axp209.sh -a
ACIN: 1 Avail: 1
VBUS: 0 Avail: 0
VHOLD: 0 (Whether VBUS is above 4.4V before being used)
Charge direction: 1 (0:Battery discharging; 1:The battery is charging)
Shutdown voltage: 2.9V
VBUS current limit: 900mA
Boot source is ACIN/VBUS
Battery charging
Battery connected: 1
Temperature: 42.3°C
Battery: 92%
ACIN: 4.9453V 554.250mA
VBUS: -V -mA
VBAT: 4.2031V Charging at 594.0mA
Vout: 4.8538V
Result with a discharging battery:
% sudo bash ./axp209.sh -a
ACIN: 0 Avail: 0
VBUS: 0 Avail: 0
VHOLD: 0 (Whether VBUS is above 4.4V before being used)
Charge direction: 0 (0:Battery discharging; 1:The battery is charging)
Shutdown voltage: 2.9V
VBUS current limit: 900mA
Boot source is ACIN/VBUS
Battery connected: 1
Temperature: 39.3°C
Battery: 100%
ACIN: -V -mA
VBUS: -V -mA
VBAT: 4.0997V Discharging at 227.0mA
Vout: 4.0628V
(here exit code is 1).
SBC Olimex A20-OLinuXino-LIME2, Debian 10 Buster, Bash 5.0:
Here is the code, which gave an error when
VBAT
=4.1932
:After ugly workaround: